| 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 f_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ml(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var VA={exports:{}},ib={};var ZU;function eoe(){if(ZU)return ib;ZU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:a}}return ib.Fragment=e,ib.jsx=n,ib.jsxs=n,ib}var QU;function toe(){return QU||(QU=1,VA.exports=eoe()),VA.exports}var s=toe(),GA={exports:{}},gn={};var JU;function noe(){if(JU)return gn;JU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),m=Symbol.iterator;function p(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,x={};function v(z,V,ne){this.props=z,this.context=V,this.refs=x,this.updater=ne||b}v.prototype.isReactComponent={},v.prototype.setState=function(z,V){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,V,"setState")},v.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function S(){}S.prototype=v.prototype;function M(z,V,ne){this.props=z,this.context=V,this.refs=x,this.updater=ne||b}var 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},D=Object.prototype.hasOwnProperty;function C(z,V,ne){var ae=ne.ref;return{$$typeof:t,type:z,key:V,ref:ae!==void 0?ae:null,props:ne}}function R(z,V){return C(z.type,V,z.props)}function U(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function O(z){var V={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(ne){return V[ne]})}var q=/\/+/g;function j(z,V){return typeof z=="object"&&z!==null&&z.key!=null?O(""+z.key):V.toString(36)}function W(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(k,k):(z.status="pending",z.then(function(V){z.status==="pending"&&(z.status="fulfilled",z.value=V)},function(V){z.status==="pending"&&(z.status="rejected",z.reason=V)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function K(z,V,ne,ae,he){var pe=typeof z;(pe==="undefined"||pe==="boolean")&&(z=null);var ie=!1;if(z===null)ie=!0;else switch(pe){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),V,ne,ae,he)}}if(ie)return he=he(z),ie=ae===""?"."+j(z,0):ae,T(he)?(ne="",ie!=null&&(ne=ie.replace(q,"$&/")+"/"),K(he,V,ne,"",function(Ne){return Ne})):he!=null&&(U(he)&&(he=R(he,ne+(he.key==null||z&&z.key===he.key?"":(""+he.key).replace(q,"$&/")+"/")+ie)),V.push(he)),1;ie=0;var Ee=ae===""?".":ae+":";if(T(z))for(var xe=0;xe<z.length;xe++)ae=z[xe],pe=Ee+j(ae,xe),ie+=K(ae,V,ne,pe,he);else if(xe=p(z),typeof xe=="function")for(z=xe.call(z),xe=0;!(ae=z.next()).done;)ae=ae.value,pe=Ee+j(ae,xe++),ie+=K(ae,V,ne,pe,he);else if(pe==="object"){if(typeof z.then=="function")return K(W(z),V,ne,ae,he);throw V=String(z),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return ie}function G(z,V,ne){if(z==null)return z;var ae=[],he=0;return K(z,ae,"","",function(pe){return V.call(ne,pe,he++)}),ae}function Q(z){if(z._status===-1){var V=z._result;V=V(),V.then(function(ne){(z._status===0||z._status===-1)&&(z._status=1,z._result=ne)},function(ne){(z._status===0||z._status===-1)&&(z._status=2,z._result=ne)}),z._status===-1&&(z._status=0,z._result=V)}if(z._status===1)return z._result.default;throw z._result}var te=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},J={map:G,forEach:function(z,V,ne){G(z,function(){V.apply(this,arguments)},ne)},count:function(z){var V=0;return G(z,function(){V++}),V},toArray:function(z){return G(z,function(V){return V})||[]},only:function(z){if(!U(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return gn.Activity=f,gn.Children=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,V,ne){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var ae=y({},z.props),he=z.key;if(V!=null)for(pe in V.key!==void 0&&(he=""+V.key),V)!D.call(V,pe)||pe==="key"||pe==="__self"||pe==="__source"||pe==="ref"&&V.ref===void 0||(ae[pe]=V[pe]);var pe=arguments.length-2;if(pe===1)ae.children=ne;else if(1<pe){for(var ie=Array(pe),Ee=0;Ee<pe;Ee++)ie[Ee]=arguments[Ee+2];ae.children=ie}return C(z.type,he,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,V,ne){var ae,he={},pe=null;if(V!=null)for(ae in V.key!==void 0&&(pe=""+V.key),V)D.call(V,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(he[ae]=V[ae]);var ie=arguments.length-2;if(ie===1)he.children=ne;else if(1<ie){for(var Ee=Array(ie),xe=0;xe<ie;xe++)Ee[xe]=arguments[xe+2];he.children=Ee}if(z&&z.defaultProps)for(ae in ie=z.defaultProps,ie)he[ae]===void 0&&(he[ae]=ie[ae]);return C(z,pe,he)},gn.createRef=function(){return{current:null}},gn.forwardRef=function(z){return{$$typeof:l,render:z}},gn.isValidElement=U,gn.lazy=function(z){return{$$typeof:d,_payload:{_status:-1,_result:z},_init:Q}},gn.memo=function(z,V){return{$$typeof:u,type:z,compare:V===void 0?null:V}},gn.startTransition=function(z){var V=E.T,ne={};E.T=ne;try{var ae=z(),he=E.S;he!==null&&he(ne,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(k,te)}catch(pe){te(pe)}finally{V!==null&&ne.types!==null&&(V.types=ne.types),E.T=V}},gn.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},gn.use=function(z){return E.H.use(z)},gn.useActionState=function(z,V,ne){return E.H.useActionState(z,V,ne)},gn.useCallback=function(z,V){return E.H.useCallback(z,V)},gn.useContext=function(z){return E.H.useContext(z)},gn.useDebugValue=function(){},gn.useDeferredValue=function(z,V){return E.H.useDeferredValue(z,V)},gn.useEffect=function(z,V){return E.H.useEffect(z,V)},gn.useEffectEvent=function(z){return E.H.useEffectEvent(z)},gn.useId=function(){return E.H.useId()},gn.useImperativeHandle=function(z,V,ne){return E.H.useImperativeHandle(z,V,ne)},gn.useInsertionEffect=function(z,V){return E.H.useInsertionEffect(z,V)},gn.useLayoutEffect=function(z,V){return E.H.useLayoutEffect(z,V)},gn.useMemo=function(z,V){return E.H.useMemo(z,V)},gn.useOptimistic=function(z,V){return E.H.useOptimistic(z,V)},gn.useReducer=function(z,V,ne){return E.H.useReducer(z,V,ne)},gn.useRef=function(z){return E.H.useRef(z)},gn.useState=function(z){return E.H.useState(z)},gn.useSyncExternalStore=function(z,V,ne){return E.H.useSyncExternalStore(z,V,ne)},gn.useTransition=function(){return E.H.useTransition()},gn.version="19.2.3",gn}var ez;function Gg(){return ez||(ez=1,GA.exports=noe()),GA.exports}var w=Gg();const Ur=ml(w),roe=Jse({__proto__:null,default:Ur},[w]);var WA={exports:{}},ab={},qA={exports:{}},KA={};var tz;function ioe(){return tz||(tz=1,(function(t){function e(K,G){var Q=K.length;K.push(G);e:for(;0<Q;){var te=Q-1>>>1,J=K[te];if(0<i(J,G))K[te]=G,K[Q]=J,Q=te;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var G=K[0],Q=K.pop();if(Q!==G){K[0]=Q;e:for(var te=0,J=K.length,z=J>>>1;te<z;){var V=2*(te+1)-1,ne=K[V],ae=V+1,he=K[ae];if(0>i(ne,Q))ae<J&&0>i(he,ne)?(K[te]=he,K[ae]=Q,te=ae):(K[te]=ne,K[V]=Q,te=V);else if(ae<J&&0>i(he,Q))K[te]=he,K[ae]=Q,te=ae;else break e}}return G}function i(K,G){var Q=K.sortIndex-G.sortIndex;return Q!==0?Q:K.id-G.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var 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 G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=K)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function T(K){if(y=!1,A(K),!b)if(n(c)!==null)b=!0,k||(k=!0,O());else{var G=n(u);G!==null&&W(T,G.startTime-K)}}var k=!1,E=-1,D=5,C=-1;function R(){return x?!0:!(t.unstable_now()-C<D)}function U(){if(x=!1,k){var K=t.unstable_now();C=K;var G=!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&&R());){var te=f.callback;if(typeof te=="function"){f.callback=null,m=f.priorityLevel;var J=te(f.expirationTime<=K);if(K=t.unstable_now(),typeof J=="function"){f.callback=J,A(K),G=!0;break t}f===n(c)&&r(c),A(K)}else r(c);f=n(c)}if(f!==null)G=!0;else{var z=n(u);z!==null&&W(T,z.startTime-K),G=!1}}break e}finally{f=null,m=Q,p=!1}G=void 0}}finally{G?O():k=!1}}}var O;if(typeof M=="function")O=function(){M(U)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,j=q.port2;q.port1.onmessage=U,O=function(){j.postMessage(null)}}else O=function(){v(U,0)};function W(K,G){E=v(function(){K(t.unstable_now())},G)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function(K){switch(m){case 1:case 2:case 3:var G=3;break;default:G=m}var Q=m;m=G;try{return K()}finally{m=Q}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(K,G){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var Q=m;m=K;try{return G()}finally{m=Q}},t.unstable_scheduleCallback=function(K,G,Q){var te=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?te+Q:te):Q=te,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:G,priorityLevel:K,startTime:Q,expirationTime:J,sortIndex:-1},Q>te?(K.sortIndex=Q,e(u,K),n(c)===null&&K===n(u)&&(y?(S(E),E=-1):y=!0,W(T,Q-te))):(K.sortIndex=J,e(c,K),b||p||(b=!0,k||(k=!0,O()))),K},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(K){var G=m;return function(){var Q=m;m=G;try{return K.apply(this,arguments)}finally{m=Q}}}})(KA)),KA}var nz;function aoe(){return nz||(nz=1,qA.exports=ioe()),qA.exports}var XA={exports:{}},ka={};var rz;function soe(){if(rz)return ka;rz=1;var t=Gg();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ka.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ka.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)},ka.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()}},ka.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))},ka.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ka.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})}},ka.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)},ka.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})}},ka.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)},ka.requestFormReset=function(c){r.d.r(c)},ka.unstable_batchedUpdates=function(c,u){return c(u)},ka.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},ka.useFormStatus=function(){return o.H.useHostTransitionStatus()},ka.version="19.2.3",ka}var iz;function bq(){if(iz)return XA.exports;iz=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),XA.exports=soe(),XA.exports}var az;function ooe(){if(az)return ab;az=1;var t=aoe(),e=Gg(),n=bq();function r(h){var g="https://react.dev/errors/"+h;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var g=h,_=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(_=g.return),h=g.return;while(h)}return g.tag===3?_:null}function o(h){if(h.tag===13){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function l(h){if(h.tag===31){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=a(h),g===null)throw Error(r(188));return g!==h?null:h}for(var _=h,N=g;;){var P=_.return;if(P===null)break;var F=P.alternate;if(F===null){if(N=P.return,N!==null){_=N;continue}break}if(P.child===F.child){for(F=P.child;F;){if(F===_)return c(P),h;if(F===N)return c(P),g;F=F.sibling}throw Error(r(188))}if(_.return!==N.return)_=P,N=F;else{for(var Z=!1,ge=P.child;ge;){if(ge===_){Z=!0,_=P,N=F;break}if(ge===N){Z=!0,N=P,_=F;break}ge=ge.sibling}if(!Z){for(ge=F.child;ge;){if(ge===_){Z=!0,_=F,N=P;break}if(ge===N){Z=!0,N=F,_=P;break}ge=ge.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"),D=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function O(h){return h===null||typeof h!="object"?null:(h=U&&h[U]||h["@@iterator"],typeof h=="function"?h:null)}var q=Symbol.for("react.client.reference");function j(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===q?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case v:return"Profiler";case x:return"StrictMode";case 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:j(h.type)||"Memo";case D:g=h._payload,h=h._init;try{return j(h(g))}catch{}}return null}var W=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},te=[],J=-1;function z(h){return{current:h}}function V(h){0>J||(h.current=te[J],te[J]=null,J--)}function ne(h,g){J++,te[J]=h.current,h.current=g}var ae=z(null),he=z(null),pe=z(null),ie=z(null);function Ee(h,g){switch(ne(pe,g),ne(he,h),ne(ae,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?vU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=vU(g),h=_U(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}V(ae),ne(ae,h)}function xe(){V(ae),V(he),V(pe)}function Ne(h){h.memoizedState!==null&&ne(ie,h);var g=ae.current,_=_U(g,h.type);g!==_&&(ne(he,h),ne(ae,_))}function _e(h){he.current===h&&(V(ae),V(he)),ie.current===h&&(V(ie),eb._currentValue=Q)}var le,Ve;function H(h){if(le===void 0)try{throw Error()}catch(_){var g=_.stack.trim().match(/\n( *(at )?)/);le=g&&g[1]||"",Ve=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+le+h+Ve}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(ht){var ot=ht}Reflect.construct(h,[],vt)}else{try{vt.call()}catch(ht){ot=ht}h.call(vt.prototype)}}else{try{throw Error()}catch(ht){ot=ht}(vt=h())&&typeof vt.catch=="function"&&vt.catch(function(){})}}catch(ht){if(ht&&ot&&typeof ht.stack=="string")return[ht.stack,ot.stack]}return[null,null]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var P=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");P&&P.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=N.DetermineComponentFrameRoot(),Z=F[0],ge=F[1];if(Z&&ge){var Oe=Z.split(`
- `),it=ge.split(`
- `);for(P=N=0;N<Oe.length&&!Oe[N].includes("DetermineComponentFrameRoot");)N++;for(;P<it.length&&!it[P].includes("DetermineComponentFrameRoot");)P++;if(N===Oe.length||P===it.length)for(N=Oe.length-1,P=it.length-1;1<=N&&0<=P&&Oe[N]!==it[P];)P--;for(;1<=N&&0<=P;N--,P--)if(Oe[N]!==it[P]){if(N!==1||P!==1)do if(N--,P--,0>P||Oe[N]!==it[P]){var xt=`
- `+Oe[N].replace(" at new "," at ");return h.displayName&&xt.includes("<anonymous>")&&(xt=xt.replace("<anonymous>",h.displayName)),xt}while(1<=N&&0<=P);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 ue=Object.prototype.hasOwnProperty,Ae=t.unstable_scheduleCallback,Ie=t.unstable_cancelCallback,ce=t.unstable_shouldYield,$=t.unstable_requestPaint,L=t.unstable_now,Y=t.unstable_getCurrentPriorityLevel,be=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,se=t.unstable_NormalPriority,Pe=t.unstable_LowPriority,Re=t.unstable_IdlePriority,Xe=t.log,et=t.unstable_setDisableYieldValue,Je=null,oe=null;function ye(h){if(typeof Xe=="function"&&et(h),oe&&typeof oe.setStrictMode=="function")try{oe.setStrictMode(Je,h)}catch{}}var je=Math.clz32?Math.clz32:re,$e=Math.log,ft=Math.LN2;function re(h){return h>>>=0,h===0?32:31-($e(h)/ft|0)|0}var ke=256,ve=262144,Fe=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 Te(h,g,_){var N=h.pendingLanes;if(N===0)return 0;var P=0,F=h.suspendedLanes,Z=h.pingedLanes;h=h.warmLanes;var ge=N&134217727;return ge!==0?(N=ge&~F,N!==0?P=Ue(N):(Z&=ge,Z!==0?P=Ue(Z):_||(_=ge&~h,_!==0&&(P=Ue(_))))):(ge=N&~F,ge!==0?P=Ue(ge):Z!==0?P=Ue(Z):_||(_=N&~h,_!==0&&(P=Ue(_)))),P===0?0:g!==0&&g!==P&&(g&F)===0&&(F=P&-P,_=g&-g,F>=_||F===32&&(_&4194048)!==0)?g:P}function qe(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function bt(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 Pt(){var h=Fe;return Fe<<=1,(Fe&62914560)===0&&(Fe=4194304),h}function Ot(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,P,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 ge=h.entanglements,Oe=h.expirationTimes,it=h.hiddenUpdates;for(_=Z&~_;0<_;){var xt=31-je(_),vt=1<<xt;ge[xt]=0,Oe[xt]=-1;var ot=it[xt];if(ot!==null)for(it[xt]=null,xt=0;xt<ot.length;xt++){var ht=ot[xt];ht!==null&&(ht.lane&=-536870913)}_&=~vt}N!==0&&vn(h,N,0),F!==0&&P===0&&h.tag!==0&&(h.suspendedLanes|=F&~(Z&~g))}function vn(h,g,_){h.pendingLanes|=g,h.suspendedLanes&=~g;var N=31-je(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-je(_),P=1<<N;P&g|h[N]&g&&(h[N]|=g),_&=~P}}function Kt(h,g){var _=g&-g;return _=(_&42)!==0?1:pn(_),(_&(h.suspendedLanes|g))!==0?0:_}function pn(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 Et(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Ln(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:VU(h.type))}function Nr(h,g){var _=G.p;try{return G.p=h,g()}finally{G.p=_}}var Or=Math.random().toString(36).slice(2),tn="__reactFiber$"+Or,yr="__reactProps$"+Or,xi="__reactContainer$"+Or,lr="__reactEvents$"+Or,we="__reactListeners$"+Or,Ye="__reactHandles$"+Or,at="__reactResources$"+Or,ct="__reactMarker$"+Or;function st(h){delete h[tn],delete h[yr],delete h[lr],delete h[we],delete h[Ye]}function Ct(h){var g=h[tn];if(g)return g;for(var _=h.parentNode;_;){if(g=_[xi]||_[tn]){if(_=g.alternate,g.child!==null||_!==null&&_.child!==null)for(h=TU(h);h!==null;){if(_=h[tn])return _;h=TU(h)}return g}h=_,_=h.parentNode}return null}function Ft(h){if(h=h[tn]||h[xi]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function Yt(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Zt(h){var g=h[at];return g||(g=h[at]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function de(h){h[ct]=!0}var De=new Set,We={};function Ze(h,g){Ge(h,g),Ge(h+"Capture",g)}function Ge(h,g){for(We[h]=g,h=0;h<g.length;h++)De.add(g[h])}var lt=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]*$"),kt={},wt={};function _t(h){return ue.call(wt,h)?!0:ue.call(kt,h)?!1:lt.test(h)?wt[h]=!0:(kt[h]=!0,!1)}function Ut(h,g,_){if(_t(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 Le(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 pt(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 me(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function He(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Lt(h,g,_){var N=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof N<"u"&&typeof N.get=="function"&&typeof N.set=="function"){var P=N.get,F=N.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return P.call(this)},set:function(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 jt(h){if(!h._valueTracker){var g=He(h)?"checked":"value";h._valueTracker=Lt(h,g,""+h[g])}}function Wt(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var _=g.getValue(),N="";return h&&(N=He(h)?h.checked?"true":"false":h.value),h=N,h!==_?(g.setValue(h),!0):!1}function Rt(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 Bt=/[\n"\\]/g;function At(h){return h.replace(Bt,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function nn(h,g,_,N,P,F,Z,ge){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=""+me(g)):h.value!==""+me(g)&&(h.value=""+me(g)):Z!=="submit"&&Z!=="reset"||h.removeAttribute("value"),g!=null?Lr(h,Z,me(g)):_!=null?Lr(h,Z,me(_)):N!=null&&h.removeAttribute("value"),P==null&&F!=null&&(h.defaultChecked=!!F),P!=null&&(h.checked=P&&typeof P!="function"&&typeof P!="symbol"),ge!=null&&typeof ge!="function"&&typeof ge!="symbol"&&typeof ge!="boolean"?h.name=""+me(ge):h.removeAttribute("name")}function Zr(h,g,_,N,P,F,Z,ge){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)){jt(h);return}_=_!=null?""+me(_):"",g=g!=null?""+me(g):_,ge||g===h.value||(h.value=g),h.defaultValue=g}N=N??P,N=typeof N!="function"&&typeof N!="symbol"&&!!N,h.checked=ge?h.checked:!!N,h.defaultChecked=!!N,Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"&&(h.name=Z),jt(h)}function Lr(h,g,_){g==="number"&&Rt(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function ca(h,g,_,N){if(h=h.options,g){g={};for(var P=0;P<_.length;P++)g["$"+_[P]]=!0;for(_=0;_<h.length;_++)P=g.hasOwnProperty("$"+h[_].value),h[_].selected!==P&&(h[_].selected=P),P&&N&&(h[_].defaultSelected=!0)}else{for(_=""+me(_),g=null,P=0;P<h.length;P++){if(h[P].value===_){h[P].selected=!0,N&&(h[P].defaultSelected=!0);return}g!==null||h[P].disabled||(g=h[P])}g!==null&&(g.selected=!0)}}function $n(h,g,_){if(g!=null&&(g=""+me(g),g!==h.value&&(h.value=g),_==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=_!=null?""+me(_):""}function di(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=_}_=me(g),h.defaultValue=_,N=h.textContent,N===_&&N!==""&&N!==null&&(h.value=N),jt(h)}function vr(h,g){if(g){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=g;return}}h.textContent=g}var Zn=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Tr(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||Zn.has(g)?g==="float"?h.cssFloat=_:h[g]=(""+_).trim():h[g]=_+"px"}function to(h,g,_){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,_!=null){for(var N in _)!_.hasOwnProperty(N)||g!=null&&g.hasOwnProperty(N)||(N.indexOf("--")===0?h.setProperty(N,""):N==="float"?h.cssFloat="":h[N]="");for(var P in g)N=g[P],g.hasOwnProperty(P)&&_[P]!==N&&Tr(h,P,N)}else for(var F in g)g.hasOwnProperty(F)&&Tr(h,F,g[F])}function Cr(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 Xie=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"]]),Yie=/^[\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 iv(h){return Yie.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function fc(){}var BE=null;function $E(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var bm=null,ym=null;function yI(h){var g=Ft(h);if(g&&(h=g.stateNode)){var _=h[yr]||null;e:switch(h=g.stateNode,g.type){case"input":if(nn(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),g=_.name,_.type==="radio"&&g!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+At(""+g)+'"][type="radio"]'),g=0;g<_.length;g++){var N=_[g];if(N!==h&&N.form===h.form){var P=N[yr]||null;if(!P)throw Error(r(90));nn(N,P.value,P.defaultValue,P.defaultValue,P.checked,P.defaultChecked,P.type,P.name)}}for(g=0;g<_.length;g++)N=_[g],N.form===h.form&&Wt(N)}break e;case"textarea":$n(h,_.value,_.defaultValue);break e;case"select":g=_.value,g!=null&&ca(h,!!_.multiple,g,!1)}}}var HE=!1;function vI(h,g,_){if(HE)return h(g,_);HE=!0;try{var N=h(g);return N}finally{if(HE=!1,(bm!==null||ym!==null)&&(Gv(),bm&&(g=bm,h=ym,ym=bm=null,yI(g),h)))for(g=0;g<h.length;g++)yI(h[g])}}function xx(h,g){var _=h.stateNode;if(_===null)return null;var N=_[yr]||null;if(N===null)return null;_=N[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(N=!N.disabled)||(h=h.type,N=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!N;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,g,typeof _));return _}var mc=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),VE=!1;if(mc)try{var bx={};Object.defineProperty(bx,"passive",{get:function(){VE=!0}}),window.addEventListener("test",bx,bx),window.removeEventListener("test",bx,bx)}catch{VE=!1}var ju=null,GE=null,av=null;function _I(){if(av)return av;var h,g=GE,_=g.length,N,P="value"in ju?ju.value:ju.textContent,F=P.length;for(h=0;h<_&&g[h]===P[h];h++);var Z=_-h;for(N=1;N<=Z&&g[_-N]===P[F-N];N++);return av=P.slice(h,1<N?1-N:void 0)}function sv(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 ov(){return!0}function wI(){return!1}function ls(h){function g(_,N,P,F,Z){this._reactName=_,this._targetInst=P,this.type=N,this.nativeEvent=F,this.target=Z,this.currentTarget=null;for(var ge in h)h.hasOwnProperty(ge)&&(_=h[ge],this[ge]=_?_(F):F[ge]);return this.isDefaultPrevented=(F.defaultPrevented!=null?F.defaultPrevented:F.returnValue===!1)?ov:wI,this.isPropagationStopped=wI,this}return f(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=ov)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=ov)},persist:function(){},isPersistent:ov}),g}var wh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},lv=ls(wh),yx=f({},wh,{view:0,detail:0}),Zie=ls(yx),WE,qE,vx,cv=f({},yx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:XE,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==vx&&(vx&&h.type==="mousemove"?(WE=h.screenX-vx.screenX,qE=h.screenY-vx.screenY):qE=WE=0,vx=h),WE)},movementY:function(h){return"movementY"in h?h.movementY:qE}}),SI=ls(cv),Qie=f({},cv,{dataTransfer:0}),Jie=ls(Qie),eae=f({},yx,{relatedTarget:0}),KE=ls(eae),tae=f({},wh,{animationName:0,elapsedTime:0,pseudoElement:0}),nae=ls(tae),rae=f({},wh,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),iae=ls(rae),aae=f({},wh,{data:0}),MI=ls(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 XE(){return cae}var uae=f({},yx,{key:function(h){if(h.key){var g=sae[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=sv(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:XE,charCode:function(h){return h.type==="keypress"?sv(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?sv(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),dae=ls(uae),hae=f({},cv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),NI=ls(hae),fae=f({},yx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:XE}),mae=ls(fae),pae=f({},wh,{propertyName:0,elapsedTime:0,pseudoElement:0}),gae=ls(pae),xae=f({},cv,{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=ls(xae),yae=f({},wh,{newState:0,oldState:0}),vae=ls(yae),_ae=[9,13,27,32],YE=mc&&"CompositionEvent"in window,_x=null;mc&&"documentMode"in document&&(_x=document.documentMode);var wae=mc&&"TextEvent"in window&&!_x,EI=mc&&(!YE||_x&&8<_x&&11>=_x),AI=" ",TI=!1;function CI(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 kI(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var vm=!1;function Sae(h,g){switch(h){case"compositionend":return kI(g);case"keypress":return g.which!==32?null:(TI=!0,AI);case"textInput":return h=g.data,h===AI&&TI?null:h;default:return null}}function Mae(h,g){if(vm)return h==="compositionend"||!YE&&CI(h,g)?(h=_I(),av=GE=ju=null,vm=!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 EI&&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 jI(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!Nae[h.type]:g==="textarea"}function PI(h,g,_,N){bm?ym?ym.push(N):ym=[N]:bm=N,g=Qv(g,"onChange"),0<g.length&&(_=new lv("onChange","change",null,_,N),h.push({event:_,listeners:g}))}var wx=null,Sx=null;function Eae(h){mU(h,0)}function uv(h){var g=Yt(h);if(Wt(g))return h}function RI(h,g){if(h==="change")return g}var DI=!1;if(mc){var ZE;if(mc){var QE="oninput"in document;if(!QE){var OI=document.createElement("div");OI.setAttribute("oninput","return;"),QE=typeof OI.oninput=="function"}ZE=QE}else ZE=!1;DI=ZE&&(!document.documentMode||9<document.documentMode)}function LI(){wx&&(wx.detachEvent("onpropertychange",II),Sx=wx=null)}function II(h){if(h.propertyName==="value"&&uv(Sx)){var g=[];PI(g,Sx,h,$E(h)),vI(Eae,g)}}function Aae(h,g,_){h==="focusin"?(LI(),wx=g,Sx=_,wx.attachEvent("onpropertychange",II)):h==="focusout"&&LI()}function Tae(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return uv(Sx)}function Cae(h,g){if(h==="click")return uv(g)}function kae(h,g){if(h==="input"||h==="change")return uv(g)}function jae(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Cs=typeof Object.is=="function"?Object.is:jae;function Mx(h,g){if(Cs(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var _=Object.keys(h),N=Object.keys(g);if(_.length!==N.length)return!1;for(N=0;N<_.length;N++){var P=_[N];if(!ue.call(g,P)||!Cs(h[P],g[P]))return!1}return!0}function FI(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function UI(h,g){var _=FI(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}_=FI(_)}}function zI(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?zI(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function BI(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=Rt(h.document);g instanceof h.HTMLIFrameElement;){try{var _=typeof g.contentWindow.location.href=="string"}catch{_=!1}if(_)h=g.contentWindow;else break;g=Rt(h.document)}return g}function JE(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g&&(g==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||g==="textarea"||h.contentEditable==="true")}var Pae=mc&&"documentMode"in document&&11>=document.documentMode,_m=null,e2=null,Nx=null,t2=!1;function $I(h,g,_){var N=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;t2||_m==null||_m!==Rt(N)||(N=_m,"selectionStart"in N&&JE(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),Nx&&Mx(Nx,N)||(Nx=N,N=Qv(e2,"onSelect"),0<N.length&&(g=new lv("onSelect","select",null,g,_),h.push({event:g,listeners:N}),g.target=_m)))}function Sh(h,g){var _={};return _[h.toLowerCase()]=g.toLowerCase(),_["Webkit"+h]="webkit"+g,_["Moz"+h]="moz"+g,_}var wm={animationend:Sh("Animation","AnimationEnd"),animationiteration:Sh("Animation","AnimationIteration"),animationstart:Sh("Animation","AnimationStart"),transitionrun:Sh("Transition","TransitionRun"),transitionstart:Sh("Transition","TransitionStart"),transitioncancel:Sh("Transition","TransitionCancel"),transitionend:Sh("Transition","TransitionEnd")},n2={},HI={};mc&&(HI=document.createElement("div").style,"AnimationEvent"in window||(delete wm.animationend.animation,delete wm.animationiteration.animation,delete wm.animationstart.animation),"TransitionEvent"in window||delete wm.transitionend.transition);function Mh(h){if(n2[h])return n2[h];if(!wm[h])return h;var g=wm[h],_;for(_ in g)if(g.hasOwnProperty(_)&&_ in HI)return n2[h]=g[_];return h}var VI=Mh("animationend"),GI=Mh("animationiteration"),WI=Mh("animationstart"),Rae=Mh("transitionrun"),Dae=Mh("transitionstart"),Oae=Mh("transitioncancel"),qI=Mh("transitionend"),KI=new Map,r2="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");r2.push("scrollEnd");function $o(h,g){KI.set(h,g),Ze(g,[h])}var dv=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},no=[],Sm=0,i2=0;function hv(){for(var h=Sm,g=i2=Sm=0;g<h;){var _=no[g];no[g++]=null;var N=no[g];no[g++]=null;var P=no[g];no[g++]=null;var F=no[g];if(no[g++]=null,N!==null&&P!==null){var Z=N.pending;Z===null?P.next=P:(P.next=Z.next,Z.next=P),N.pending=P}F!==0&&XI(_,P,F)}}function fv(h,g,_,N){no[Sm++]=h,no[Sm++]=g,no[Sm++]=_,no[Sm++]=N,i2|=N,h.lanes|=N,h=h.alternate,h!==null&&(h.lanes|=N)}function a2(h,g,_,N){return fv(h,g,_,N),mv(h)}function Nh(h,g){return fv(h,null,null,g),mv(h)}function XI(h,g,_){h.lanes|=_;var N=h.alternate;N!==null&&(N.lanes|=_);for(var P=!1,F=h.return;F!==null;)F.childLanes|=_,N=F.alternate,N!==null&&(N.childLanes|=_),F.tag===22&&(h=F.stateNode,h===null||h._visibility&1||(P=!0)),h=F,F=F.return;return h.tag===3?(F=h.stateNode,P&&g!==null&&(P=31-je(_),h=F.hiddenUpdates,N=h[P],N===null?h[P]=[g]:N.push(g),g.lane=_|536870912),F):null}function mv(h){if(50<qx)throw qx=0,mA=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var Mm={};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 ks(h,g,_,N){return new Lae(h,g,_,N)}function s2(h){return h=h.prototype,!(!h||!h.isReactComponent)}function pc(h,g){var _=h.alternate;return _===null?(_=ks(h.tag,g,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=g,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,g=h.dependencies,_.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function YI(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 pv(h,g,_,N,P,F){var Z=0;if(N=h,typeof h=="function")s2(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=ks(31,_,g,P),h.elementType=C,h.lanes=F,h;case y:return Eh(_.children,P,F,g);case x:Z=8,P|=24;break;case v:return h=ks(12,_,g,P|2),h.elementType=v,h.lanes=F,h;case T:return h=ks(13,_,g,P),h.elementType=T,h.lanes=F,h;case k:return h=ks(19,_,g,P),h.elementType=k,h.lanes=F,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case M:Z=10;break e;case S:Z=9;break e;case A:Z=11;break e;case E:Z=14;break e;case D:Z=16,N=null;break e}Z=29,_=Error(r(130,h===null?"null":typeof h,"")),N=null}return g=ks(Z,_,g,P),g.elementType=h,g.type=N,g.lanes=F,g}function Eh(h,g,_,N){return h=ks(7,h,N,g),h.lanes=_,h}function o2(h,g,_){return h=ks(6,h,null,g),h.lanes=_,h}function ZI(h){var g=ks(18,null,null,0);return g.stateNode=h,g}function l2(h,g,_){return g=ks(4,h.children!==null?h.children:[],h.key,g),g.lanes=_,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var QI=new WeakMap;function ro(h,g){if(typeof h=="object"&&h!==null){var _=QI.get(h);return _!==void 0?_:(g={value:h,source:g,stack:I(g)},QI.set(h,g),g)}return{value:h,source:g,stack:I(g)}}var Nm=[],Em=0,gv=null,Ex=0,io=[],ao=0,Pu=null,vl=1,_l="";function gc(h,g){Nm[Em++]=Ex,Nm[Em++]=gv,gv=h,Ex=g}function JI(h,g,_){io[ao++]=vl,io[ao++]=_l,io[ao++]=Pu,Pu=h;var N=vl;h=_l;var P=32-je(N)-1;N&=~(1<<P),_+=1;var F=32-je(g)+P;if(30<F){var Z=P-P%5;F=(N&(1<<Z)-1).toString(32),N>>=Z,P-=Z,vl=1<<32-je(g)+P|_<<P|N,_l=F+h}else vl=1<<F|_<<P|N,_l=h}function c2(h){h.return!==null&&(gc(h,1),JI(h,1,0))}function u2(h){for(;h===gv;)gv=Nm[--Em],Nm[Em]=null,Ex=Nm[--Em],Nm[Em]=null;for(;h===Pu;)Pu=io[--ao],io[ao]=null,_l=io[--ao],io[ao]=null,vl=io[--ao],io[ao]=null}function eF(h,g){io[ao++]=vl,io[ao++]=_l,io[ao++]=Pu,vl=g.id,_l=g.overflow,Pu=h}var ua=null,kr=null,In=!1,Ru=null,so=!1,d2=Error(r(519));function Du(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ax(ro(g,h)),d2}function tF(h){var g=h.stateNode,_=h.type,N=h.memoizedProps;switch(g[tn]=h,g[yr]=N,_){case"dialog":kn("cancel",g),kn("close",g);break;case"iframe":case"object":case"embed":kn("load",g);break;case"video":case"audio":for(_=0;_<Xx.length;_++)kn(Xx[_],g);break;case"source":kn("error",g);break;case"img":case"image":case"link":kn("error",g),kn("load",g);break;case"details":kn("toggle",g);break;case"input":kn("invalid",g),Zr(g,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":kn("invalid",g);break;case"textarea":kn("invalid",g),di(g,N.value,N.defaultValue,N.children)}_=N.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||g.textContent===""+_||N.suppressHydrationWarning===!0||bU(g.textContent,_)?(N.popover!=null&&(kn("beforetoggle",g),kn("toggle",g)),N.onScroll!=null&&kn("scroll",g),N.onScrollEnd!=null&&kn("scrollend",g),N.onClick!=null&&(g.onclick=fc),g=!0):g=!1,g||Du(h,!0)}function nF(h){for(ua=h.return;ua;)switch(ua.tag){case 5:case 31:case 13:so=!1;return;case 27:case 3:so=!0;return;default:ua=ua.return}}function Am(h){if(h!==ua)return!1;if(!In)return nF(h),In=!0,!1;var g=h.tag,_;if((_=g!==3&&g!==27)&&((_=g===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||CA(h.type,h.memoizedProps)),_=!_),_&&kr&&Du(h),nF(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));kr=AU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));kr=AU(h)}else g===27?(g=kr,Ku(h.type)?(h=DA,DA=null,kr=h):kr=g):kr=ua?lo(h.stateNode.nextSibling):null;return!0}function Ah(){kr=ua=null,In=!1}function h2(){var h=Ru;return h!==null&&(hs===null?hs=h:hs.push.apply(hs,h),Ru=null),h}function Ax(h){Ru===null?Ru=[h]:Ru.push(h)}var f2=z(null),Th=null,xc=null;function Ou(h,g,_){ne(f2,g._currentValue),g._currentValue=_}function bc(h){h._currentValue=f2.current,V(f2)}function m2(h,g,_){for(;h!==null;){var N=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,N!==null&&(N.childLanes|=g)):N!==null&&(N.childLanes&g)!==g&&(N.childLanes|=g),h===_)break;h=h.return}}function p2(h,g,_,N){var P=h.child;for(P!==null&&(P.return=h);P!==null;){var F=P.dependencies;if(F!==null){var Z=P.child;F=F.firstContext;e:for(;F!==null;){var ge=F;F=P;for(var Oe=0;Oe<g.length;Oe++)if(ge.context===g[Oe]){F.lanes|=_,ge=F.alternate,ge!==null&&(ge.lanes|=_),m2(F.return,_,h),N||(Z=null);break e}F=ge.next}}else if(P.tag===18){if(Z=P.return,Z===null)throw Error(r(341));Z.lanes|=_,F=Z.alternate,F!==null&&(F.lanes|=_),m2(Z,_,h),Z=null}else Z=P.child;if(Z!==null)Z.return=P;else for(Z=P;Z!==null;){if(Z===h){Z=null;break}if(P=Z.sibling,P!==null){P.return=Z.return,Z=P;break}Z=Z.return}P=Z}}function Tm(h,g,_,N){h=null;for(var P=g,F=!1;P!==null;){if(!F){if((P.flags&524288)!==0)F=!0;else if((P.flags&262144)!==0)break}if(P.tag===10){var Z=P.alternate;if(Z===null)throw Error(r(387));if(Z=Z.memoizedProps,Z!==null){var ge=P.type;Cs(P.pendingProps.value,Z.value)||(h!==null?h.push(ge):h=[ge])}}else if(P===ie.current){if(Z=P.alternate,Z===null)throw Error(r(387));Z.memoizedState.memoizedState!==P.memoizedState.memoizedState&&(h!==null?h.push(eb):h=[eb])}P=P.return}h!==null&&p2(g,h,_,N),g.flags|=262144}function xv(h){for(h=h.firstContext;h!==null;){if(!Cs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Ch(h){Th=h,xc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function da(h){return rF(Th,h)}function bv(h,g){return Th===null&&Ch(h),rF(h,g)}function rF(h,g){var _=g._currentValue;if(g={context:g,memoizedValue:_,next:null},xc===null){if(h===null)throw Error(r(308));xc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else xc=xc.next=g;return _}var 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,bi={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function g2(){return{controller:new Iae,data:new Map,refCount:0}}function Tx(h){h.refCount--,h.refCount===0&&Fae(Uae,function(){h.controller.abort()})}var Cx=null,x2=0,Cm=0,km=null;function zae(h,g){if(Cx===null){var _=Cx=[];x2=0,Cm=vA(),km={status:"pending",value:void 0,then:function(N){_.push(N)}}}return x2++,g.then(iF,iF),g}function iF(){if(--x2===0&&Cx!==null){km!==null&&(km.status="fulfilled");var h=Cx;Cx=null,Cm=0,km=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(P){_.push(P)}};return h.then(function(){N.status="fulfilled",N.value=g;for(var P=0;P<_.length;P++)(0,_[P])(g)},function(P){for(N.status="rejected",N.reason=P,P=0;P<_.length;P++)(0,_[P])(void 0)}),N}var aF=K.S;K.S=function(h,g){$5=L(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&zae(h,g),aF!==null&&aF(h,g)};var kh=z(null);function b2(){var h=kh.current;return h!==null?h:_r.pooledCache}function yv(h,g){g===null?ne(kh,kh.current):ne(kh,g.pool)}function sF(){var h=b2();return h===null?null:{parent:bi._currentValue,pool:h}}var jm=Error(r(460)),y2=Error(r(474)),vv=Error(r(542)),_v={then:function(){}};function oF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function lF(h,g,_){switch(_=h[_],_===void 0?h.push(g):_!==g&&(g.then(fc,fc),g=_),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,uF(h),h;default:if(typeof g.status=="string")g.then(fc,fc);else{if(h=_r,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(N){if(g.status==="pending"){var P=g;P.status="fulfilled",P.value=N}},function(N){if(g.status==="pending"){var P=g;P.status="rejected",P.reason=N}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,uF(h),h}throw Ph=g,jm}}function jh(h){try{var g=h._init;return g(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(Ph=_,jm):_}}var Ph=null;function cF(){if(Ph===null)throw Error(r(459));var h=Ph;return Ph=null,h}function uF(h){if(h===jm||h===vv)throw Error(r(483))}var Pm=null,kx=0;function wv(h){var g=kx;return kx+=1,Pm===null&&(Pm=[]),lF(Pm,h,g)}function jx(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function Sv(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 dF(h){function g(Qe,ze){if(h){var rt=Qe.deletions;rt===null?(Qe.deletions=[ze],Qe.flags|=16):rt.push(ze)}}function _(Qe,ze){if(!h)return null;for(;ze!==null;)g(Qe,ze),ze=ze.sibling;return null}function N(Qe){for(var ze=new Map;Qe!==null;)Qe.key!==null?ze.set(Qe.key,Qe):ze.set(Qe.index,Qe),Qe=Qe.sibling;return ze}function P(Qe,ze){return Qe=pc(Qe,ze),Qe.index=0,Qe.sibling=null,Qe}function F(Qe,ze,rt){return Qe.index=rt,h?(rt=Qe.alternate,rt!==null?(rt=rt.index,rt<ze?(Qe.flags|=67108866,ze):rt):(Qe.flags|=67108866,ze)):(Qe.flags|=1048576,ze)}function Z(Qe){return h&&Qe.alternate===null&&(Qe.flags|=67108866),Qe}function ge(Qe,ze,rt,yt){return ze===null||ze.tag!==6?(ze=o2(rt,Qe.mode,yt),ze.return=Qe,ze):(ze=P(ze,rt),ze.return=Qe,ze)}function Oe(Qe,ze,rt,yt){var en=rt.type;return en===y?xt(Qe,ze,rt.props.children,yt,rt.key):ze!==null&&(ze.elementType===en||typeof en=="object"&&en!==null&&en.$$typeof===D&&jh(en)===ze.type)?(ze=P(ze,rt.props),jx(ze,rt),ze.return=Qe,ze):(ze=pv(rt.type,rt.key,rt.props,null,Qe.mode,yt),jx(ze,rt),ze.return=Qe,ze)}function it(Qe,ze,rt,yt){return ze===null||ze.tag!==4||ze.stateNode.containerInfo!==rt.containerInfo||ze.stateNode.implementation!==rt.implementation?(ze=l2(rt,Qe.mode,yt),ze.return=Qe,ze):(ze=P(ze,rt.children||[]),ze.return=Qe,ze)}function xt(Qe,ze,rt,yt,en){return ze===null||ze.tag!==7?(ze=Eh(rt,Qe.mode,yt,en),ze.return=Qe,ze):(ze=P(ze,rt),ze.return=Qe,ze)}function vt(Qe,ze,rt){if(typeof ze=="string"&&ze!==""||typeof ze=="number"||typeof ze=="bigint")return ze=o2(""+ze,Qe.mode,rt),ze.return=Qe,ze;if(typeof ze=="object"&&ze!==null){switch(ze.$$typeof){case p:return rt=pv(ze.type,ze.key,ze.props,null,Qe.mode,rt),jx(rt,ze),rt.return=Qe,rt;case b:return ze=l2(ze,Qe.mode,rt),ze.return=Qe,ze;case D:return ze=jh(ze),vt(Qe,ze,rt)}if(W(ze)||O(ze))return ze=Eh(ze,Qe.mode,rt,null),ze.return=Qe,ze;if(typeof ze.then=="function")return vt(Qe,wv(ze),rt);if(ze.$$typeof===M)return vt(Qe,bv(Qe,ze),rt);Sv(Qe,ze)}return null}function ot(Qe,ze,rt,yt){var en=ze!==null?ze.key:null;if(typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint")return en!==null?null:ge(Qe,ze,""+rt,yt);if(typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case p:return rt.key===en?Oe(Qe,ze,rt,yt):null;case b:return rt.key===en?it(Qe,ze,rt,yt):null;case D:return rt=jh(rt),ot(Qe,ze,rt,yt)}if(W(rt)||O(rt))return en!==null?null:xt(Qe,ze,rt,yt,null);if(typeof rt.then=="function")return ot(Qe,ze,wv(rt),yt);if(rt.$$typeof===M)return ot(Qe,ze,bv(Qe,rt),yt);Sv(Qe,rt)}return null}function ht(Qe,ze,rt,yt,en){if(typeof yt=="string"&&yt!==""||typeof yt=="number"||typeof yt=="bigint")return Qe=Qe.get(rt)||null,ge(ze,Qe,""+yt,en);if(typeof yt=="object"&&yt!==null){switch(yt.$$typeof){case p:return Qe=Qe.get(yt.key===null?rt:yt.key)||null,Oe(ze,Qe,yt,en);case b:return Qe=Qe.get(yt.key===null?rt:yt.key)||null,it(ze,Qe,yt,en);case D:return yt=jh(yt),ht(Qe,ze,rt,yt,en)}if(W(yt)||O(yt))return Qe=Qe.get(rt)||null,xt(ze,Qe,yt,en,null);if(typeof yt.then=="function")return ht(Qe,ze,rt,wv(yt),en);if(yt.$$typeof===M)return ht(Qe,ze,rt,bv(ze,yt),en);Sv(ze,yt)}return null}function Xt(Qe,ze,rt,yt){for(var en=null,Wn=null,Qt=ze,yn=ze=0,Dn=null;Qt!==null&&yn<rt.length;yn++){Qt.index>yn?(Dn=Qt,Qt=null):Dn=Qt.sibling;var qn=ot(Qe,Qt,rt[yn],yt);if(qn===null){Qt===null&&(Qt=Dn);break}h&&Qt&&qn.alternate===null&&g(Qe,Qt),ze=F(qn,ze,yn),Wn===null?en=qn:Wn.sibling=qn,Wn=qn,Qt=Dn}if(yn===rt.length)return _(Qe,Qt),In&&gc(Qe,yn),en;if(Qt===null){for(;yn<rt.length;yn++)Qt=vt(Qe,rt[yn],yt),Qt!==null&&(ze=F(Qt,ze,yn),Wn===null?en=Qt:Wn.sibling=Qt,Wn=Qt);return In&&gc(Qe,yn),en}for(Qt=N(Qt);yn<rt.length;yn++)Dn=ht(Qt,Qe,yn,rt[yn],yt),Dn!==null&&(h&&Dn.alternate!==null&&Qt.delete(Dn.key===null?yn:Dn.key),ze=F(Dn,ze,yn),Wn===null?en=Dn:Wn.sibling=Dn,Wn=Dn);return h&&Qt.forEach(function(Ju){return g(Qe,Ju)}),In&&gc(Qe,yn),en}function sn(Qe,ze,rt,yt){if(rt==null)throw Error(r(151));for(var en=null,Wn=null,Qt=ze,yn=ze=0,Dn=null,qn=rt.next();Qt!==null&&!qn.done;yn++,qn=rt.next()){Qt.index>yn?(Dn=Qt,Qt=null):Dn=Qt.sibling;var Ju=ot(Qe,Qt,qn.value,yt);if(Ju===null){Qt===null&&(Qt=Dn);break}h&&Qt&&Ju.alternate===null&&g(Qe,Qt),ze=F(Ju,ze,yn),Wn===null?en=Ju:Wn.sibling=Ju,Wn=Ju,Qt=Dn}if(qn.done)return _(Qe,Qt),In&&gc(Qe,yn),en;if(Qt===null){for(;!qn.done;yn++,qn=rt.next())qn=vt(Qe,qn.value,yt),qn!==null&&(ze=F(qn,ze,yn),Wn===null?en=qn:Wn.sibling=qn,Wn=qn);return In&&gc(Qe,yn),en}for(Qt=N(Qt);!qn.done;yn++,qn=rt.next())qn=ht(Qt,Qe,yn,qn.value,yt),qn!==null&&(h&&qn.alternate!==null&&Qt.delete(qn.key===null?yn:qn.key),ze=F(qn,ze,yn),Wn===null?en=qn:Wn.sibling=qn,Wn=qn);return h&&Qt.forEach(function(Qse){return g(Qe,Qse)}),In&&gc(Qe,yn),en}function dr(Qe,ze,rt,yt){if(typeof rt=="object"&&rt!==null&&rt.type===y&&rt.key===null&&(rt=rt.props.children),typeof rt=="object"&&rt!==null){switch(rt.$$typeof){case p:e:{for(var en=rt.key;ze!==null;){if(ze.key===en){if(en=rt.type,en===y){if(ze.tag===7){_(Qe,ze.sibling),yt=P(ze,rt.props.children),yt.return=Qe,Qe=yt;break e}}else if(ze.elementType===en||typeof en=="object"&&en!==null&&en.$$typeof===D&&jh(en)===ze.type){_(Qe,ze.sibling),yt=P(ze,rt.props),jx(yt,rt),yt.return=Qe,Qe=yt;break e}_(Qe,ze);break}else g(Qe,ze);ze=ze.sibling}rt.type===y?(yt=Eh(rt.props.children,Qe.mode,yt,rt.key),yt.return=Qe,Qe=yt):(yt=pv(rt.type,rt.key,rt.props,null,Qe.mode,yt),jx(yt,rt),yt.return=Qe,Qe=yt)}return Z(Qe);case b:e:{for(en=rt.key;ze!==null;){if(ze.key===en)if(ze.tag===4&&ze.stateNode.containerInfo===rt.containerInfo&&ze.stateNode.implementation===rt.implementation){_(Qe,ze.sibling),yt=P(ze,rt.children||[]),yt.return=Qe,Qe=yt;break e}else{_(Qe,ze);break}else g(Qe,ze);ze=ze.sibling}yt=l2(rt,Qe.mode,yt),yt.return=Qe,Qe=yt}return Z(Qe);case D:return rt=jh(rt),dr(Qe,ze,rt,yt)}if(W(rt))return Xt(Qe,ze,rt,yt);if(O(rt)){if(en=O(rt),typeof en!="function")throw Error(r(150));return rt=en.call(rt),sn(Qe,ze,rt,yt)}if(typeof rt.then=="function")return dr(Qe,ze,wv(rt),yt);if(rt.$$typeof===M)return dr(Qe,ze,bv(Qe,rt),yt);Sv(Qe,rt)}return typeof rt=="string"&&rt!==""||typeof rt=="number"||typeof rt=="bigint"?(rt=""+rt,ze!==null&&ze.tag===6?(_(Qe,ze.sibling),yt=P(ze,rt),yt.return=Qe,Qe=yt):(_(Qe,ze),yt=o2(rt,Qe.mode,yt),yt.return=Qe,Qe=yt),Z(Qe)):_(Qe,ze)}return function(Qe,ze,rt,yt){try{kx=0;var en=dr(Qe,ze,rt,yt);return Pm=null,en}catch(Qt){if(Qt===jm||Qt===vv)throw Qt;var Wn=ks(29,Qt,null,Qe.mode);return Wn.lanes=yt,Wn.return=Qe,Wn}}}var Rh=dF(!0),hF=dF(!1),Lu=!1;function v2(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function _2(h,g){h=h.updateQueue,g.updateQueue===h&&(g.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function Iu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function Fu(h,g,_){var N=h.updateQueue;if(N===null)return null;if(N=N.shared,(Qn&2)!==0){var P=N.pending;return P===null?g.next=g:(g.next=P.next,P.next=g),N.pending=g,g=mv(h),XI(h,null,_),g}return fv(h,N,g,_),mv(h)}function Px(h,g,_){if(g=g.updateQueue,g!==null&&(g=g.shared,(_&4194048)!==0)){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,gt(h,_)}}function w2(h,g){var _=h.updateQueue,N=h.alternate;if(N!==null&&(N=N.updateQueue,_===N)){var P=null,F=null;if(_=_.firstBaseUpdate,_!==null){do{var Z={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};F===null?P=F=Z:F=F.next=Z,_=_.next}while(_!==null);F===null?P=F=g:F=F.next=g}else P=F=g;_={baseState:N.baseState,firstBaseUpdate:P,lastBaseUpdate:F,shared:N.shared,callbacks:N.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=g:h.next=g,_.lastBaseUpdate=g}var S2=!1;function Rx(){if(S2){var h=km;if(h!==null)throw h}}function Dx(h,g,_,N){S2=!1;var P=h.updateQueue;Lu=!1;var F=P.firstBaseUpdate,Z=P.lastBaseUpdate,ge=P.shared.pending;if(ge!==null){P.shared.pending=null;var Oe=ge,it=Oe.next;Oe.next=null,Z===null?F=it:Z.next=it,Z=Oe;var xt=h.alternate;xt!==null&&(xt=xt.updateQueue,ge=xt.lastBaseUpdate,ge!==Z&&(ge===null?xt.firstBaseUpdate=it:ge.next=it,xt.lastBaseUpdate=Oe))}if(F!==null){var vt=P.baseState;Z=0,xt=it=Oe=null,ge=F;do{var ot=ge.lane&-536870913,ht=ot!==ge.lane;if(ht?(Rn&ot)===ot:(N&ot)===ot){ot!==0&&ot===Cm&&(S2=!0),xt!==null&&(xt=xt.next={lane:0,tag:ge.tag,payload:ge.payload,callback:null,next:null});e:{var Xt=h,sn=ge;ot=g;var dr=_;switch(sn.tag){case 1:if(Xt=sn.payload,typeof Xt=="function"){vt=Xt.call(dr,vt,ot);break e}vt=Xt;break e;case 3:Xt.flags=Xt.flags&-65537|128;case 0:if(Xt=sn.payload,ot=typeof Xt=="function"?Xt.call(dr,vt,ot):Xt,ot==null)break e;vt=f({},vt,ot);break e;case 2:Lu=!0}}ot=ge.callback,ot!==null&&(h.flags|=64,ht&&(h.flags|=8192),ht=P.callbacks,ht===null?P.callbacks=[ot]:ht.push(ot))}else ht={lane:ot,tag:ge.tag,payload:ge.payload,callback:ge.callback,next:null},xt===null?(it=xt=ht,Oe=vt):xt=xt.next=ht,Z|=ot;if(ge=ge.next,ge===null){if(ge=P.shared.pending,ge===null)break;ht=ge,ge=ht.next,ht.next=null,P.lastBaseUpdate=ht,P.shared.pending=null}}while(!0);xt===null&&(Oe=vt),P.baseState=Oe,P.firstBaseUpdate=it,P.lastBaseUpdate=xt,F===null&&(P.shared.lanes=0),Hu|=Z,h.lanes=Z,h.memoizedState=vt}}function fF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function mF(h,g){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)fF(_[h],g)}var Rm=z(null),Mv=z(0);function pF(h,g){h=Ac,ne(Mv,h),ne(Rm,g),Ac=h|g.baseLanes}function M2(){ne(Mv,Ac),ne(Rm,Rm.current)}function N2(){Ac=Mv.current,V(Rm),V(Mv)}var js=z(null),oo=null;function Uu(h){var g=h.alternate;ne(hi,hi.current&1),ne(js,h),oo===null&&(g===null||Rm.current!==null||g.memoizedState!==null)&&(oo=h)}function E2(h){ne(hi,hi.current),ne(js,h),oo===null&&(oo=h)}function gF(h){h.tag===22?(ne(hi,hi.current),ne(js,h),oo===null&&(oo=h)):zu()}function zu(){ne(hi,hi.current),ne(js,js.current)}function Ps(h){V(js),oo===h&&(oo=null),V(hi)}var hi=z(0);function Nv(h){for(var g=h;g!==null;){if(g.tag===13){var _=g.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||PA(_)||RA(_)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var yc=0,bn=null,cr=null,yi=null,Ev=!1,Dm=!1,Dh=!1,Av=0,Ox=0,Om=null,$ae=0;function Qr(){throw Error(r(321))}function A2(h,g){if(g===null)return!1;for(var _=0;_<g.length&&_<h.length;_++)if(!Cs(h[_],g[_]))return!1;return!0}function T2(h,g,_,N,P,F){return yc=F,bn=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,K.H=h===null||h.memoizedState===null?JF:H2,Dh=!1,F=_(N,P),Dh=!1,Dm&&(F=bF(g,_,N,P)),xF(h),F}function xF(h){K.H=Fx;var g=cr!==null&&cr.next!==null;if(yc=0,yi=cr=bn=null,Ev=!1,Ox=0,Om=null,g)throw Error(r(300));h===null||vi||(h=h.dependencies,h!==null&&xv(h)&&(vi=!0))}function bF(h,g,_,N){bn=h;var P=0;do{if(Dm&&(Om=null),Ox=0,Dm=!1,25<=P)throw Error(r(301));if(P+=1,yi=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=e5,F=g(_,N)}while(Dm);return F}function Hae(){var h=K.H,g=h.useState()[0];return g=typeof g.then=="function"?Lx(g):g,h=h.useState()[0],(cr!==null?cr.memoizedState:null)!==h&&(bn.flags|=1024),g}function C2(){var h=Av!==0;return Av=0,h}function k2(h,g,_){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~_}function j2(h){if(Ev){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}Ev=!1}yc=0,yi=cr=bn=null,Dm=!1,Ox=Av=0,Om=null}function Ga(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yi===null?bn.memoizedState=yi=h:yi=yi.next=h,yi}function fi(){if(cr===null){var h=bn.alternate;h=h!==null?h.memoizedState:null}else h=cr.next;var g=yi===null?bn.memoizedState:yi.next;if(g!==null)yi=g,cr=h;else{if(h===null)throw bn.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},yi===null?bn.memoizedState=yi=h:yi=yi.next=h}return yi}function Tv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Lx(h){var g=Ox;return Ox+=1,Om===null&&(Om=[]),h=lF(Om,h,g),g=bn,(yi===null?g.memoizedState:yi.next)===null&&(g=g.alternate,K.H=g===null||g.memoizedState===null?JF:H2),h}function Cv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return Lx(h);if(h.$$typeof===M)return da(h)}throw Error(r(438,String(h)))}function P2(h){var g=null,_=bn.updateQueue;if(_!==null&&(g=_.memoCache),g==null){var N=bn.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(g={data:N.data.map(function(P){return P.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),_===null&&(_=Tv(),bn.updateQueue=_),_.memoCache=g,_=g.data[g.index],_===void 0)for(_=g.data[g.index]=Array(h),N=0;N<h;N++)_[N]=R;return g.index++,_}function vc(h,g){return typeof g=="function"?g(h):g}function kv(h){var g=fi();return R2(g,cr,h)}function R2(h,g,_){var N=h.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=_;var P=h.baseQueue,F=N.pending;if(F!==null){if(P!==null){var Z=P.next;P.next=F.next,F.next=Z}g.baseQueue=P=F,N.pending=null}if(F=h.baseState,P===null)h.memoizedState=F;else{g=P.next;var ge=Z=null,Oe=null,it=g,xt=!1;do{var vt=it.lane&-536870913;if(vt!==it.lane?(Rn&vt)===vt:(yc&vt)===vt){var ot=it.revertLane;if(ot===0)Oe!==null&&(Oe=Oe.next={lane:0,revertLane:0,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null}),vt===Cm&&(xt=!0);else if((yc&ot)===ot){it=it.next,ot===Cm&&(xt=!0);continue}else vt={lane:0,revertLane:it.revertLane,gesture:null,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Oe===null?(ge=Oe=vt,Z=F):Oe=Oe.next=vt,bn.lanes|=ot,Hu|=ot;vt=it.action,Dh&&_(F,vt),F=it.hasEagerState?it.eagerState:_(F,vt)}else ot={lane:vt,revertLane:it.revertLane,gesture:it.gesture,action:it.action,hasEagerState:it.hasEagerState,eagerState:it.eagerState,next:null},Oe===null?(ge=Oe=ot,Z=F):Oe=Oe.next=ot,bn.lanes|=vt,Hu|=vt;it=it.next}while(it!==null&&it!==g);if(Oe===null?Z=F:Oe.next=ge,!Cs(F,h.memoizedState)&&(vi=!0,xt&&(_=km,_!==null)))throw _;h.memoizedState=F,h.baseState=Z,h.baseQueue=Oe,N.lastRenderedState=F}return P===null&&(N.lanes=0),[h.memoizedState,N.dispatch]}function D2(h){var g=fi(),_=g.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var N=_.dispatch,P=_.pending,F=g.memoizedState;if(P!==null){_.pending=null;var Z=P=P.next;do F=h(F,Z.action),Z=Z.next;while(Z!==P);Cs(F,g.memoizedState)||(vi=!0),g.memoizedState=F,g.baseQueue===null&&(g.baseState=F),_.lastRenderedState=F}return[F,N]}function yF(h,g,_){var N=bn,P=fi(),F=In;if(F){if(_===void 0)throw Error(r(407));_=_()}else _=g();var Z=!Cs((cr||P).memoizedState,_);if(Z&&(P.memoizedState=_,vi=!0),P=P.queue,I2(wF.bind(null,N,P,h),[h]),P.getSnapshot!==g||Z||yi!==null&&yi.memoizedState.tag&1){if(N.flags|=2048,Lm(9,{destroy:void 0},_F.bind(null,N,P,_,g),null),_r===null)throw Error(r(349));F||(yc&127)!==0||vF(N,g,_)}return _}function vF(h,g,_){h.flags|=16384,h={getSnapshot:g,value:_},g=bn.updateQueue,g===null?(g=Tv(),bn.updateQueue=g,g.stores=[h]):(_=g.stores,_===null?g.stores=[h]:_.push(h))}function _F(h,g,_,N){g.value=_,g.getSnapshot=N,SF(g)&&MF(h)}function wF(h,g,_){return _(function(){SF(g)&&MF(h)})}function SF(h){var g=h.getSnapshot;h=h.value;try{var _=g();return!Cs(h,_)}catch{return!0}}function MF(h){var g=Nh(h,2);g!==null&&fs(g,h,2)}function O2(h){var g=Ga();if(typeof h=="function"){var _=h;if(h=_(),Dh){ye(!0);try{_()}finally{ye(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vc,lastRenderedState:h},g}function NF(h,g,_,N){return h.baseState=_,R2(h,cr,typeof N=="function"?N:vc)}function Vae(h,g,_,N,P){if(Rv(h))throw Error(r(485));if(h=g.action,h!==null){var F={payload:P,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Z){F.listeners.push(Z)}};K.T!==null?_(!0):F.isTransition=!1,N(F),_=g.pending,_===null?(F.next=g.pending=F,EF(g,F)):(F.next=_.next,g.pending=_.next=F)}}function EF(h,g){var _=g.action,N=g.payload,P=h.state;if(g.isTransition){var F=K.T,Z={};K.T=Z;try{var ge=_(P,N),Oe=K.S;Oe!==null&&Oe(Z,ge),AF(h,g,ge)}catch(it){L2(h,g,it)}finally{F!==null&&Z.types!==null&&(F.types=Z.types),K.T=F}}else try{F=_(P,N),AF(h,g,F)}catch(it){L2(h,g,it)}}function AF(h,g,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(N){TF(h,g,N)},function(N){return L2(h,g,N)}):TF(h,g,_)}function TF(h,g,_){g.status="fulfilled",g.value=_,CF(g),h.state=_,g=h.pending,g!==null&&(_=g.next,_===g?h.pending=null:(_=_.next,g.next=_,EF(h,_)))}function L2(h,g,_){var N=h.pending;if(h.pending=null,N!==null){N=N.next;do g.status="rejected",g.reason=_,CF(g),g=g.next;while(g!==N)}h.action=null}function CF(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function kF(h,g){return g}function jF(h,g){if(In){var _=_r.formState;if(_!==null){e:{var N=bn;if(In){if(kr){t:{for(var P=kr,F=so;P.nodeType!==8;){if(!F){P=null;break t}if(P=lo(P.nextSibling),P===null){P=null;break t}}F=P.data,P=F==="F!"||F==="F"?P:null}if(P){kr=lo(P.nextSibling),N=P.data==="F!";break e}}Du(N)}N=!1}N&&(g=_[0])}}return _=Ga(),_.memoizedState=_.baseState=g,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:kF,lastRenderedState:g},_.queue=N,_=YF.bind(null,bn,N),N.dispatch=_,N=O2(!1),F=$2.bind(null,bn,!1,N.queue),N=Ga(),P={state:g,dispatch:null,action:h,pending:null},N.queue=P,_=Vae.bind(null,bn,P,F,_),P.dispatch=_,N.memoizedState=h,[g,_,!1]}function PF(h){var g=fi();return RF(g,cr,h)}function RF(h,g,_){if(g=R2(h,g,kF)[0],h=kv(vc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var N=Lx(g)}catch(Z){throw Z===jm?vv:Z}else N=g;g=fi();var P=g.queue,F=P.dispatch;return _!==g.memoizedState&&(bn.flags|=2048,Lm(9,{destroy:void 0},Gae.bind(null,P,_),null)),[N,F,h]}function Gae(h,g){h.action=g}function DF(h){var g=fi(),_=cr;if(_!==null)return RF(g,_,h);fi(),g=g.memoizedState,_=fi();var N=_.queue.dispatch;return _.memoizedState=h,[g,N,!1]}function Lm(h,g,_,N){return h={tag:h,create:_,deps:N,inst:g,next:null},g=bn.updateQueue,g===null&&(g=Tv(),bn.updateQueue=g),_=g.lastEffect,_===null?g.lastEffect=h.next=h:(N=_.next,_.next=h,h.next=N,g.lastEffect=h),h}function OF(){return fi().memoizedState}function jv(h,g,_,N){var P=Ga();bn.flags|=h,P.memoizedState=Lm(1|g,{destroy:void 0},_,N===void 0?null:N)}function Pv(h,g,_,N){var P=fi();N=N===void 0?null:N;var F=P.memoizedState.inst;cr!==null&&N!==null&&A2(N,cr.memoizedState.deps)?P.memoizedState=Lm(g,F,_,N):(bn.flags|=h,P.memoizedState=Lm(1|g,F,_,N))}function LF(h,g){jv(8390656,8,h,g)}function I2(h,g){Pv(2048,8,h,g)}function Wae(h){bn.flags|=4;var g=bn.updateQueue;if(g===null)g=Tv(),bn.updateQueue=g,g.events=[h];else{var _=g.events;_===null?g.events=[h]:_.push(h)}}function IF(h){var g=fi().memoizedState;return Wae({ref:g,nextImpl:h}),function(){if((Qn&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function FF(h,g){return Pv(4,2,h,g)}function UF(h,g){return Pv(4,4,h,g)}function zF(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 BF(h,g,_){_=_!=null?_.concat([h]):null,Pv(4,4,zF.bind(null,g,h),_)}function F2(){}function $F(h,g){var _=fi();g=g===void 0?null:g;var N=_.memoizedState;return g!==null&&A2(g,N[1])?N[0]:(_.memoizedState=[h,g],h)}function HF(h,g){var _=fi();g=g===void 0?null:g;var N=_.memoizedState;if(g!==null&&A2(g,N[1]))return N[0];if(N=h(),Dh){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[N,g],N}function U2(h,g,_){return _===void 0||(yc&1073741824)!==0&&(Rn&261930)===0?h.memoizedState=g:(h.memoizedState=_,h=V5(),bn.lanes|=h,Hu|=h,_)}function VF(h,g,_,N){return Cs(_,g)?_:Rm.current!==null?(h=U2(h,_,N),Cs(h,g)||(vi=!0),h):(yc&42)===0||(yc&1073741824)!==0&&(Rn&261930)===0?(vi=!0,h.memoizedState=_):(h=V5(),bn.lanes|=h,Hu|=h,g)}function GF(h,g,_,N,P){var F=G.p;G.p=F!==0&&8>F?F:8;var Z=K.T,ge={};K.T=ge,$2(h,!1,g,_);try{var Oe=P(),it=K.S;if(it!==null&&it(ge,Oe),Oe!==null&&typeof Oe=="object"&&typeof Oe.then=="function"){var xt=Bae(Oe,N);Ix(h,g,xt,Os(h))}else Ix(h,g,N,Os(h))}catch(vt){Ix(h,g,{then:function(){},status:"rejected",reason:vt},Os())}finally{G.p=F,Z!==null&&ge.types!==null&&(Z.types=ge.types),K.T=Z}}function qae(){}function z2(h,g,_,N){if(h.tag!==5)throw Error(r(476));var P=WF(h).queue;GF(h,P,g,Q,_===null?qae:function(){return qF(h),_(N)})}function WF(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:vc,lastRenderedState:Q},next:null};var _={};return g.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vc,lastRenderedState:_},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function qF(h){var g=WF(h);g.next===null&&(g=h.alternate.memoizedState),Ix(h,g.next.queue,{},Os())}function B2(){return da(eb)}function KF(){return fi().memoizedState}function XF(){return fi().memoizedState}function Kae(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var _=Os();h=Iu(_);var N=Fu(g,h,_);N!==null&&(fs(N,g,_),Px(N,g,_)),g={cache:g2()},h.payload=g;return}g=g.return}}function Xae(h,g,_){var N=Os();_={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Rv(h)?ZF(g,_):(_=a2(h,g,_,N),_!==null&&(fs(_,h,N),QF(_,g,N)))}function YF(h,g,_){var N=Os();Ix(h,g,_,N)}function Ix(h,g,_,N){var P={lane:N,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Rv(h))ZF(g,P);else{var F=h.alternate;if(h.lanes===0&&(F===null||F.lanes===0)&&(F=g.lastRenderedReducer,F!==null))try{var Z=g.lastRenderedState,ge=F(Z,_);if(P.hasEagerState=!0,P.eagerState=ge,Cs(ge,Z))return fv(h,g,P,0),_r===null&&hv(),!1}catch{}if(_=a2(h,g,P,N),_!==null)return fs(_,h,N),QF(_,g,N),!0}return!1}function $2(h,g,_,N){if(N={lane:2,revertLane:vA(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},Rv(h)){if(g)throw Error(r(479))}else g=a2(h,_,N,2),g!==null&&fs(g,h,2)}function Rv(h){var g=h.alternate;return h===bn||g!==null&&g===bn}function ZF(h,g){Dm=Ev=!0;var _=h.pending;_===null?g.next=g:(g.next=_.next,_.next=g),h.pending=g}function QF(h,g,_){if((_&4194048)!==0){var N=g.lanes;N&=h.pendingLanes,_|=N,g.lanes=_,gt(h,_)}}var Fx={readContext:da,use:Cv,useCallback:Qr,useContext:Qr,useEffect:Qr,useImperativeHandle:Qr,useLayoutEffect:Qr,useInsertionEffect:Qr,useMemo:Qr,useReducer:Qr,useRef:Qr,useState:Qr,useDebugValue:Qr,useDeferredValue:Qr,useTransition:Qr,useSyncExternalStore:Qr,useId:Qr,useHostTransitionStatus:Qr,useFormState:Qr,useActionState:Qr,useOptimistic:Qr,useMemoCache:Qr,useCacheRefresh:Qr};Fx.useEffectEvent=Qr;var JF={readContext:da,use:Cv,useCallback:function(h,g){return Ga().memoizedState=[h,g===void 0?null:g],h},useContext:da,useEffect:LF,useImperativeHandle:function(h,g,_){_=_!=null?_.concat([h]):null,jv(4194308,4,zF.bind(null,g,h),_)},useLayoutEffect:function(h,g){return jv(4194308,4,h,g)},useInsertionEffect:function(h,g){jv(4,2,h,g)},useMemo:function(h,g){var _=Ga();g=g===void 0?null:g;var N=h();if(Dh){ye(!0);try{h()}finally{ye(!1)}}return _.memoizedState=[N,g],N},useReducer:function(h,g,_){var N=Ga();if(_!==void 0){var P=_(g);if(Dh){ye(!0);try{_(g)}finally{ye(!1)}}}else P=g;return N.memoizedState=N.baseState=P,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:P},N.queue=h,h=h.dispatch=Xae.bind(null,bn,h),[N.memoizedState,h]},useRef:function(h){var g=Ga();return h={current:h},g.memoizedState=h},useState:function(h){h=O2(h);var g=h.queue,_=YF.bind(null,bn,g);return g.dispatch=_,[h.memoizedState,_]},useDebugValue:F2,useDeferredValue:function(h,g){var _=Ga();return U2(_,h,g)},useTransition:function(){var h=O2(!1);return h=GF.bind(null,bn,h.queue,!0,!1),Ga().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,_){var N=bn,P=Ga();if(In){if(_===void 0)throw Error(r(407));_=_()}else{if(_=g(),_r===null)throw Error(r(349));(Rn&127)!==0||vF(N,g,_)}P.memoizedState=_;var F={value:_,getSnapshot:g};return P.queue=F,LF(wF.bind(null,N,F,h),[h]),N.flags|=2048,Lm(9,{destroy:void 0},_F.bind(null,N,F,_,g),null),_},useId:function(){var h=Ga(),g=_r.identifierPrefix;if(In){var _=_l,N=vl;_=(N&~(1<<32-je(N)-1)).toString(32)+_,g="_"+g+"R_"+_,_=Av++,0<_&&(g+="H"+_.toString(32)),g+="_"}else _=$ae++,g="_"+g+"r_"+_.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:B2,useFormState:jF,useActionState:jF,useOptimistic:function(h){var g=Ga();g.memoizedState=g.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=_,g=$2.bind(null,bn,!0,_),_.dispatch=g,[h,g]},useMemoCache:P2,useCacheRefresh:function(){return Ga().memoizedState=Kae.bind(null,bn)},useEffectEvent:function(h){var g=Ga(),_={impl:h};return g.memoizedState=_,function(){if((Qn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},H2={readContext:da,use:Cv,useCallback:$F,useContext:da,useEffect:I2,useImperativeHandle:BF,useInsertionEffect:FF,useLayoutEffect:UF,useMemo:HF,useReducer:kv,useRef:OF,useState:function(){return kv(vc)},useDebugValue:F2,useDeferredValue:function(h,g){var _=fi();return VF(_,cr.memoizedState,h,g)},useTransition:function(){var h=kv(vc)[0],g=fi().memoizedState;return[typeof h=="boolean"?h:Lx(h),g]},useSyncExternalStore:yF,useId:KF,useHostTransitionStatus:B2,useFormState:PF,useActionState:PF,useOptimistic:function(h,g){var _=fi();return NF(_,cr,h,g)},useMemoCache:P2,useCacheRefresh:XF};H2.useEffectEvent=IF;var e5={readContext:da,use:Cv,useCallback:$F,useContext:da,useEffect:I2,useImperativeHandle:BF,useInsertionEffect:FF,useLayoutEffect:UF,useMemo:HF,useReducer:D2,useRef:OF,useState:function(){return D2(vc)},useDebugValue:F2,useDeferredValue:function(h,g){var _=fi();return cr===null?U2(_,h,g):VF(_,cr.memoizedState,h,g)},useTransition:function(){var h=D2(vc)[0],g=fi().memoizedState;return[typeof h=="boolean"?h:Lx(h),g]},useSyncExternalStore:yF,useId:KF,useHostTransitionStatus:B2,useFormState:DF,useActionState:DF,useOptimistic:function(h,g){var _=fi();return cr!==null?NF(_,cr,h,g):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:P2,useCacheRefresh:XF};e5.useEffectEvent=IF;function V2(h,g,_,N){g=h.memoizedState,_=_(N,g),_=_==null?g:f({},g,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var G2={enqueueSetState:function(h,g,_){h=h._reactInternals;var N=Os(),P=Iu(N);P.payload=g,_!=null&&(P.callback=_),g=Fu(h,P,N),g!==null&&(fs(g,h,N),Px(g,h,N))},enqueueReplaceState:function(h,g,_){h=h._reactInternals;var N=Os(),P=Iu(N);P.tag=1,P.payload=g,_!=null&&(P.callback=_),g=Fu(h,P,N),g!==null&&(fs(g,h,N),Px(g,h,N))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var _=Os(),N=Iu(_);N.tag=2,g!=null&&(N.callback=g),g=Fu(h,N,_),g!==null&&(fs(g,h,_),Px(g,h,_))}};function t5(h,g,_,N,P,F,Z){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(N,F,Z):g.prototype&&g.prototype.isPureReactComponent?!Mx(_,N)||!Mx(P,F):!0}function n5(h,g,_,N){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(_,N),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(_,N),g.state!==h&&G2.enqueueReplaceState(g,g.state,null)}function Oh(h,g){var _=g;if("ref"in g){_={};for(var N in g)N!=="ref"&&(_[N]=g[N])}if(h=h.defaultProps){_===g&&(_=f({},_));for(var P in h)_[P]===void 0&&(_[P]=h[P])}return _}function r5(h){dv(h)}function i5(h){console.error(h)}function a5(h){dv(h)}function Dv(h,g){try{var _=h.onUncaughtError;_(g.value,{componentStack:g.stack})}catch(N){setTimeout(function(){throw N})}}function s5(h,g,_){try{var N=h.onCaughtError;N(_.value,{componentStack:_.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(P){setTimeout(function(){throw P})}}function W2(h,g,_){return _=Iu(_),_.tag=3,_.payload={element:null},_.callback=function(){Dv(h,g)},_}function o5(h){return h=Iu(h),h.tag=3,h}function l5(h,g,_,N){var P=_.type.getDerivedStateFromError;if(typeof P=="function"){var F=N.value;h.payload=function(){return P(F)},h.callback=function(){s5(g,_,N)}}var Z=_.stateNode;Z!==null&&typeof Z.componentDidCatch=="function"&&(h.callback=function(){s5(g,_,N),typeof P!="function"&&(Vu===null?Vu=new Set([this]):Vu.add(this));var ge=N.stack;this.componentDidCatch(N.value,{componentStack:ge!==null?ge:""})})}function Yae(h,g,_,N,P){if(_.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(g=_.alternate,g!==null&&Tm(g,_,P,!0),_=js.current,_!==null){switch(_.tag){case 31:case 13:return oo===null?Wv():_.alternate===null&&Jr===0&&(Jr=3),_.flags&=-257,_.flags|=65536,_.lanes=P,N===_v?_.flags|=16384:(g=_.updateQueue,g===null?_.updateQueue=new Set([N]):g.add(N),xA(h,N,P)),!1;case 22:return _.flags|=65536,N===_v?_.flags|=16384:(g=_.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([N])},_.updateQueue=g):(_=g.retryQueue,_===null?g.retryQueue=new Set([N]):_.add(N)),xA(h,N,P)),!1}throw Error(r(435,_.tag))}return xA(h,N,P),Wv(),!1}if(In)return g=js.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=P,N!==d2&&(h=Error(r(422),{cause:N}),Ax(ro(h,_)))):(N!==d2&&(g=Error(r(423),{cause:N}),Ax(ro(g,_))),h=h.current.alternate,h.flags|=65536,P&=-P,h.lanes|=P,N=ro(N,_),P=W2(h.stateNode,N,P),w2(h,P),Jr!==4&&(Jr=2)),!1;var F=Error(r(520),{cause:N});if(F=ro(F,_),Wx===null?Wx=[F]:Wx.push(F),Jr!==4&&(Jr=2),g===null)return!0;N=ro(N,_),_=g;do{switch(_.tag){case 3:return _.flags|=65536,h=P&-P,_.lanes|=h,h=W2(_.stateNode,N,h),w2(_,h),!1;case 1:if(g=_.type,F=_.stateNode,(_.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&(Vu===null||!Vu.has(F))))return _.flags|=65536,P&=-P,_.lanes|=P,P=o5(P),l5(P,h,_,N),w2(_,P),!1}_=_.return}while(_!==null);return!1}var q2=Error(r(461)),vi=!1;function ha(h,g,_,N){g.child=h===null?hF(g,null,_,N):Rh(g,h.child,_,N)}function c5(h,g,_,N,P){_=_.render;var F=g.ref;if("ref"in N){var Z={};for(var ge in N)ge!=="ref"&&(Z[ge]=N[ge])}else Z=N;return Ch(g),N=T2(h,g,_,Z,F,P),ge=C2(),h!==null&&!vi?(k2(h,g,P),_c(h,g,P)):(In&&ge&&c2(g),g.flags|=1,ha(h,g,N,P),g.child)}function u5(h,g,_,N,P){if(h===null){var F=_.type;return typeof F=="function"&&!s2(F)&&F.defaultProps===void 0&&_.compare===null?(g.tag=15,g.type=F,d5(h,g,F,N,P)):(h=pv(_.type,null,N,g,g.mode,P),h.ref=g.ref,h.return=g,g.child=h)}if(F=h.child,!tA(h,P)){var Z=F.memoizedProps;if(_=_.compare,_=_!==null?_:Mx,_(Z,N)&&h.ref===g.ref)return _c(h,g,P)}return g.flags|=1,h=pc(F,N),h.ref=g.ref,h.return=g,g.child=h}function d5(h,g,_,N,P){if(h!==null){var F=h.memoizedProps;if(Mx(F,N)&&h.ref===g.ref)if(vi=!1,g.pendingProps=N=F,tA(h,P))(h.flags&131072)!==0&&(vi=!0);else return g.lanes=h.lanes,_c(h,g,P)}return K2(h,g,_,N,P)}function h5(h,g,_,N){var P=N.children,F=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),N.mode==="hidden"){if((g.flags&128)!==0){if(F=F!==null?F.baseLanes|_:_,h!==null){for(N=g.child=h.child,P=0;N!==null;)P=P|N.lanes|N.childLanes,N=N.sibling;N=P&~F}else N=0,g.child=null;return f5(h,g,F,_,N)}if((_&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&yv(g,F!==null?F.cachePool:null),F!==null?pF(g,F):M2(),gF(g);else return N=g.lanes=536870912,f5(h,g,F!==null?F.baseLanes|_:_,_,N)}else F!==null?(yv(g,F.cachePool),pF(g,F),zu(),g.memoizedState=null):(h!==null&&yv(g,null),M2(),zu());return ha(h,g,P,_),g.child}function Ux(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function f5(h,g,_,N,P){var F=b2();return F=F===null?null:{parent:bi._currentValue,pool:F},g.memoizedState={baseLanes:_,cachePool:F},h!==null&&yv(g,null),M2(),gF(g),h!==null&&Tm(h,g,N,!0),g.childLanes=P,null}function Ov(h,g){return g=Iv({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function m5(h,g,_){return Rh(g,h.child,null,_),h=Ov(g,g.pendingProps),h.flags|=2,Ps(g),g.memoizedState=null,h}function Zae(h,g,_){var N=g.pendingProps,P=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(In){if(N.mode==="hidden")return h=Ov(g,N),g.lanes=536870912,Ux(null,h);if(E2(g),(h=kr)?(h=EU(h,so),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Pu!==null?{id:vl,overflow:_l}:null,retryLane:536870912,hydrationErrors:null},_=ZI(h),_.return=g,g.child=_,ua=g,kr=null)):h=null,h===null)throw Du(g);return g.lanes=536870912,null}return Ov(g,N)}var F=h.memoizedState;if(F!==null){var Z=F.dehydrated;if(E2(g),P)if(g.flags&256)g.flags&=-257,g=m5(h,g,_);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(vi||Tm(h,g,_,!1),P=(_&h.childLanes)!==0,vi||P){if(N=_r,N!==null&&(Z=Kt(N,_),Z!==0&&Z!==F.retryLane))throw F.retryLane=Z,Nh(h,Z),fs(N,h,Z),q2;Wv(),g=m5(h,g,_)}else h=F.treeContext,kr=lo(Z.nextSibling),ua=g,In=!0,Ru=null,so=!1,h!==null&&eF(g,h),g=Ov(g,N),g.flags|=4096;return g}return h=pc(h.child,{mode:N.mode,children:N.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Lv(h,g){var _=g.ref;if(_===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(g.flags|=4194816)}}function K2(h,g,_,N,P){return Ch(g),_=T2(h,g,_,N,void 0,P),N=C2(),h!==null&&!vi?(k2(h,g,P),_c(h,g,P)):(In&&N&&c2(g),g.flags|=1,ha(h,g,_,P),g.child)}function p5(h,g,_,N,P,F){return Ch(g),g.updateQueue=null,_=bF(g,N,_,P),xF(h),N=C2(),h!==null&&!vi?(k2(h,g,F),_c(h,g,F)):(In&&N&&c2(g),g.flags|=1,ha(h,g,_,F),g.child)}function g5(h,g,_,N,P){if(Ch(g),g.stateNode===null){var F=Mm,Z=_.contextType;typeof Z=="object"&&Z!==null&&(F=da(Z)),F=new _(N,F),g.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=G2,g.stateNode=F,F._reactInternals=g,F=g.stateNode,F.props=N,F.state=g.memoizedState,F.refs={},v2(g),Z=_.contextType,F.context=typeof Z=="object"&&Z!==null?da(Z):Mm,F.state=g.memoizedState,Z=_.getDerivedStateFromProps,typeof Z=="function"&&(V2(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&&G2.enqueueReplaceState(F,F.state,null),Dx(g,N,F,P),Rx(),F.state=g.memoizedState),typeof F.componentDidMount=="function"&&(g.flags|=4194308),N=!0}else if(h===null){F=g.stateNode;var ge=g.memoizedProps,Oe=Oh(_,ge);F.props=Oe;var it=F.context,xt=_.contextType;Z=Mm,typeof xt=="object"&&xt!==null&&(Z=da(xt));var vt=_.getDerivedStateFromProps;xt=typeof vt=="function"||typeof F.getSnapshotBeforeUpdate=="function",ge=g.pendingProps!==ge,xt||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(ge||it!==Z)&&n5(g,F,N,Z),Lu=!1;var ot=g.memoizedState;F.state=ot,Dx(g,N,F,P),Rx(),it=g.memoizedState,ge||ot!==it||Lu?(typeof vt=="function"&&(V2(g,_,vt,N),it=g.memoizedState),(Oe=Lu||t5(g,_,Oe,N,ot,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=Oe):(typeof F.componentDidMount=="function"&&(g.flags|=4194308),N=!1)}else{F=g.stateNode,_2(h,g),Z=g.memoizedProps,xt=Oh(_,Z),F.props=xt,vt=g.pendingProps,ot=F.context,it=_.contextType,Oe=Mm,typeof it=="object"&&it!==null&&(Oe=da(it)),ge=_.getDerivedStateFromProps,(it=typeof ge=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(Z!==vt||ot!==Oe)&&n5(g,F,N,Oe),Lu=!1,ot=g.memoizedState,F.state=ot,Dx(g,N,F,P),Rx();var ht=g.memoizedState;Z!==vt||ot!==ht||Lu||h!==null&&h.dependencies!==null&&xv(h.dependencies)?(typeof ge=="function"&&(V2(g,_,ge,N),ht=g.memoizedState),(xt=Lu||t5(g,_,xt,N,ot,ht,Oe)||h!==null&&h.dependencies!==null&&xv(h.dependencies))?(it||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(N,ht,Oe),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(N,ht,Oe)),typeof F.componentDidUpdate=="function"&&(g.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof F.componentDidUpdate!="function"||Z===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Z===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),g.memoizedProps=N,g.memoizedState=ht),F.props=N,F.state=ht,F.context=Oe,N=xt):(typeof F.componentDidUpdate!="function"||Z===h.memoizedProps&&ot===h.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Z===h.memoizedProps&&ot===h.memoizedState||(g.flags|=1024),N=!1)}return F=N,Lv(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=Rh(g,h.child,null,P),g.child=Rh(g,null,_,P)):ha(h,g,_,P),g.memoizedState=F.state,h=g.child):h=_c(h,g,P),h}function x5(h,g,_,N){return Ah(),g.flags|=256,ha(h,g,_,N),g.child}var X2={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Y2(h){return{baseLanes:h,cachePool:sF()}}function Z2(h,g,_){return h=h!==null?h.childLanes&~_:0,g&&(h|=Ds),h}function b5(h,g,_){var N=g.pendingProps,P=!1,F=(g.flags&128)!==0,Z;if((Z=F)||(Z=h!==null&&h.memoizedState===null?!1:(hi.current&2)!==0),Z&&(P=!0,g.flags&=-129),Z=(g.flags&32)!==0,g.flags&=-33,h===null){if(In){if(P?Uu(g):zu(),(h=kr)?(h=EU(h,so),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:Pu!==null?{id:vl,overflow:_l}:null,retryLane:536870912,hydrationErrors:null},_=ZI(h),_.return=g,g.child=_,ua=g,kr=null)):h=null,h===null)throw Du(g);return RA(h)?g.lanes=32:g.lanes=536870912,null}var ge=N.children;return N=N.fallback,P?(zu(),P=g.mode,ge=Iv({mode:"hidden",children:ge},P),N=Eh(N,P,_,null),ge.return=g,N.return=g,ge.sibling=N,g.child=ge,N=g.child,N.memoizedState=Y2(_),N.childLanes=Z2(h,Z,_),g.memoizedState=X2,Ux(null,N)):(Uu(g),Q2(g,ge))}var Oe=h.memoizedState;if(Oe!==null&&(ge=Oe.dehydrated,ge!==null)){if(F)g.flags&256?(Uu(g),g.flags&=-257,g=J2(h,g,_)):g.memoizedState!==null?(zu(),g.child=h.child,g.flags|=128,g=null):(zu(),ge=N.fallback,P=g.mode,N=Iv({mode:"visible",children:N.children},P),ge=Eh(ge,P,_,null),ge.flags|=2,N.return=g,ge.return=g,N.sibling=ge,g.child=N,Rh(g,h.child,null,_),N=g.child,N.memoizedState=Y2(_),N.childLanes=Z2(h,Z,_),g.memoizedState=X2,g=Ux(null,N));else if(Uu(g),RA(ge)){if(Z=ge.nextSibling&&ge.nextSibling.dataset,Z)var it=Z.dgst;Z=it,N=Error(r(419)),N.stack="",N.digest=Z,Ax({value:N,source:null,stack:null}),g=J2(h,g,_)}else if(vi||Tm(h,g,_,!1),Z=(_&h.childLanes)!==0,vi||Z){if(Z=_r,Z!==null&&(N=Kt(Z,_),N!==0&&N!==Oe.retryLane))throw Oe.retryLane=N,Nh(h,N),fs(Z,h,N),q2;PA(ge)||Wv(),g=J2(h,g,_)}else PA(ge)?(g.flags|=192,g.child=h.child,g=null):(h=Oe.treeContext,kr=lo(ge.nextSibling),ua=g,In=!0,Ru=null,so=!1,h!==null&&eF(g,h),g=Q2(g,N.children),g.flags|=4096);return g}return P?(zu(),ge=N.fallback,P=g.mode,Oe=h.child,it=Oe.sibling,N=pc(Oe,{mode:"hidden",children:N.children}),N.subtreeFlags=Oe.subtreeFlags&65011712,it!==null?ge=pc(it,ge):(ge=Eh(ge,P,_,null),ge.flags|=2),ge.return=g,N.return=g,N.sibling=ge,g.child=N,Ux(null,N),N=g.child,ge=h.child.memoizedState,ge===null?ge=Y2(_):(P=ge.cachePool,P!==null?(Oe=bi._currentValue,P=P.parent!==Oe?{parent:Oe,pool:Oe}:P):P=sF(),ge={baseLanes:ge.baseLanes|_,cachePool:P}),N.memoizedState=ge,N.childLanes=Z2(h,Z,_),g.memoizedState=X2,Ux(h.child,N)):(Uu(g),_=h.child,h=_.sibling,_=pc(_,{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 Q2(h,g){return g=Iv({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function Iv(h,g){return h=ks(22,h,null,g),h.lanes=0,h}function J2(h,g,_){return Rh(g,h.child,null,_),h=Q2(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function y5(h,g,_){h.lanes|=g;var N=h.alternate;N!==null&&(N.lanes|=g),m2(h.return,g,_)}function eA(h,g,_,N,P,F){var Z=h.memoizedState;Z===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:N,tail:_,tailMode:P,treeForkCount:F}:(Z.isBackwards=g,Z.rendering=null,Z.renderingStartTime=0,Z.last=N,Z.tail=_,Z.tailMode=P,Z.treeForkCount=F)}function v5(h,g,_){var N=g.pendingProps,P=N.revealOrder,F=N.tail;N=N.children;var Z=hi.current,ge=(Z&2)!==0;if(ge?(Z=Z&1|2,g.flags|=128):Z&=1,ne(hi,Z),ha(h,g,N,_),N=In?Ex:0,!ge&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&y5(h,_,g);else if(h.tag===19)y5(h,_,g);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===g)break e;for(;h.sibling===null;){if(h.return===null||h.return===g)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(P){case"forwards":for(_=g.child,P=null;_!==null;)h=_.alternate,h!==null&&Nv(h)===null&&(P=_),_=_.sibling;_=P,_===null?(P=g.child,g.child=null):(P=_.sibling,_.sibling=null),eA(g,!1,P,_,F,N);break;case"backwards":case"unstable_legacy-backwards":for(_=null,P=g.child,g.child=null;P!==null;){if(h=P.alternate,h!==null&&Nv(h)===null){g.child=P;break}h=P.sibling,P.sibling=_,_=P,P=h}eA(g,!0,_,null,F,N);break;case"together":eA(g,!1,null,null,void 0,N);break;default:g.memoizedState=null}return g.child}function _c(h,g,_){if(h!==null&&(g.dependencies=h.dependencies),Hu|=g.lanes,(_&g.childLanes)===0)if(h!==null){if(Tm(h,g,_,!1),(_&g.childLanes)===0)return null}else return null;if(h!==null&&g.child!==h.child)throw Error(r(153));if(g.child!==null){for(h=g.child,_=pc(h,h.pendingProps),g.child=_,_.return=g;h.sibling!==null;)h=h.sibling,_=_.sibling=pc(h,h.pendingProps),_.return=g;_.sibling=null}return g.child}function tA(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&xv(h)))}function Qae(h,g,_){switch(g.tag){case 3:Ee(g,g.stateNode.containerInfo),Ou(g,bi,h.memoizedState.cache),Ah();break;case 27:case 5:Ne(g);break;case 4:Ee(g,g.stateNode.containerInfo);break;case 10:Ou(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,E2(g),null;break;case 13:var N=g.memoizedState;if(N!==null)return N.dehydrated!==null?(Uu(g),g.flags|=128,null):(_&g.child.childLanes)!==0?b5(h,g,_):(Uu(g),h=_c(h,g,_),h!==null?h.sibling:null);Uu(g);break;case 19:var P=(h.flags&128)!==0;if(N=(_&g.childLanes)!==0,N||(Tm(h,g,_,!1),N=(_&g.childLanes)!==0),P){if(N)return v5(h,g,_);g.flags|=128}if(P=g.memoizedState,P!==null&&(P.rendering=null,P.tail=null,P.lastEffect=null),ne(hi,hi.current),N)break;return null;case 22:return g.lanes=0,h5(h,g,_,g.pendingProps);case 24:Ou(g,bi,h.memoizedState.cache)}return _c(h,g,_)}function _5(h,g,_){if(h!==null)if(h.memoizedProps!==g.pendingProps)vi=!0;else{if(!tA(h,_)&&(g.flags&128)===0)return vi=!1,Qae(h,g,_);vi=(h.flags&131072)!==0}else vi=!1,In&&(g.flags&1048576)!==0&&JI(g,Ex,g.index);switch(g.lanes=0,g.tag){case 16:e:{var N=g.pendingProps;if(h=jh(g.elementType),g.type=h,typeof h=="function")s2(h)?(N=Oh(h,N),g.tag=1,g=g5(null,g,h,N,_)):(g.tag=0,g=K2(null,g,h,N,_));else{if(h!=null){var P=h.$$typeof;if(P===A){g.tag=11,g=c5(null,g,h,N,_);break e}else if(P===E){g.tag=14,g=u5(null,g,h,N,_);break e}}throw g=j(h)||h,Error(r(306,g,""))}}return g;case 0:return K2(h,g,g.type,g.pendingProps,_);case 1:return N=g.type,P=Oh(N,g.pendingProps),g5(h,g,N,P,_);case 3:e:{if(Ee(g,g.stateNode.containerInfo),h===null)throw Error(r(387));N=g.pendingProps;var F=g.memoizedState;P=F.element,_2(h,g),Dx(g,N,null,_);var Z=g.memoizedState;if(N=Z.cache,Ou(g,bi,N),N!==F.cache&&p2(g,[bi],_,!0),Rx(),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=x5(h,g,N,_);break e}else if(N!==P){P=ro(Error(r(424)),g),Ax(P),g=x5(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,kr=lo(h.firstChild),ua=g,In=!0,Ru=null,so=!0,_=hF(g,null,N,_),g.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling;else{if(Ah(),N===P){g=_c(h,g,_);break e}ha(h,g,N,_)}g=g.child}return g;case 26:return Lv(h,g),h===null?(_=PU(g.type,null,g.pendingProps,null))?g.memoizedState=_:In||(_=g.type,h=g.pendingProps,N=Jv(pe.current).createElement(_),N[tn]=g,N[yr]=h,fa(N,_,h),de(N),g.stateNode=N):g.memoizedState=PU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return Ne(g),h===null&&In&&(N=g.stateNode=CU(g.type,g.pendingProps,pe.current),ua=g,so=!0,P=kr,Ku(g.type)?(DA=P,kr=lo(N.firstChild)):kr=P),ha(h,g,g.pendingProps.children,_),Lv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&In&&((P=N=kr)&&(N=Tse(N,g.type,g.pendingProps,so),N!==null?(g.stateNode=N,ua=g,kr=lo(N.firstChild),so=!1,P=!0):P=!1),P||Du(g)),Ne(g),P=g.type,F=g.pendingProps,Z=h!==null?h.memoizedProps:null,N=F.children,CA(P,F)?N=null:Z!==null&&CA(P,Z)&&(g.flags|=32),g.memoizedState!==null&&(P=T2(h,g,Hae,null,null,_),eb._currentValue=P),Lv(h,g),ha(h,g,N,_),g.child;case 6:return h===null&&In&&((h=_=kr)&&(_=Cse(_,g.pendingProps,so),_!==null?(g.stateNode=_,ua=g,kr=null,h=!0):h=!1),h||Du(g)),null;case 13:return b5(h,g,_);case 4:return Ee(g,g.stateNode.containerInfo),N=g.pendingProps,h===null?g.child=Rh(g,null,N,_):ha(h,g,N,_),g.child;case 11:return c5(h,g,g.type,g.pendingProps,_);case 7:return ha(h,g,g.pendingProps,_),g.child;case 8:return ha(h,g,g.pendingProps.children,_),g.child;case 12:return ha(h,g,g.pendingProps.children,_),g.child;case 10:return N=g.pendingProps,Ou(g,g.type,N.value),ha(h,g,N.children,_),g.child;case 9:return P=g.type._context,N=g.pendingProps.children,Ch(g),P=da(P),N=N(P),g.flags|=1,ha(h,g,N,_),g.child;case 14:return u5(h,g,g.type,g.pendingProps,_);case 15:return d5(h,g,g.type,g.pendingProps,_);case 19:return v5(h,g,_);case 31:return Zae(h,g,_);case 22:return h5(h,g,_,g.pendingProps);case 24:return Ch(g),N=da(bi),h===null?(P=b2(),P===null&&(P=_r,F=g2(),P.pooledCache=F,F.refCount++,F!==null&&(P.pooledCacheLanes|=_),P=F),g.memoizedState={parent:N,cache:P},v2(g),Ou(g,bi,P)):((h.lanes&_)!==0&&(_2(h,g),Dx(g,null,null,_),Rx()),P=h.memoizedState,F=g.memoizedState,P.parent!==N?(P={parent:N,cache:N},g.memoizedState=P,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=P),Ou(g,bi,N)):(N=F.cache,Ou(g,bi,N),N!==P.cache&&p2(g,[bi],_,!0))),ha(h,g,g.pendingProps.children,_),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function wc(h){h.flags|=4}function nA(h,g,_,N,P){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(P&335544128)===P)if(h.stateNode.complete)h.flags|=8192;else if(K5())h.flags|=8192;else throw Ph=_v,y2}else h.flags&=-16777217}function w5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!IU(g))if(K5())h.flags|=8192;else throw Ph=_v,y2}function Fv(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?Pt():536870912,h.lanes|=g,zm|=g)}function zx(h,g){if(!In)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 jr(h){var g=h.alternate!==null&&h.alternate.child===h.child,_=0,N=0;if(g)for(var P=h.child;P!==null;)_|=P.lanes|P.childLanes,N|=P.subtreeFlags&65011712,N|=P.flags&65011712,P.return=h,P=P.sibling;else for(P=h.child;P!==null;)_|=P.lanes|P.childLanes,N|=P.subtreeFlags,N|=P.flags,P.return=h,P=P.sibling;return h.subtreeFlags|=N,h.childLanes=_,g}function Jae(h,g,_){var N=g.pendingProps;switch(u2(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jr(g),null;case 1:return jr(g),null;case 3:return _=g.stateNode,N=null,h!==null&&(N=h.memoizedState.cache),g.memoizedState.cache!==N&&(g.flags|=2048),bc(bi),xe(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Am(g)?wc(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,h2())),jr(g),null;case 26:var P=g.type,F=g.memoizedState;return h===null?(wc(g),F!==null?(jr(g),w5(g,F)):(jr(g),nA(g,P,null,N,_))):F?F!==h.memoizedState?(wc(g),jr(g),w5(g,F)):(jr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==N&&wc(g),jr(g),nA(g,P,h,N,_)),null;case 27:if(_e(g),_=pe.current,P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&wc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return jr(g),null}h=ae.current,Am(g)?tF(g):(h=CU(P,N,_),g.stateNode=h,wc(g))}return jr(g),null;case 5:if(_e(g),P=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&wc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return jr(g),null}if(F=ae.current,Am(g))tF(g);else{var Z=Jv(pe.current);switch(F){case 1:F=Z.createElementNS("http://www.w3.org/2000/svg",P);break;case 2:F=Z.createElementNS("http://www.w3.org/1998/Math/MathML",P);break;default:switch(P){case"svg":F=Z.createElementNS("http://www.w3.org/2000/svg",P);break;case"math":F=Z.createElementNS("http://www.w3.org/1998/Math/MathML",P);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(P,{is:N.is}):Z.createElement(P)}}F[tn]=g,F[yr]=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(fa(F,P,N),P){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&wc(g)}}return jr(g),nA(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,_),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==N&&wc(g);else{if(typeof N!="string"&&g.stateNode===null)throw Error(r(166));if(h=pe.current,Am(g)){if(h=g.stateNode,_=g.memoizedProps,N=null,P=ua,P!==null)switch(P.tag){case 27:case 5:N=P.memoizedProps}h[tn]=g,h=!!(h.nodeValue===_||N!==null&&N.suppressHydrationWarning===!0||bU(h.nodeValue,_)),h||Du(g,!0)}else h=Jv(h).createTextNode(N),h[tn]=g,g.stateNode=h}return jr(g),null;case 31:if(_=g.memoizedState,h===null||h.memoizedState!==null){if(N=Am(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[tn]=g}else Ah(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;jr(g),h=!1}else _=h2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return g.flags&256?(Ps(g),g):(Ps(g),null);if((g.flags&128)!==0)throw Error(r(558))}return jr(g),null;case 13:if(N=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(P=Am(g),N!==null&&N.dehydrated!==null){if(h===null){if(!P)throw Error(r(318));if(P=g.memoizedState,P=P!==null?P.dehydrated:null,!P)throw Error(r(317));P[tn]=g}else Ah(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;jr(g),P=!1}else P=h2(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=P),P=!0;if(!P)return g.flags&256?(Ps(g),g):(Ps(g),null)}return Ps(g),(g.flags&128)!==0?(g.lanes=_,g):(_=N!==null,h=h!==null&&h.memoizedState!==null,_&&(N=g.child,P=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(P=N.alternate.memoizedState.cachePool.pool),F=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(F=N.memoizedState.cachePool.pool),F!==P&&(N.flags|=2048)),_!==h&&_&&(g.child.flags|=8192),Fv(g,g.updateQueue),jr(g),null);case 4:return xe(),h===null&&MA(g.stateNode.containerInfo),jr(g),null;case 10:return bc(g.type),jr(g),null;case 19:if(V(hi),N=g.memoizedState,N===null)return jr(g),null;if(P=(g.flags&128)!==0,F=N.rendering,F===null)if(P)zx(N,!1);else{if(Jr!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(F=Nv(h),F!==null){for(g.flags|=128,zx(N,!1),h=F.updateQueue,g.updateQueue=h,Fv(g,h),g.subtreeFlags=0,h=_,_=g.child;_!==null;)YI(_,h),_=_.sibling;return ne(hi,hi.current&1|2),In&&gc(g,N.treeForkCount),g.child}h=h.sibling}N.tail!==null&&L()>Hv&&(g.flags|=128,P=!0,zx(N,!1),g.lanes=4194304)}else{if(!P)if(h=Nv(F),h!==null){if(g.flags|=128,P=!0,h=h.updateQueue,g.updateQueue=h,Fv(g,h),zx(N,!0),N.tail===null&&N.tailMode==="hidden"&&!F.alternate&&!In)return jr(g),null}else 2*L()-N.renderingStartTime>Hv&&_!==536870912&&(g.flags|=128,P=!0,zx(N,!1),g.lanes=4194304);N.isBackwards?(F.sibling=g.child,g.child=F):(h=N.last,h!==null?h.sibling=F:g.child=F,N.last=F)}return N.tail!==null?(h=N.tail,N.rendering=h,N.tail=h.sibling,N.renderingStartTime=L(),h.sibling=null,_=hi.current,ne(hi,P?_&1|2:_&1),In&&gc(g,N.treeForkCount),h):(jr(g),null);case 22:case 23:return Ps(g),N2(),N=g.memoizedState!==null,h!==null?h.memoizedState!==null!==N&&(g.flags|=8192):N&&(g.flags|=8192),N?(_&536870912)!==0&&(g.flags&128)===0&&(jr(g),g.subtreeFlags&6&&(g.flags|=8192)):jr(g),_=g.updateQueue,_!==null&&Fv(g,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==_&&(g.flags|=2048),h!==null&&V(kh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),g.memoizedState.cache!==_&&(g.flags|=2048),bc(bi),jr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function ese(h,g){switch(u2(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return bc(bi),xe(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return _e(g),null;case 31:if(g.memoizedState!==null){if(Ps(g),g.alternate===null)throw Error(r(340));Ah()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Ps(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));Ah()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return V(hi),null;case 4:return xe(),null;case 10:return bc(g.type),null;case 22:case 23:return Ps(g),N2(),h!==null&&V(kh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return bc(bi),null;case 25:return null;default:return null}}function S5(h,g){switch(u2(g),g.tag){case 3:bc(bi),xe();break;case 26:case 27:case 5:_e(g);break;case 4:xe();break;case 31:g.memoizedState!==null&&Ps(g);break;case 13:Ps(g);break;case 19:V(hi);break;case 10:bc(g.type);break;case 22:case 23:Ps(g),N2(),h!==null&&V(kh);break;case 24:bc(bi)}}function Bx(h,g){try{var _=g.updateQueue,N=_!==null?_.lastEffect:null;if(N!==null){var P=N.next;_=P;do{if((_.tag&h)===h){N=void 0;var F=_.create,Z=_.inst;N=F(),Z.destroy=N}_=_.next}while(_!==P)}}catch(ge){rr(g,g.return,ge)}}function Bu(h,g,_){try{var N=g.updateQueue,P=N!==null?N.lastEffect:null;if(P!==null){var F=P.next;N=F;do{if((N.tag&h)===h){var Z=N.inst,ge=Z.destroy;if(ge!==void 0){Z.destroy=void 0,P=g;var Oe=_,it=ge;try{it()}catch(xt){rr(P,Oe,xt)}}}N=N.next}while(N!==F)}}catch(xt){rr(g,g.return,xt)}}function M5(h){var g=h.updateQueue;if(g!==null){var _=h.stateNode;try{mF(g,_)}catch(N){rr(h,h.return,N)}}}function N5(h,g,_){_.props=Oh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(N){rr(h,g,N)}}function $x(h,g){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var N=h.stateNode;break;case 30:N=h.stateNode;break;default:N=h.stateNode}typeof _=="function"?h.refCleanup=_(N):_.current=N}}catch(P){rr(h,g,P)}}function wl(h,g){var _=h.ref,N=h.refCleanup;if(_!==null)if(typeof N=="function")try{N()}catch(P){rr(h,g,P)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(P){rr(h,g,P)}else _.current=null}function E5(h){var g=h.type,_=h.memoizedProps,N=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":_.autoFocus&&N.focus();break e;case"img":_.src?N.src=_.src:_.srcSet&&(N.srcset=_.srcSet)}}catch(P){rr(h,h.return,P)}}function rA(h,g,_){try{var N=h.stateNode;wse(N,h.type,_,g),N[yr]=g}catch(P){rr(h,h.return,P)}}function A5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Ku(h.type)||h.tag===4}function iA(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||A5(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&&Ku(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function aA(h,g,_){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,g):(g=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,g.appendChild(h),_=_._reactRootContainer,_!=null||g.onclick!==null||(g.onclick=fc));else if(N!==4&&(N===27&&Ku(h.type)&&(_=h.stateNode,g=null),h=h.child,h!==null))for(aA(h,g,_),h=h.sibling;h!==null;)aA(h,g,_),h=h.sibling}function Uv(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&&Ku(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(Uv(h,g,_),h=h.sibling;h!==null;)Uv(h,g,_),h=h.sibling}function T5(h){var g=h.stateNode,_=h.memoizedProps;try{for(var N=h.type,P=g.attributes;P.length;)g.removeAttributeNode(P[0]);fa(g,N,_),g[tn]=h,g[yr]=_}catch(F){rr(h,h.return,F)}}var Sc=!1,_i=!1,sA=!1,C5=typeof WeakSet=="function"?WeakSet:Set,Vi=null;function tse(h,g){if(h=h.containerInfo,AA=s_,h=BI(h),JE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var N=_.getSelection&&_.getSelection();if(N&&N.rangeCount!==0){_=N.anchorNode;var P=N.anchorOffset,F=N.focusNode;N=N.focusOffset;try{_.nodeType,F.nodeType}catch{_=null;break e}var Z=0,ge=-1,Oe=-1,it=0,xt=0,vt=h,ot=null;t:for(;;){for(var ht;vt!==_||P!==0&&vt.nodeType!==3||(ge=Z+P),vt!==F||N!==0&&vt.nodeType!==3||(Oe=Z+N),vt.nodeType===3&&(Z+=vt.nodeValue.length),(ht=vt.firstChild)!==null;)ot=vt,vt=ht;for(;;){if(vt===h)break t;if(ot===_&&++it===P&&(ge=Z),ot===F&&++xt===N&&(Oe=Z),(ht=vt.nextSibling)!==null)break;vt=ot,ot=vt.parentNode}vt=ht}_=ge===-1||Oe===-1?null:{start:ge,end:Oe}}else _=null}_=_||{start:0,end:0}}else _=null;for(TA={focusedElem:h,selectionRange:_},s_=!1,Vi=g;Vi!==null;)if(g=Vi,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,Vi=h;else for(;Vi!==null;){switch(g=Vi,F=g.alternate,h=g.flags,g.tag){case 0:if((h&4)!==0&&(h=g.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)P=h[_],P.ref.impl=P.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&F!==null){h=void 0,_=g,P=F.memoizedProps,F=F.memoizedState,N=_.stateNode;try{var Xt=Oh(_.type,P);h=N.getSnapshotBeforeUpdate(Xt,F),N.__reactInternalSnapshotBeforeUpdate=h}catch(sn){rr(_,_.return,sn)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,_=h.nodeType,_===9)jA(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":jA(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=g.sibling,h!==null){h.return=g.return,Vi=h;break}Vi=g.return}}function k5(h,g,_){var N=_.flags;switch(_.tag){case 0:case 11:case 15:Nc(h,_),N&4&&Bx(5,_);break;case 1:if(Nc(h,_),N&4)if(h=_.stateNode,g===null)try{h.componentDidMount()}catch(Z){rr(_,_.return,Z)}else{var P=Oh(_.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(P,g,h.__reactInternalSnapshotBeforeUpdate)}catch(Z){rr(_,_.return,Z)}}N&64&&M5(_),N&512&&$x(_,_.return);break;case 3:if(Nc(h,_),N&64&&(h=_.updateQueue,h!==null)){if(g=null,_.child!==null)switch(_.child.tag){case 27:case 5:g=_.child.stateNode;break;case 1:g=_.child.stateNode}try{mF(h,g)}catch(Z){rr(_,_.return,Z)}}break;case 27:g===null&&N&4&&T5(_);case 26:case 5:Nc(h,_),g===null&&N&4&&E5(_),N&512&&$x(_,_.return);break;case 12:Nc(h,_);break;case 31:Nc(h,_),N&4&&R5(h,_);break;case 13:Nc(h,_),N&4&&D5(h,_),N&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=use.bind(null,_),kse(h,_))));break;case 22:if(N=_.memoizedState!==null||Sc,!N){g=g!==null&&g.memoizedState!==null||_i,P=Sc;var F=_i;Sc=N,(_i=g)&&!F?Ec(h,_,(_.subtreeFlags&8772)!==0):Nc(h,_),Sc=P,_i=F}break;case 30:break;default:Nc(h,_)}}function j5(h){var g=h.alternate;g!==null&&(h.alternate=null,j5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&&st(g)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Ir=null,cs=!1;function Mc(h,g,_){for(_=_.child;_!==null;)P5(h,g,_),_=_.sibling}function P5(h,g,_){if(oe&&typeof oe.onCommitFiberUnmount=="function")try{oe.onCommitFiberUnmount(Je,_)}catch{}switch(_.tag){case 26:_i||wl(_,g),Mc(h,g,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:_i||wl(_,g);var N=Ir,P=cs;Ku(_.type)&&(Ir=_.stateNode,cs=!1),Mc(h,g,_),Zx(_.stateNode),Ir=N,cs=P;break;case 5:_i||wl(_,g);case 6:if(N=Ir,P=cs,Ir=null,Mc(h,g,_),Ir=N,cs=P,Ir!==null)if(cs)try{(Ir.nodeType===9?Ir.body:Ir.nodeName==="HTML"?Ir.ownerDocument.body:Ir).removeChild(_.stateNode)}catch(F){rr(_,g,F)}else try{Ir.removeChild(_.stateNode)}catch(F){rr(_,g,F)}break;case 18:Ir!==null&&(cs?(h=Ir,MU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),Km(h)):MU(Ir,_.stateNode));break;case 4:N=Ir,P=cs,Ir=_.stateNode.containerInfo,cs=!0,Mc(h,g,_),Ir=N,cs=P;break;case 0:case 11:case 14:case 15:Bu(2,_,g),_i||Bu(4,_,g),Mc(h,g,_);break;case 1:_i||(wl(_,g),N=_.stateNode,typeof N.componentWillUnmount=="function"&&N5(_,g,N)),Mc(h,g,_);break;case 21:Mc(h,g,_);break;case 22:_i=(N=_i)||_.memoizedState!==null,Mc(h,g,_),_i=N;break;default:Mc(h,g,_)}}function R5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{Km(h)}catch(_){rr(g,g.return,_)}}}function D5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{Km(h)}catch(_){rr(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 C5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new C5),g;default:throw Error(r(435,h.tag))}}function zv(h,g){var _=nse(h);g.forEach(function(N){if(!_.has(N)){_.add(N);var P=dse.bind(null,h,N);N.then(P,P)}})}function us(h,g){var _=g.deletions;if(_!==null)for(var N=0;N<_.length;N++){var P=_[N],F=h,Z=g,ge=Z;e:for(;ge!==null;){switch(ge.tag){case 27:if(Ku(ge.type)){Ir=ge.stateNode,cs=!1;break e}break;case 5:Ir=ge.stateNode,cs=!1;break e;case 3:case 4:Ir=ge.stateNode.containerInfo,cs=!0;break e}ge=ge.return}if(Ir===null)throw Error(r(160));P5(F,Z,P),Ir=null,cs=!1,F=P.alternate,F!==null&&(F.return=null),P.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)O5(g,h),g=g.sibling}var Ho=null;function O5(h,g){var _=h.alternate,N=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:us(g,h),ds(h),N&4&&(Bu(3,h,h.return),Bx(3,h),Bu(5,h,h.return));break;case 1:us(g,h),ds(h),N&512&&(_i||_===null||wl(_,_.return)),N&64&&Sc&&(h=h.updateQueue,h!==null&&(N=h.callbacks,N!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?N:_.concat(N))));break;case 26:var P=Ho;if(us(g,h),ds(h),N&512&&(_i||_===null||wl(_,_.return)),N&4){var F=_!==null?_.memoizedState:null;if(N=h.memoizedState,_===null)if(N===null)if(h.stateNode===null){e:{N=h.type,_=h.memoizedProps,P=P.ownerDocument||P;t:switch(N){case"title":F=P.getElementsByTagName("title")[0],(!F||F[ct]||F[tn]||F.namespaceURI==="http://www.w3.org/2000/svg"||F.hasAttribute("itemprop"))&&(F=P.createElement(N),P.head.insertBefore(F,P.querySelector("head > title"))),fa(F,N,_),F[tn]=h,de(F),N=F;break e;case"link":var Z=OU("link","href",P).get(N+(_.href||""));if(Z){for(var ge=0;ge<Z.length;ge++)if(F=Z[ge],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(ge,1);break t}}F=P.createElement(N),fa(F,N,_),P.head.appendChild(F);break;case"meta":if(Z=OU("meta","content",P).get(N+(_.content||""))){for(ge=0;ge<Z.length;ge++)if(F=Z[ge],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(ge,1);break t}}F=P.createElement(N),fa(F,N,_),P.head.appendChild(F);break;default:throw Error(r(468,N))}F[tn]=h,de(F),N=F}h.stateNode=N}else LU(P,h.type,h.stateNode);else h.stateNode=DU(P,N,h.memoizedProps);else F!==N?(F===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):F.count--,N===null?LU(P,h.type,h.stateNode):DU(P,N,h.memoizedProps)):N===null&&h.stateNode!==null&&rA(h,h.memoizedProps,_.memoizedProps)}break;case 27:us(g,h),ds(h),N&512&&(_i||_===null||wl(_,_.return)),_!==null&&N&4&&rA(h,h.memoizedProps,_.memoizedProps);break;case 5:if(us(g,h),ds(h),N&512&&(_i||_===null||wl(_,_.return)),h.flags&32){P=h.stateNode;try{vr(P,"")}catch(Xt){rr(h,h.return,Xt)}}N&4&&h.stateNode!=null&&(P=h.memoizedProps,rA(h,P,_!==null?_.memoizedProps:P)),N&1024&&(sA=!0);break;case 6:if(us(g,h),ds(h),N&4){if(h.stateNode===null)throw Error(r(162));N=h.memoizedProps,_=h.stateNode;try{_.nodeValue=N}catch(Xt){rr(h,h.return,Xt)}}break;case 3:if(n_=null,P=Ho,Ho=e_(g.containerInfo),us(g,h),Ho=P,ds(h),N&4&&_!==null&&_.memoizedState.isDehydrated)try{Km(g.containerInfo)}catch(Xt){rr(h,h.return,Xt)}sA&&(sA=!1,L5(h));break;case 4:N=Ho,Ho=e_(h.stateNode.containerInfo),us(g,h),ds(h),Ho=N;break;case 12:us(g,h),ds(h);break;case 31:us(g,h),ds(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,zv(h,N)));break;case 13:us(g,h),ds(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&($v=L()),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,zv(h,N)));break;case 22:P=h.memoizedState!==null;var Oe=_!==null&&_.memoizedState!==null,it=Sc,xt=_i;if(Sc=it||P,_i=xt||Oe,us(g,h),_i=xt,Sc=it,ds(h),N&8192)e:for(g=h.stateNode,g._visibility=P?g._visibility&-2:g._visibility|1,P&&(_===null||Oe||Sc||_i||Lh(h)),_=null,g=h;;){if(g.tag===5||g.tag===26){if(_===null){Oe=_=g;try{if(F=Oe.stateNode,P)Z=F.style,typeof Z.setProperty=="function"?Z.setProperty("display","none","important"):Z.display="none";else{ge=Oe.stateNode;var vt=Oe.memoizedProps.style,ot=vt!=null&&vt.hasOwnProperty("display")?vt.display:null;ge.style.display=ot==null||typeof ot=="boolean"?"":(""+ot).trim()}}catch(Xt){rr(Oe,Oe.return,Xt)}}}else if(g.tag===6){if(_===null){Oe=g;try{Oe.stateNode.nodeValue=P?"":Oe.memoizedProps}catch(Xt){rr(Oe,Oe.return,Xt)}}}else if(g.tag===18){if(_===null){Oe=g;try{var ht=Oe.stateNode;P?NU(ht,!0):NU(Oe.stateNode,!1)}catch(Xt){rr(Oe,Oe.return,Xt)}}}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,zv(h,_))));break;case 19:us(g,h),ds(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,zv(h,N)));break;case 30:break;case 21:break;default:us(g,h),ds(h)}}function ds(h){var g=h.flags;if(g&2){try{for(var _,N=h.return;N!==null;){if(A5(N)){_=N;break}N=N.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var P=_.stateNode,F=iA(h);Uv(h,F,P);break;case 5:var Z=_.stateNode;_.flags&32&&(vr(Z,""),_.flags&=-33);var ge=iA(h);Uv(h,ge,Z);break;case 3:case 4:var Oe=_.stateNode.containerInfo,it=iA(h);aA(h,it,Oe);break;default:throw Error(r(161))}}catch(xt){rr(h,h.return,xt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function L5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;L5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Nc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)k5(h,g.alternate,g),g=g.sibling}function Lh(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:Bu(4,g,g.return),Lh(g);break;case 1:wl(g,g.return);var _=g.stateNode;typeof _.componentWillUnmount=="function"&&N5(g,g.return,_),Lh(g);break;case 27:Zx(g.stateNode);case 26:case 5:wl(g,g.return),Lh(g);break;case 22:g.memoizedState===null&&Lh(g);break;case 30:Lh(g);break;default:Lh(g)}h=h.sibling}}function Ec(h,g,_){for(_=_&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var N=g.alternate,P=h,F=g,Z=F.flags;switch(F.tag){case 0:case 11:case 15:Ec(P,F,_),Bx(4,F);break;case 1:if(Ec(P,F,_),N=F,P=N.stateNode,typeof P.componentDidMount=="function")try{P.componentDidMount()}catch(it){rr(N,N.return,it)}if(N=F,P=N.updateQueue,P!==null){var ge=N.stateNode;try{var Oe=P.shared.hiddenCallbacks;if(Oe!==null)for(P.shared.hiddenCallbacks=null,P=0;P<Oe.length;P++)fF(Oe[P],ge)}catch(it){rr(N,N.return,it)}}_&&Z&64&&M5(F),$x(F,F.return);break;case 27:T5(F);case 26:case 5:Ec(P,F,_),_&&N===null&&Z&4&&E5(F),$x(F,F.return);break;case 12:Ec(P,F,_);break;case 31:Ec(P,F,_),_&&Z&4&&R5(P,F);break;case 13:Ec(P,F,_),_&&Z&4&&D5(P,F);break;case 22:F.memoizedState===null&&Ec(P,F,_),$x(F,F.return);break;case 30:break;default:Ec(P,F,_)}g=g.sibling}}function oA(h,g){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Tx(_))}function lA(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Tx(h))}function Vo(h,g,_,N){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)I5(h,g,_,N),g=g.sibling}function I5(h,g,_,N){var P=g.flags;switch(g.tag){case 0:case 11:case 15:Vo(h,g,_,N),P&2048&&Bx(9,g);break;case 1:Vo(h,g,_,N);break;case 3:Vo(h,g,_,N),P&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Tx(h)));break;case 12:if(P&2048){Vo(h,g,_,N),h=g.stateNode;try{var F=g.memoizedProps,Z=F.id,ge=F.onPostCommit;typeof ge=="function"&&ge(Z,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Oe){rr(g,g.return,Oe)}}else Vo(h,g,_,N);break;case 31:Vo(h,g,_,N);break;case 13:Vo(h,g,_,N);break;case 23:break;case 22:F=g.stateNode,Z=g.alternate,g.memoizedState!==null?F._visibility&2?Vo(h,g,_,N):Hx(h,g):F._visibility&2?Vo(h,g,_,N):(F._visibility|=2,Im(h,g,_,N,(g.subtreeFlags&10256)!==0||!1)),P&2048&&oA(Z,g);break;case 24:Vo(h,g,_,N),P&2048&&lA(g.alternate,g);break;default:Vo(h,g,_,N)}}function Im(h,g,_,N,P){for(P=P&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var F=h,Z=g,ge=_,Oe=N,it=Z.flags;switch(Z.tag){case 0:case 11:case 15:Im(F,Z,ge,Oe,P),Bx(8,Z);break;case 23:break;case 22:var xt=Z.stateNode;Z.memoizedState!==null?xt._visibility&2?Im(F,Z,ge,Oe,P):Hx(F,Z):(xt._visibility|=2,Im(F,Z,ge,Oe,P)),P&&it&2048&&oA(Z.alternate,Z);break;case 24:Im(F,Z,ge,Oe,P),P&&it&2048&&lA(Z.alternate,Z);break;default:Im(F,Z,ge,Oe,P)}g=g.sibling}}function Hx(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var _=h,N=g,P=N.flags;switch(N.tag){case 22:Hx(_,N),P&2048&&oA(N.alternate,N);break;case 24:Hx(_,N),P&2048&&lA(N.alternate,N);break;default:Hx(_,N)}g=g.sibling}}var Vx=8192;function Fm(h,g,_){if(h.subtreeFlags&Vx)for(h=h.child;h!==null;)F5(h,g,_),h=h.sibling}function F5(h,g,_){switch(h.tag){case 26:Fm(h,g,_),h.flags&Vx&&h.memoizedState!==null&&$se(_,Ho,h.memoizedState,h.memoizedProps);break;case 5:Fm(h,g,_);break;case 3:case 4:var N=Ho;Ho=e_(h.stateNode.containerInfo),Fm(h,g,_),Ho=N;break;case 22:h.memoizedState===null&&(N=h.alternate,N!==null&&N.memoizedState!==null?(N=Vx,Vx=16777216,Fm(h,g,_),Vx=N):Fm(h,g,_));break;default:Fm(h,g,_)}}function U5(h){var g=h.alternate;if(g!==null&&(h=g.child,h!==null)){g.child=null;do g=h.sibling,h.sibling=null,h=g;while(h!==null)}}function Gx(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Vi=N,B5(N,h)}U5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)z5(h),h=h.sibling}function z5(h){switch(h.tag){case 0:case 11:case 15:Gx(h),h.flags&2048&&Bu(9,h,h.return);break;case 3:Gx(h);break;case 12:Gx(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,Bv(h)):Gx(h);break;default:Gx(h)}}function Bv(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var _=0;_<g.length;_++){var N=g[_];Vi=N,B5(N,h)}U5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:Bu(8,g,g.return),Bv(g);break;case 22:_=g.stateNode,_._visibility&2&&(_._visibility&=-3,Bv(g));break;default:Bv(g)}h=h.sibling}}function B5(h,g){for(;Vi!==null;){var _=Vi;switch(_.tag){case 0:case 11:case 15:Bu(8,_,g);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var N=_.memoizedState.cachePool.pool;N!=null&&N.refCount++}break;case 24:Tx(_.memoizedState.cache)}if(N=_.child,N!==null)N.return=_,Vi=N;else e:for(_=h;Vi!==null;){N=Vi;var P=N.sibling,F=N.return;if(j5(N),N===_){Vi=null;break e}if(P!==null){P.return=F,Vi=P;break e}Vi=F}}}var rse={getCacheForType:function(h){var g=da(bi),_=g.data.get(h);return _===void 0&&(_=h(),g.data.set(h,_)),_},cacheSignal:function(){return da(bi).controller.signal}},ise=typeof WeakMap=="function"?WeakMap:Map,Qn=0,_r=null,Cn=null,Rn=0,nr=0,Rs=null,$u=!1,Um=!1,cA=!1,Ac=0,Jr=0,Hu=0,Ih=0,uA=0,Ds=0,zm=0,Wx=null,hs=null,dA=!1,$v=0,$5=0,Hv=1/0,Vv=null,Vu=null,ki=0,Gu=null,Bm=null,Tc=0,hA=0,fA=null,H5=null,qx=0,mA=null;function Os(){return(Qn&2)!==0&&Rn!==0?Rn&-Rn:K.T!==null?vA():Ln()}function V5(){if(Ds===0)if((Rn&536870912)===0||In){var h=ve;ve<<=1,(ve&3932160)===0&&(ve=262144),Ds=h}else Ds=536870912;return h=js.current,h!==null&&(h.flags|=32),Ds}function fs(h,g,_){(h===_r&&(nr===2||nr===9)||h.cancelPendingCommit!==null)&&($m(h,0),Wu(h,Rn,Ds,!1)),ln(h,_),((Qn&2)===0||h!==_r)&&(h===_r&&((Qn&2)===0&&(Ih|=_),Jr===4&&Wu(h,Rn,Ds,!1)),Sl(h))}function G5(h,g,_){if((Qn&6)!==0)throw Error(r(327));var N=!_&&(g&127)===0&&(g&h.expiredLanes)===0||qe(h,g),P=N?ose(h,g):gA(h,g,!0),F=N;do{if(P===0){Um&&!N&&Wu(h,g,0,!1);break}else{if(_=h.current.alternate,F&&!ase(_)){P=gA(h,g,!1),F=!1;continue}if(P===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 ge=h;P=Wx;var Oe=ge.current.memoizedState.isDehydrated;if(Oe&&($m(ge,Z).flags|=256),Z=gA(ge,Z,!1),Z!==2){if(cA&&!Oe){ge.errorRecoveryDisabledLanes|=F,Ih|=F,P=4;break e}F=hs,hs=P,F!==null&&(hs===null?hs=F:hs.push.apply(hs,F))}P=Z}if(F=!1,P!==2)continue}}if(P===1){$m(h,0),Wu(h,g,0,!0);break}e:{switch(N=h,F=P,F){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:Wu(N,g,Ds,!$u);break e;case 2:hs=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(P=$v+300-L(),10<P)){if(Wu(N,g,Ds,!$u),Te(N,0,!0)!==0)break e;Tc=g,N.timeoutHandle=wU(W5.bind(null,N,_,hs,Vv,dA,g,Ds,Ih,zm,$u,F,"Throttled",-0,0),P);break e}W5(N,_,hs,Vv,dA,g,Ds,Ih,zm,$u,F,null,-0,0)}}break}while(!0);Sl(h)}function W5(h,g,_,N,P,F,Z,ge,Oe,it,xt,vt,ot,ht){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:fc},F5(g,F,vt);var Xt=(F&62914560)===F?$v-L():(F&4194048)===F?$5-L():0;if(Xt=Hse(vt,Xt),Xt!==null){Tc=F,h.cancelPendingCommit=Xt(eU.bind(null,h,g,F,_,N,P,Z,ge,Oe,xt,vt,null,ot,ht)),Wu(h,F,Z,!it);return}}eU(h,g,F,_,N,P,Z,ge,Oe)}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 P=_[N],F=P.getSnapshot;P=P.value;try{if(!Cs(F(),P))return!1}catch{return!1}}if(_=g.child,g.subtreeFlags&16384&&_!==null)_.return=g,g=_;else{if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function Wu(h,g,_,N){g&=~uA,g&=~Ih,h.suspendedLanes|=g,h.pingedLanes&=~g,N&&(h.warmLanes|=g),N=h.expirationTimes;for(var P=g;0<P;){var F=31-je(P),Z=1<<F;N[F]=-1,P&=~Z}_!==0&&vn(h,_,g)}function Gv(){return(Qn&6)===0?(Kx(0),!1):!0}function pA(){if(Cn!==null){if(nr===0)var h=Cn.return;else h=Cn,xc=Th=null,j2(h),Pm=null,kx=0,h=Cn;for(;h!==null;)S5(h.alternate,h),h=h.return;Cn=null}}function $m(h,g){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,Nse(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),Tc=0,pA(),_r=h,Cn=_=pc(h.current,null),Rn=g,nr=0,Rs=null,$u=!1,Um=qe(h,g),cA=!1,zm=Ds=uA=Ih=Hu=Jr=0,hs=Wx=null,dA=!1,(g&8)!==0&&(g|=g&32);var N=h.entangledLanes;if(N!==0)for(h=h.entanglements,N&=g;0<N;){var P=31-je(N),F=1<<P;g|=h[P],N&=~F}return Ac=g,hv(),_}function q5(h,g){bn=null,K.H=Fx,g===jm||g===vv?(g=cF(),nr=3):g===y2?(g=cF(),nr=4):nr=g===q2?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Rs=g,Cn===null&&(Jr=1,Dv(h,ro(g,h.current)))}function K5(){var h=js.current;return h===null?!0:(Rn&4194048)===Rn?oo===null:(Rn&62914560)===Rn||(Rn&536870912)!==0?h===oo:!1}function X5(){var h=K.H;return K.H=Fx,h===null?Fx:h}function Y5(){var h=K.A;return K.A=rse,h}function Wv(){Jr=4,$u||(Rn&4194048)!==Rn&&js.current!==null||(Um=!0),(Hu&134217727)===0&&(Ih&134217727)===0||_r===null||Wu(_r,Rn,Ds,!1)}function gA(h,g,_){var N=Qn;Qn|=2;var P=X5(),F=Y5();(_r!==h||Rn!==g)&&(Vv=null,$m(h,g)),g=!1;var Z=Jr;e:do try{if(nr!==0&&Cn!==null){var ge=Cn,Oe=Rs;switch(nr){case 8:pA(),Z=6;break e;case 3:case 2:case 9:case 6:js.current===null&&(g=!0);var it=nr;if(nr=0,Rs=null,Hm(h,ge,Oe,it),_&&Um){Z=0;break e}break;default:it=nr,nr=0,Rs=null,Hm(h,ge,Oe,it)}}sse(),Z=Jr;break}catch(xt){q5(h,xt)}while(!0);return g&&h.shellSuspendCounter++,xc=Th=null,Qn=N,K.H=P,K.A=F,Cn===null&&(_r=null,Rn=0,hv()),Z}function sse(){for(;Cn!==null;)Z5(Cn)}function ose(h,g){var _=Qn;Qn|=2;var N=X5(),P=Y5();_r!==h||Rn!==g?(Vv=null,Hv=L()+500,$m(h,g)):Um=qe(h,g);e:do try{if(nr!==0&&Cn!==null){g=Cn;var F=Rs;t:switch(nr){case 1:nr=0,Rs=null,Hm(h,g,F,1);break;case 2:case 9:if(oF(F)){nr=0,Rs=null,Q5(g);break}g=function(){nr!==2&&nr!==9||_r!==h||(nr=7),Sl(h)},F.then(g,g);break e;case 3:nr=7;break e;case 4:nr=5;break e;case 7:oF(F)?(nr=0,Rs=null,Q5(g)):(nr=0,Rs=null,Hm(h,g,F,7));break;case 5:var Z=null;switch(Cn.tag){case 26:Z=Cn.memoizedState;case 5:case 27:var ge=Cn;if(Z?IU(Z):ge.stateNode.complete){nr=0,Rs=null;var Oe=ge.sibling;if(Oe!==null)Cn=Oe;else{var it=ge.return;it!==null?(Cn=it,qv(it)):Cn=null}break t}}nr=0,Rs=null,Hm(h,g,F,5);break;case 6:nr=0,Rs=null,Hm(h,g,F,6);break;case 8:pA(),Jr=6;break e;default:throw Error(r(462))}}lse();break}catch(xt){q5(h,xt)}while(!0);return xc=Th=null,K.H=N,K.A=P,Qn=_,Cn!==null?0:(_r=null,Rn=0,hv(),Jr)}function lse(){for(;Cn!==null&&!ce();)Z5(Cn)}function Z5(h){var g=_5(h.alternate,h,Ac);h.memoizedProps=h.pendingProps,g===null?qv(h):Cn=g}function Q5(h){var g=h,_=g.alternate;switch(g.tag){case 15:case 0:g=p5(_,g,g.pendingProps,g.type,void 0,Rn);break;case 11:g=p5(_,g,g.pendingProps,g.type.render,g.ref,Rn);break;case 5:j2(g);default:S5(_,g),g=Cn=YI(g,Ac),g=_5(_,g,Ac)}h.memoizedProps=h.pendingProps,g===null?qv(h):Cn=g}function Hm(h,g,_,N){xc=Th=null,j2(g),Pm=null,kx=0;var P=g.return;try{if(Yae(h,P,g,_,Rn)){Jr=1,Dv(h,ro(_,h.current)),Cn=null;return}}catch(F){if(P!==null)throw Cn=P,F;Jr=1,Dv(h,ro(_,h.current)),Cn=null;return}g.flags&32768?(In||N===1?h=!0:Um||(Rn&536870912)!==0?h=!1:($u=h=!0,(N===2||N===9||N===3||N===6)&&(N=js.current,N!==null&&N.tag===13&&(N.flags|=16384))),J5(g,h)):qv(g)}function qv(h){var g=h;do{if((g.flags&32768)!==0){J5(g,$u);return}h=g.return;var _=Jae(g.alternate,g,Ac);if(_!==null){Cn=_;return}if(g=g.sibling,g!==null){Cn=g;return}Cn=g=h}while(g!==null);Jr===0&&(Jr=5)}function J5(h,g){do{var _=ese(h.alternate,h);if(_!==null){_.flags&=32767,Cn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!g&&(h=h.sibling,h!==null)){Cn=h;return}Cn=h=_}while(h!==null);Jr=6,Cn=null}function eU(h,g,_,N,P,F,Z,ge,Oe){h.cancelPendingCommit=null;do Kv();while(ki!==0);if((Qn&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(F=g.lanes|g.childLanes,F|=i2,Gt(h,_,F,Z,ge,Oe),h===_r&&(Cn=_r=null,Rn=0),Bm=g,Gu=h,Tc=_,hA=F,fA=P,H5=N,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,hse(se,function(){return aU(),null})):(h.callbackNode=null,h.callbackPriority=0),N=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||N){N=K.T,K.T=null,P=G.p,G.p=2,Z=Qn,Qn|=4;try{tse(h,g,_)}finally{Qn=Z,G.p=P,K.T=N}}ki=1,tU(),nU(),rU()}}function tU(){if(ki===1){ki=0;var h=Gu,g=Bm,_=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||_){_=K.T,K.T=null;var N=G.p;G.p=2;var P=Qn;Qn|=4;try{O5(g,h);var F=TA,Z=BI(h.containerInfo),ge=F.focusedElem,Oe=F.selectionRange;if(Z!==ge&&ge&&ge.ownerDocument&&zI(ge.ownerDocument.documentElement,ge)){if(Oe!==null&&JE(ge)){var it=Oe.start,xt=Oe.end;if(xt===void 0&&(xt=it),"selectionStart"in ge)ge.selectionStart=it,ge.selectionEnd=Math.min(xt,ge.value.length);else{var vt=ge.ownerDocument||document,ot=vt&&vt.defaultView||window;if(ot.getSelection){var ht=ot.getSelection(),Xt=ge.textContent.length,sn=Math.min(Oe.start,Xt),dr=Oe.end===void 0?sn:Math.min(Oe.end,Xt);!ht.extend&&sn>dr&&(Z=dr,dr=sn,sn=Z);var Qe=UI(ge,sn),ze=UI(ge,dr);if(Qe&&ze&&(ht.rangeCount!==1||ht.anchorNode!==Qe.node||ht.anchorOffset!==Qe.offset||ht.focusNode!==ze.node||ht.focusOffset!==ze.offset)){var rt=vt.createRange();rt.setStart(Qe.node,Qe.offset),ht.removeAllRanges(),sn>dr?(ht.addRange(rt),ht.extend(ze.node,ze.offset)):(rt.setEnd(ze.node,ze.offset),ht.addRange(rt))}}}}for(vt=[],ht=ge;ht=ht.parentNode;)ht.nodeType===1&&vt.push({element:ht,left:ht.scrollLeft,top:ht.scrollTop});for(typeof ge.focus=="function"&&ge.focus(),ge=0;ge<vt.length;ge++){var yt=vt[ge];yt.element.scrollLeft=yt.left,yt.element.scrollTop=yt.top}}s_=!!AA,TA=AA=null}finally{Qn=P,G.p=N,K.T=_}}h.current=g,ki=2}}function nU(){if(ki===2){ki=0;var h=Gu,g=Bm,_=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||_){_=K.T,K.T=null;var N=G.p;G.p=2;var P=Qn;Qn|=4;try{k5(h,g.alternate,g)}finally{Qn=P,G.p=N,K.T=_}}ki=3}}function rU(){if(ki===4||ki===3){ki=0,$();var h=Gu,g=Bm,_=Tc,N=H5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?ki=5:(ki=0,Bm=Gu=null,iU(h,h.pendingLanes));var P=h.pendingLanes;if(P===0&&(Vu=null),Et(_),g=g.stateNode,oe&&typeof oe.onCommitFiberRoot=="function")try{oe.onCommitFiberRoot(Je,g,void 0,(g.current.flags&128)===128)}catch{}if(N!==null){g=K.T,P=G.p,G.p=2,K.T=null;try{for(var F=h.onRecoverableError,Z=0;Z<N.length;Z++){var ge=N[Z];F(ge.value,{componentStack:ge.stack})}}finally{K.T=g,G.p=P}}(Tc&3)!==0&&Kv(),Sl(h),P=h.pendingLanes,(_&261930)!==0&&(P&42)!==0?h===mA?qx++:(qx=0,mA=h):qx=0,Kx(0)}}function iU(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Tx(g)))}function Kv(){return tU(),nU(),rU(),aU()}function aU(){if(ki!==5)return!1;var h=Gu,g=hA;hA=0;var _=Et(Tc),N=K.T,P=G.p;try{G.p=32>_?32:_,K.T=null,_=fA,fA=null;var F=Gu,Z=Tc;if(ki=0,Bm=Gu=null,Tc=0,(Qn&6)!==0)throw Error(r(331));var ge=Qn;if(Qn|=4,z5(F.current),I5(F,F.current,Z,_),Qn=ge,Kx(0,!1),oe&&typeof oe.onPostCommitFiberRoot=="function")try{oe.onPostCommitFiberRoot(Je,F)}catch{}return!0}finally{G.p=P,K.T=N,iU(h,g)}}function sU(h,g,_){g=ro(_,g),g=W2(h.stateNode,g,2),h=Fu(h,g,2),h!==null&&(ln(h,2),Sl(h))}function rr(h,g,_){if(h.tag===3)sU(h,h,_);else for(;g!==null;){if(g.tag===3){sU(g,h,_);break}else if(g.tag===1){var N=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(Vu===null||!Vu.has(N))){h=ro(_,h),_=o5(2),N=Fu(g,_,2),N!==null&&(l5(_,N,g,h),ln(N,2),Sl(N));break}}g=g.return}}function xA(h,g,_){var N=h.pingCache;if(N===null){N=h.pingCache=new ise;var P=new Set;N.set(g,P)}else P=N.get(g),P===void 0&&(P=new Set,N.set(g,P));P.has(_)||(cA=!0,P.add(_),h=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&=~_,_r===h&&(Rn&_)===_&&(Jr===4||Jr===3&&(Rn&62914560)===Rn&&300>L()-$v?(Qn&2)===0&&$m(h,0):uA|=_,zm===Rn&&(zm=0)),Sl(h)}function oU(h,g){g===0&&(g=Pt()),h=Nh(h,g),h!==null&&(ln(h,g),Sl(h))}function use(h){var g=h.memoizedState,_=0;g!==null&&(_=g.retryLane),oU(h,_)}function dse(h,g){var _=0;switch(h.tag){case 31:case 13:var N=h.stateNode,P=h.memoizedState;P!==null&&(_=P.retryLane);break;case 19:N=h.stateNode;break;case 22:N=h.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(g),oU(h,_)}function hse(h,g){return Ae(h,g)}var Xv=null,Vm=null,bA=!1,Yv=!1,yA=!1,qu=0;function Sl(h){h!==Vm&&h.next===null&&(Vm===null?Xv=Vm=h:Vm=Vm.next=h),Yv=!0,bA||(bA=!0,mse())}function Kx(h,g){if(!yA&&Yv){yA=!0;do for(var _=!1,N=Xv;N!==null;){if(h!==0){var P=N.pendingLanes;if(P===0)var F=0;else{var Z=N.suspendedLanes,ge=N.pingedLanes;F=(1<<31-je(42|h)+1)-1,F&=P&~(Z&~ge),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(_=!0,dU(N,F))}else F=Rn,F=Te(N,N===_r?F:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(F&3)===0||qe(N,F)||(_=!0,dU(N,F));N=N.next}while(_);yA=!1}}function fse(){lU()}function lU(){Yv=bA=!1;var h=0;qu!==0&&Mse()&&(h=qu);for(var g=L(),_=null,N=Xv;N!==null;){var P=N.next,F=cU(N,g);F===0?(N.next=null,_===null?Xv=P:_.next=P,P===null&&(Vm=_)):(_=N,(h!==0||(F&3)!==0)&&(Yv=!0)),N=P}ki!==0&&ki!==5||Kx(h),qu!==0&&(qu=0)}function cU(h,g){for(var _=h.suspendedLanes,N=h.pingedLanes,P=h.expirationTimes,F=h.pendingLanes&-62914561;0<F;){var Z=31-je(F),ge=1<<Z,Oe=P[Z];Oe===-1?((ge&_)===0||(ge&N)!==0)&&(P[Z]=bt(ge,g)):Oe<=g&&(h.expiredLanes|=ge),F&=~ge}if(g=_r,_=Rn,_=Te(h,h===g?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N=h.callbackNode,_===0||h===g&&(nr===2||nr===9)||h.cancelPendingCommit!==null)return N!==null&&N!==null&&Ie(N),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||qe(h,_)){if(g=_&-_,g===h.callbackPriority)return g;switch(N!==null&&Ie(N),Et(_)){case 2:case 8:_=Se;break;case 32:_=se;break;case 268435456:_=Re;break;default:_=se}return N=uU.bind(null,h),_=Ae(_,N),h.callbackPriority=g,h.callbackNode=_,g}return N!==null&&N!==null&&Ie(N),h.callbackPriority=2,h.callbackNode=null,2}function uU(h,g){if(ki!==0&&ki!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(Kv()&&h.callbackNode!==_)return null;var N=Rn;return N=Te(h,h===_r?N:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N===0?null:(G5(h,N,g),cU(h,L()),h.callbackNode!=null&&h.callbackNode===_?uU.bind(null,h):null)}function dU(h,g){if(Kv())return null;G5(h,g,!0)}function mse(){Ese(function(){(Qn&6)!==0?Ae(be,fse):lU()})}function vA(){if(qu===0){var h=Cm;h===0&&(h=ke,ke<<=1,(ke&261888)===0&&(ke=256)),qu=h}return qu}function hU(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:iv(""+h)}function fU(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,P){if(g==="submit"&&_&&_.stateNode===P){var F=hU((P[yr]||null).action),Z=N.submitter;Z&&(g=(g=Z[yr]||null)?hU(g.formAction):Z.getAttribute("formAction"),g!==null&&(F=g,Z=null));var ge=new lv("action","action",null,N,P);h.push({event:ge,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(qu!==0){var Oe=Z?fU(P,Z):new FormData(P);z2(_,{pending:!0,data:Oe,method:P.method,action:F},null,Oe)}}else typeof F=="function"&&(ge.preventDefault(),Oe=Z?fU(P,Z):new FormData(P),z2(_,{pending:!0,data:Oe,method:P.method,action:F},F,Oe))},currentTarget:P}]})}}for(var _A=0;_A<r2.length;_A++){var wA=r2[_A],gse=wA.toLowerCase(),xse=wA[0].toUpperCase()+wA.slice(1);$o(gse,"on"+xse)}$o(VI,"onAnimationEnd"),$o(GI,"onAnimationIteration"),$o(WI,"onAnimationStart"),$o("dblclick","onDoubleClick"),$o("focusin","onFocus"),$o("focusout","onBlur"),$o(Rae,"onTransitionRun"),$o(Dae,"onTransitionStart"),$o(Oae,"onTransitionCancel"),$o(qI,"onTransitionEnd"),Ge("onMouseEnter",["mouseout","mouseover"]),Ge("onMouseLeave",["mouseout","mouseover"]),Ge("onPointerEnter",["pointerout","pointerover"]),Ge("onPointerLeave",["pointerout","pointerover"]),Ze("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ze("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ze("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ze("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ze("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ze("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xx="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),bse=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Xx));function mU(h,g){g=(g&4)!==0;for(var _=0;_<h.length;_++){var N=h[_],P=N.event;N=N.listeners;e:{var F=void 0;if(g)for(var Z=N.length-1;0<=Z;Z--){var ge=N[Z],Oe=ge.instance,it=ge.currentTarget;if(ge=ge.listener,Oe!==F&&P.isPropagationStopped())break e;F=ge,P.currentTarget=it;try{F(P)}catch(xt){dv(xt)}P.currentTarget=null,F=Oe}else for(Z=0;Z<N.length;Z++){if(ge=N[Z],Oe=ge.instance,it=ge.currentTarget,ge=ge.listener,Oe!==F&&P.isPropagationStopped())break e;F=ge,P.currentTarget=it;try{F(P)}catch(xt){dv(xt)}P.currentTarget=null,F=Oe}}}}function kn(h,g){var _=g[lr];_===void 0&&(_=g[lr]=new Set);var N=h+"__bubble";_.has(N)||(pU(g,h,2,!1),_.add(N))}function SA(h,g,_){var N=0;g&&(N|=4),pU(_,h,N,g)}var Zv="_reactListening"+Math.random().toString(36).slice(2);function MA(h){if(!h[Zv]){h[Zv]=!0,De.forEach(function(_){_!=="selectionchange"&&(bse.has(_)||SA(_,!1,h),SA(_,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[Zv]||(g[Zv]=!0,SA("selectionchange",!1,g))}}function pU(h,g,_,N){switch(VU(g)){case 2:var P=Wse;break;case 8:P=qse;break;default:P=UA}_=P.bind(null,g,_,h),P=void 0,!VE||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(P=!0),N?P!==void 0?h.addEventListener(g,_,{capture:!0,passive:P}):h.addEventListener(g,_,!0):P!==void 0?h.addEventListener(g,_,{passive:P}):h.addEventListener(g,_,!1)}function NA(h,g,_,N,P){var F=N;if((g&1)===0&&(g&2)===0&&N!==null)e:for(;;){if(N===null)return;var Z=N.tag;if(Z===3||Z===4){var ge=N.stateNode.containerInfo;if(ge===P)break;if(Z===4)for(Z=N.return;Z!==null;){var Oe=Z.tag;if((Oe===3||Oe===4)&&Z.stateNode.containerInfo===P)return;Z=Z.return}for(;ge!==null;){if(Z=Ct(ge),Z===null)return;if(Oe=Z.tag,Oe===5||Oe===6||Oe===26||Oe===27){N=F=Z;continue e}ge=ge.parentNode}}N=N.return}vI(function(){var it=F,xt=$E(_),vt=[];e:{var ot=KI.get(h);if(ot!==void 0){var ht=lv,Xt=h;switch(h){case"keypress":if(sv(_)===0)break e;case"keydown":case"keyup":ht=dae;break;case"focusin":Xt="focus",ht=KE;break;case"focusout":Xt="blur",ht=KE;break;case"beforeblur":case"afterblur":ht=KE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ht=SI;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ht=Jie;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ht=mae;break;case VI:case GI:case WI:ht=nae;break;case qI:ht=gae;break;case"scroll":case"scrollend":ht=Zie;break;case"wheel":ht=bae;break;case"copy":case"cut":case"paste":ht=iae;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ht=NI;break;case"toggle":case"beforetoggle":ht=vae}var sn=(g&4)!==0,dr=!sn&&(h==="scroll"||h==="scrollend"),Qe=sn?ot!==null?ot+"Capture":null:ot;sn=[];for(var ze=it,rt;ze!==null;){var yt=ze;if(rt=yt.stateNode,yt=yt.tag,yt!==5&&yt!==26&&yt!==27||rt===null||Qe===null||(yt=xx(ze,Qe),yt!=null&&sn.push(Yx(ze,yt,rt))),dr)break;ze=ze.return}0<sn.length&&(ot=new ht(ot,Xt,null,_,xt),vt.push({event:ot,listeners:sn}))}}if((g&7)===0){e:{if(ot=h==="mouseover"||h==="pointerover",ht=h==="mouseout"||h==="pointerout",ot&&_!==BE&&(Xt=_.relatedTarget||_.fromElement)&&(Ct(Xt)||Xt[xi]))break e;if((ht||ot)&&(ot=xt.window===xt?xt:(ot=xt.ownerDocument)?ot.defaultView||ot.parentWindow:window,ht?(Xt=_.relatedTarget||_.toElement,ht=it,Xt=Xt?Ct(Xt):null,Xt!==null&&(dr=a(Xt),sn=Xt.tag,Xt!==dr||sn!==5&&sn!==27&&sn!==6)&&(Xt=null)):(ht=null,Xt=it),ht!==Xt)){if(sn=SI,yt="onMouseLeave",Qe="onMouseEnter",ze="mouse",(h==="pointerout"||h==="pointerover")&&(sn=NI,yt="onPointerLeave",Qe="onPointerEnter",ze="pointer"),dr=ht==null?ot:Yt(ht),rt=Xt==null?ot:Yt(Xt),ot=new sn(yt,ze+"leave",ht,_,xt),ot.target=dr,ot.relatedTarget=rt,yt=null,Ct(xt)===it&&(sn=new sn(Qe,ze+"enter",Xt,_,xt),sn.target=rt,sn.relatedTarget=dr,yt=sn),dr=yt,ht&&Xt)t:{for(sn=yse,Qe=ht,ze=Xt,rt=0,yt=Qe;yt;yt=sn(yt))rt++;yt=0;for(var en=ze;en;en=sn(en))yt++;for(;0<rt-yt;)Qe=sn(Qe),rt--;for(;0<yt-rt;)ze=sn(ze),yt--;for(;rt--;){if(Qe===ze||ze!==null&&Qe===ze.alternate){sn=Qe;break t}Qe=sn(Qe),ze=sn(ze)}sn=null}else sn=null;ht!==null&&gU(vt,ot,ht,sn,!1),Xt!==null&&dr!==null&&gU(vt,dr,Xt,sn,!0)}}e:{if(ot=it?Yt(it):window,ht=ot.nodeName&&ot.nodeName.toLowerCase(),ht==="select"||ht==="input"&&ot.type==="file")var Wn=RI;else if(jI(ot))if(DI)Wn=kae;else{Wn=Tae;var Qt=Aae}else ht=ot.nodeName,!ht||ht.toLowerCase()!=="input"||ot.type!=="checkbox"&&ot.type!=="radio"?it&&Cr(it.elementType)&&(Wn=RI):Wn=Cae;if(Wn&&(Wn=Wn(h,it))){PI(vt,Wn,_,xt);break e}Qt&&Qt(h,ot,it),h==="focusout"&&it&&ot.type==="number"&&it.memoizedProps.value!=null&&Lr(ot,"number",ot.value)}switch(Qt=it?Yt(it):window,h){case"focusin":(jI(Qt)||Qt.contentEditable==="true")&&(_m=Qt,e2=it,Nx=null);break;case"focusout":Nx=e2=_m=null;break;case"mousedown":t2=!0;break;case"contextmenu":case"mouseup":case"dragend":t2=!1,$I(vt,_,xt);break;case"selectionchange":if(Pae)break;case"keydown":case"keyup":$I(vt,_,xt)}var yn;if(YE)e:{switch(h){case"compositionstart":var Dn="onCompositionStart";break e;case"compositionend":Dn="onCompositionEnd";break e;case"compositionupdate":Dn="onCompositionUpdate";break e}Dn=void 0}else vm?CI(h,_)&&(Dn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Dn="onCompositionStart");Dn&&(EI&&_.locale!=="ko"&&(vm||Dn!=="onCompositionStart"?Dn==="onCompositionEnd"&&vm&&(yn=_I()):(ju=xt,GE="value"in ju?ju.value:ju.textContent,vm=!0)),Qt=Qv(it,Dn),0<Qt.length&&(Dn=new MI(Dn,h,null,_,xt),vt.push({event:Dn,listeners:Qt}),yn?Dn.data=yn:(yn=kI(_),yn!==null&&(Dn.data=yn)))),(yn=wae?Sae(h,_):Mae(h,_))&&(Dn=Qv(it,"onBeforeInput"),0<Dn.length&&(Qt=new MI("onBeforeInput","beforeinput",null,_,xt),vt.push({event:Qt,listeners:Dn}),Qt.data=yn)),pse(vt,h,it,_,xt)}mU(vt,g)})}function Yx(h,g,_){return{instance:h,listener:g,currentTarget:_}}function Qv(h,g){for(var _=g+"Capture",N=[];h!==null;){var P=h,F=P.stateNode;if(P=P.tag,P!==5&&P!==26&&P!==27||F===null||(P=xx(h,_),P!=null&&N.unshift(Yx(h,P,F)),P=xx(h,g),P!=null&&N.push(Yx(h,P,F))),h.tag===3)return N;h=h.return}return[]}function yse(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function gU(h,g,_,N,P){for(var F=g._reactName,Z=[];_!==null&&_!==N;){var ge=_,Oe=ge.alternate,it=ge.stateNode;if(ge=ge.tag,Oe!==null&&Oe===N)break;ge!==5&&ge!==26&&ge!==27||it===null||(Oe=it,P?(it=xx(_,F),it!=null&&Z.unshift(Yx(_,it,Oe))):P||(it=xx(_,F),it!=null&&Z.push(Yx(_,it,Oe)))),_=_.return}Z.length!==0&&h.push({event:g,listeners:Z})}var vse=/\r\n?/g,_se=/\u0000|\uFFFD/g;function xU(h){return(typeof h=="string"?h:""+h).replace(vse,`
- `).replace(_se,"")}function bU(h,g){return g=xU(g),xU(h)===g}function ur(h,g,_,N,P,F){switch(_){case"children":typeof N=="string"?g==="body"||g==="textarea"&&N===""||vr(h,N):(typeof N=="number"||typeof N=="bigint")&&g!=="body"&&vr(h,""+N);break;case"className":Le(h,"class",N);break;case"tabIndex":Le(h,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":Le(h,_,N);break;case"style":to(h,N,F);break;case"data":if(g!=="object"){Le(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=iv(""+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",P.name,P,null),ur(h,g,"formEncType",P.formEncType,P,null),ur(h,g,"formMethod",P.formMethod,P,null),ur(h,g,"formTarget",P.formTarget,P,null)):(ur(h,g,"encType",P.encType,P,null),ur(h,g,"method",P.method,P,null),ur(h,g,"target",P.target,P,null)));if(N==null||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(_);break}N=iv(""+N),h.setAttribute(_,N);break;case"onClick":N!=null&&(h.onclick=fc);break;case"onScroll":N!=null&&kn("scroll",h);break;case"onScrollEnd":N!=null&&kn("scrollend",h);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=N&&typeof N!="function"&&typeof N!="symbol";break;case"muted":h.muted=N&&typeof N!="function"&&typeof N!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(N==null||typeof N=="function"||typeof N=="boolean"||typeof N=="symbol"){h.removeAttribute("xlink:href");break}_=iv(""+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":kn("beforetoggle",h),kn("toggle",h),Ut(h,"popover",N);break;case"xlinkActuate":pt(h,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":pt(h,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":pt(h,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":pt(h,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":pt(h,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":pt(h,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":pt(h,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":pt(h,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":pt(h,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":Ut(h,"is",N);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=Xie.get(_)||_,Ut(h,_,N))}}function EA(h,g,_,N,P,F){switch(_){case"style":to(h,N,F);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(_=N.__html,_!=null){if(P.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof N=="string"?vr(h,N):(typeof N=="number"||typeof N=="bigint")&&vr(h,""+N);break;case"onScroll":N!=null&&kn("scroll",h);break;case"onScrollEnd":N!=null&&kn("scrollend",h);break;case"onClick":N!=null&&(h.onclick=fc);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!We.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(P=_.endsWith("Capture"),g=_.slice(2,P?_.length-7:void 0),F=h[yr]||null,F=F!=null?F[_]:null,typeof F=="function"&&h.removeEventListener(g,F,P),typeof N=="function")){typeof F!="function"&&F!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(g,N,P);break e}_ in h?h[_]=N:N===!0?h.setAttribute(_,""):Ut(h,_,N)}}}function fa(h,g,_){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":kn("error",h),kn("load",h);var N=!1,P=!1,F;for(F in _)if(_.hasOwnProperty(F)){var Z=_[F];if(Z!=null)switch(F){case"src":N=!0;break;case"srcSet":P=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:ur(h,g,F,Z,_,null)}}P&&ur(h,g,"srcSet",_.srcSet,_,null),N&&ur(h,g,"src",_.src,_,null);return;case"input":kn("invalid",h);var ge=F=Z=P=null,Oe=null,it=null;for(N in _)if(_.hasOwnProperty(N)){var xt=_[N];if(xt!=null)switch(N){case"name":P=xt;break;case"type":Z=xt;break;case"checked":Oe=xt;break;case"defaultChecked":it=xt;break;case"value":F=xt;break;case"defaultValue":ge=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(r(137,g));break;default:ur(h,g,N,xt,_,null)}}Zr(h,F,ge,Oe,it,Z,P,!1);return;case"select":kn("invalid",h),N=Z=F=null;for(P in _)if(_.hasOwnProperty(P)&&(ge=_[P],ge!=null))switch(P){case"value":F=ge;break;case"defaultValue":Z=ge;break;case"multiple":N=ge;default:ur(h,g,P,ge,_,null)}g=F,_=Z,h.multiple=!!N,g!=null?ca(h,!!N,g,!1):_!=null&&ca(h,!!N,_,!0);return;case"textarea":kn("invalid",h),F=P=N=null;for(Z in _)if(_.hasOwnProperty(Z)&&(ge=_[Z],ge!=null))switch(Z){case"value":N=ge;break;case"defaultValue":P=ge;break;case"children":F=ge;break;case"dangerouslySetInnerHTML":if(ge!=null)throw Error(r(91));break;default:ur(h,g,Z,ge,_,null)}di(h,N,P,F);return;case"option":for(Oe in _)_.hasOwnProperty(Oe)&&(N=_[Oe],N!=null)&&(Oe==="selected"?h.selected=N&&typeof N!="function"&&typeof N!="symbol":ur(h,g,Oe,N,_,null));return;case"dialog":kn("beforetoggle",h),kn("toggle",h),kn("cancel",h),kn("close",h);break;case"iframe":case"object":kn("load",h);break;case"video":case"audio":for(N=0;N<Xx.length;N++)kn(Xx[N],h);break;case"image":kn("error",h),kn("load",h);break;case"details":kn("toggle",h);break;case"embed":case"source":case"link":kn("error",h),kn("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(Cr(g)){for(xt in _)_.hasOwnProperty(xt)&&(N=_[xt],N!==void 0&&EA(h,g,xt,N,_,void 0));return}}for(ge in _)_.hasOwnProperty(ge)&&(N=_[ge],N!=null&&ur(h,g,ge,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 P=null,F=null,Z=null,ge=null,Oe=null,it=null,xt=null;for(ht in _){var vt=_[ht];if(_.hasOwnProperty(ht)&&vt!=null)switch(ht){case"checked":break;case"value":break;case"defaultValue":Oe=vt;default:N.hasOwnProperty(ht)||ur(h,g,ht,null,N,vt)}}for(var ot in N){var ht=N[ot];if(vt=_[ot],N.hasOwnProperty(ot)&&(ht!=null||vt!=null))switch(ot){case"type":F=ht;break;case"name":P=ht;break;case"checked":it=ht;break;case"defaultChecked":xt=ht;break;case"value":Z=ht;break;case"defaultValue":ge=ht;break;case"children":case"dangerouslySetInnerHTML":if(ht!=null)throw Error(r(137,g));break;default:ht!==vt&&ur(h,g,ot,ht,N,vt)}}nn(h,Z,ge,Oe,it,xt,F,P);return;case"select":ht=Z=ge=ot=null;for(F in _)if(Oe=_[F],_.hasOwnProperty(F)&&Oe!=null)switch(F){case"value":break;case"multiple":ht=Oe;default:N.hasOwnProperty(F)||ur(h,g,F,null,N,Oe)}for(P in N)if(F=N[P],Oe=_[P],N.hasOwnProperty(P)&&(F!=null||Oe!=null))switch(P){case"value":ot=F;break;case"defaultValue":ge=F;break;case"multiple":Z=F;default:F!==Oe&&ur(h,g,P,F,N,Oe)}g=ge,_=Z,N=ht,ot!=null?ca(h,!!_,ot,!1):!!N!=!!_&&(g!=null?ca(h,!!_,g,!0):ca(h,!!_,_?[]:"",!1));return;case"textarea":ht=ot=null;for(ge in _)if(P=_[ge],_.hasOwnProperty(ge)&&P!=null&&!N.hasOwnProperty(ge))switch(ge){case"value":break;case"children":break;default:ur(h,g,ge,null,N,P)}for(Z in N)if(P=N[Z],F=_[Z],N.hasOwnProperty(Z)&&(P!=null||F!=null))switch(Z){case"value":ot=P;break;case"defaultValue":ht=P;break;case"children":break;case"dangerouslySetInnerHTML":if(P!=null)throw Error(r(91));break;default:P!==F&&ur(h,g,Z,P,N,F)}$n(h,ot,ht);return;case"option":for(var Xt in _)ot=_[Xt],_.hasOwnProperty(Xt)&&ot!=null&&!N.hasOwnProperty(Xt)&&(Xt==="selected"?h.selected=!1:ur(h,g,Xt,null,N,ot));for(Oe in N)ot=N[Oe],ht=_[Oe],N.hasOwnProperty(Oe)&&ot!==ht&&(ot!=null||ht!=null)&&(Oe==="selected"?h.selected=ot&&typeof ot!="function"&&typeof ot!="symbol":ur(h,g,Oe,ot,N,ht));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var sn in _)ot=_[sn],_.hasOwnProperty(sn)&&ot!=null&&!N.hasOwnProperty(sn)&&ur(h,g,sn,null,N,ot);for(it in N)if(ot=N[it],ht=_[it],N.hasOwnProperty(it)&&ot!==ht&&(ot!=null||ht!=null))switch(it){case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,g));break;default:ur(h,g,it,ot,N,ht)}return;default:if(Cr(g)){for(var dr in _)ot=_[dr],_.hasOwnProperty(dr)&&ot!==void 0&&!N.hasOwnProperty(dr)&&EA(h,g,dr,void 0,N,ot);for(xt in N)ot=N[xt],ht=_[xt],!N.hasOwnProperty(xt)||ot===ht||ot===void 0&&ht===void 0||EA(h,g,xt,ot,N,ht);return}}for(var Qe in _)ot=_[Qe],_.hasOwnProperty(Qe)&&ot!=null&&!N.hasOwnProperty(Qe)&&ur(h,g,Qe,null,N,ot);for(vt in N)ot=N[vt],ht=_[vt],!N.hasOwnProperty(vt)||ot===ht||ot==null&&ht==null||ur(h,g,vt,ot,N,ht)}function yU(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 P=_[N],F=P.transferSize,Z=P.initiatorType,ge=P.duration;if(F&&ge&&yU(Z)){for(Z=0,ge=P.responseEnd,N+=1;N<_.length;N++){var Oe=_[N],it=Oe.startTime;if(it>ge)break;var xt=Oe.transferSize,vt=Oe.initiatorType;xt&&yU(vt)&&(Oe=Oe.responseEnd,Z+=xt*(Oe<ge?1:(ge-it)/(Oe-it)))}if(--N,g+=8*(F+Z)/(P.duration/1e3),h++,10<h)break}}if(0<h)return g/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var AA=null,TA=null;function Jv(h){return h.nodeType===9?h:h.ownerDocument}function vU(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 _U(h,g){if(h===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&g==="foreignObject"?0:h}function CA(h,g){return h==="textarea"||h==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var kA=null;function Mse(){var h=window.event;return h&&h.type==="popstate"?h===kA?!1:(kA=h,!0):(kA=null,!1)}var wU=typeof setTimeout=="function"?setTimeout:void 0,Nse=typeof clearTimeout=="function"?clearTimeout:void 0,SU=typeof Promise=="function"?Promise:void 0,Ese=typeof queueMicrotask=="function"?queueMicrotask:typeof SU<"u"?function(h){return SU.resolve(null).then(h).catch(Ase)}:wU;function Ase(h){setTimeout(function(){throw h})}function Ku(h){return h==="head"}function MU(h,g){var _=g,N=0;do{var P=_.nextSibling;if(h.removeChild(_),P&&P.nodeType===8)if(_=P.data,_==="/$"||_==="/&"){if(N===0){h.removeChild(P),Km(g);return}N--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")N++;else if(_==="html")Zx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Zx(_);for(var F=_.firstChild;F;){var Z=F.nextSibling,ge=F.nodeName;F[ct]||ge==="SCRIPT"||ge==="STYLE"||ge==="LINK"&&F.rel.toLowerCase()==="stylesheet"||_.removeChild(F),F=Z}}else _==="body"&&Zx(h.ownerDocument.body);_=P}while(_);Km(g)}function NU(h,g){var _=h;h=0;do{var N=_.nextSibling;if(_.nodeType===1?g?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(g?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),N&&N.nodeType===8)if(_=N.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=N}while(_)}function jA(h){var g=h.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var _=g;switch(g=g.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":jA(_),st(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Tse(h,g,_,N){for(;h.nodeType===1;){var P=_;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!N&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(N){if(!h[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!==P.rel||h.getAttribute("href")!==(P.href==null||P.href===""?null:P.href)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin)||h.getAttribute("title")!==(P.title==null?null:P.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(F=h.getAttribute("src"),(F!==(P.src==null?null:P.src)||h.getAttribute("type")!==(P.type==null?null:P.type)||h.getAttribute("crossorigin")!==(P.crossOrigin==null?null:P.crossOrigin))&&F&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var F=P.name==null?null:""+P.name;if(P.type==="hidden"&&h.getAttribute("name")===F)return h}else return h;if(h=lo(h.nextSibling),h===null)break}return null}function Cse(h,g,_){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=lo(h.nextSibling),h===null))return null;return h}function EU(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=lo(h.nextSibling),h===null))return null;return h}function PA(h){return h.data==="$?"||h.data==="$~"}function RA(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function 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 lo(h){for(;h!=null;h=h.nextSibling){var g=h.nodeType;if(g===1||g===3)break;if(g===8){if(g=h.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return h}var DA=null;function AU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(g===0)return lo(h.nextSibling);g--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||g++}h=h.nextSibling}return null}function TU(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 CU(h,g,_){switch(g=Jv(_),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 Zx(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);st(h)}var co=new Map,kU=new Set;function e_(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var Cc=G.d;G.d={f:jse,r:Pse,D:Rse,C:Dse,L:Ose,m:Lse,X:Fse,S:Ise,M:Use};function jse(){var h=Cc.f(),g=Gv();return h||g}function Pse(h){var g=Ft(h);g!==null&&g.tag===5&&g.type==="form"?qF(g):Cc.r(h)}var Gm=typeof document>"u"?null:document;function jU(h,g,_){var N=Gm;if(N&&typeof g=="string"&&g){var P=At(g);P='link[rel="'+h+'"][href="'+P+'"]',typeof _=="string"&&(P+='[crossorigin="'+_+'"]'),kU.has(P)||(kU.add(P),h={rel:h,crossOrigin:_,href:g},N.querySelector(P)===null&&(g=N.createElement("link"),fa(g,"link",h),de(g),N.head.appendChild(g)))}}function Rse(h){Cc.D(h),jU("dns-prefetch",h,null)}function Dse(h,g){Cc.C(h,g),jU("preconnect",h,g)}function Ose(h,g,_){Cc.L(h,g,_);var N=Gm;if(N&&h&&g){var P='link[rel="preload"][as="'+At(g)+'"]';g==="image"&&_&&_.imageSrcSet?(P+='[imagesrcset="'+At(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(P+='[imagesizes="'+At(_.imageSizes)+'"]')):P+='[href="'+At(h)+'"]';var F=P;switch(g){case"style":F=Wm(h);break;case"script":F=qm(h)}co.has(F)||(h=f({rel:"preload",href:g==="image"&&_&&_.imageSrcSet?void 0:h,as:g},_),co.set(F,h),N.querySelector(P)!==null||g==="style"&&N.querySelector(Qx(F))||g==="script"&&N.querySelector(Jx(F))||(g=N.createElement("link"),fa(g,"link",h),de(g),N.head.appendChild(g)))}}function Lse(h,g){Cc.m(h,g);var _=Gm;if(_&&h){var N=g&&typeof g.as=="string"?g.as:"script",P='link[rel="modulepreload"][as="'+At(N)+'"][href="'+At(h)+'"]',F=P;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":F=qm(h)}if(!co.has(F)&&(h=f({rel:"modulepreload",href:h},g),co.set(F,h),_.querySelector(P)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Jx(F)))return}N=_.createElement("link"),fa(N,"link",h),de(N),_.head.appendChild(N)}}}function Ise(h,g,_){Cc.S(h,g,_);var N=Gm;if(N&&h){var P=Zt(N).hoistableStyles,F=Wm(h);g=g||"default";var Z=P.get(F);if(!Z){var ge={loading:0,preload:null};if(Z=N.querySelector(Qx(F)))ge.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},_),(_=co.get(F))&&OA(h,_);var Oe=Z=N.createElement("link");de(Oe),fa(Oe,"link",h),Oe._p=new Promise(function(it,xt){Oe.onload=it,Oe.onerror=xt}),Oe.addEventListener("load",function(){ge.loading|=1}),Oe.addEventListener("error",function(){ge.loading|=2}),ge.loading|=4,t_(Z,g,N)}Z={type:"stylesheet",instance:Z,count:1,state:ge},P.set(F,Z)}}}function Fse(h,g){Cc.X(h,g);var _=Gm;if(_&&h){var N=Zt(_).hoistableScripts,P=qm(h),F=N.get(P);F||(F=_.querySelector(Jx(P)),F||(h=f({src:h,async:!0},g),(g=co.get(P))&&LA(h,g),F=_.createElement("script"),de(F),fa(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},N.set(P,F))}}function Use(h,g){Cc.M(h,g);var _=Gm;if(_&&h){var N=Zt(_).hoistableScripts,P=qm(h),F=N.get(P);F||(F=_.querySelector(Jx(P)),F||(h=f({src:h,async:!0,type:"module"},g),(g=co.get(P))&&LA(h,g),F=_.createElement("script"),de(F),fa(F,"link",h),_.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},N.set(P,F))}}function PU(h,g,_,N){var P=(P=pe.current)?e_(P):null;if(!P)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(g=Wm(_.href),_=Zt(P).hoistableStyles,N=_.get(g),N||(N={type:"style",instance:null,count:0,state:null},_.set(g,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=Wm(_.href);var F=Zt(P).hoistableStyles,Z=F.get(h);if(Z||(P=P.ownerDocument||P,Z={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},F.set(h,Z),(F=P.querySelector(Qx(h)))&&!F._p&&(Z.instance=F,Z.state.loading=5),co.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},co.set(h,_),F||zse(P,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=qm(_),_=Zt(P).hoistableScripts,N=_.get(g),N||(N={type:"script",instance:null,count:0,state:null},_.set(g,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function Wm(h){return'href="'+At(h)+'"'}function Qx(h){return'link[rel="stylesheet"]['+h+"]"}function RU(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}),fa(g,"link",_),de(g),h.head.appendChild(g))}function qm(h){return'[src="'+At(h)+'"]'}function Jx(h){return"script[async]"+h}function DU(h,g,_){if(g.count++,g.instance===null)switch(g.type){case"style":var N=h.querySelector('style[data-href~="'+At(_.href)+'"]');if(N)return g.instance=N,de(N),N;var P=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return N=(h.ownerDocument||h).createElement("style"),de(N),fa(N,"style",P),t_(N,_.precedence,h),g.instance=N;case"stylesheet":P=Wm(_.href);var F=h.querySelector(Qx(P));if(F)return g.state.loading|=4,g.instance=F,de(F),F;N=RU(_),(P=co.get(P))&&OA(N,P),F=(h.ownerDocument||h).createElement("link"),de(F);var Z=F;return Z._p=new Promise(function(ge,Oe){Z.onload=ge,Z.onerror=Oe}),fa(F,"link",N),g.state.loading|=4,t_(F,_.precedence,h),g.instance=F;case"script":return F=qm(_.src),(P=h.querySelector(Jx(F)))?(g.instance=P,de(P),P):(N=_,(P=co.get(F))&&(N=f({},_),LA(N,P)),h=h.ownerDocument||h,P=h.createElement("script"),de(P),fa(P,"link",N),h.head.appendChild(P),g.instance=P);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(N=g.instance,g.state.loading|=4,t_(N,_.precedence,h));return g.instance}function t_(h,g,_){for(var N=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),P=N.length?N[N.length-1]:null,F=P,Z=0;Z<N.length;Z++){var ge=N[Z];if(ge.dataset.precedence===g)F=ge;else if(F!==P)break}F?F.parentNode.insertBefore(h,F.nextSibling):(g=_.nodeType===9?_.head:_,g.insertBefore(h,g.firstChild))}function OA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function LA(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var n_=null;function OU(h,g,_){if(n_===null){var N=new Map,P=n_=new Map;P.set(_,N)}else P=n_,N=P.get(_),N||(N=new Map,P.set(_,N));if(N.has(h))return N;for(N.set(h,null),_=_.getElementsByTagName(h),P=0;P<_.length;P++){var F=_[P];if(!(F[ct]||F[tn]||h==="link"&&F.getAttribute("rel")==="stylesheet")&&F.namespaceURI!=="http://www.w3.org/2000/svg"){var Z=F.getAttribute(g)||"";Z=h+Z;var ge=N.get(Z);ge?ge.push(F):N.set(Z,[F])}}return N}function LU(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 IU(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 P=Wm(N.href),F=g.querySelector(Qx(P));if(F){g=F._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=r_.bind(h),g.then(h,h)),_.state.loading|=4,_.instance=F,de(F);return}F=g.ownerDocument||g,N=RU(N),(P=co.get(P))&&OA(N,P),F=F.createElement("link"),de(F);var Z=F;Z._p=new Promise(function(ge,Oe){Z.onload=ge,Z.onerror=Oe}),fa(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++,_=r_.bind(h),g.addEventListener("load",_),g.addEventListener("error",_))}}var IA=0;function Hse(h,g){return h.stylesheets&&h.count===0&&a_(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var N=setTimeout(function(){if(h.stylesheets&&a_(h,h.stylesheets),h.unsuspend){var F=h.unsuspend;h.unsuspend=null,F()}},6e4+g);0<h.imgBytes&&IA===0&&(IA=62500*Sse());var P=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&a_(h,h.stylesheets),h.unsuspend)){var F=h.unsuspend;h.unsuspend=null,F()}},(h.imgBytes>IA?50:800)+g);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(N),clearTimeout(P)}}:null}function r_(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)a_(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var i_=null;function a_(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,i_=new Map,g.forEach(Vse,h),i_=null,r_.call(h))}function Vse(h,g){if(!(g.state.loading&4)){var _=i_.get(h);if(_)var N=_.get(null);else{_=new Map,i_.set(h,_);for(var P=h.querySelectorAll("link[data-precedence],style[data-precedence]"),F=0;F<P.length;F++){var Z=P[F];(Z.nodeName==="LINK"||Z.getAttribute("media")!=="not all")&&(_.set(Z.dataset.precedence,Z),N=Z)}N&&_.set(null,N)}P=g.instance,Z=P.getAttribute("data-precedence"),F=_.get(Z)||N,F===N&&_.set(null,P),_.set(Z,P),this.count++,N=r_.bind(this),P.addEventListener("load",N),P.addEventListener("error",N),F?F.parentNode.insertBefore(P,F.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(P,h.firstChild)),g.state.loading|=4}}var eb={$$typeof:M,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function Gse(h,g,_,N,P,F,Z,ge,Oe){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=Ot(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ot(0),this.hiddenUpdates=Ot(null),this.identifierPrefix=N,this.onUncaughtError=P,this.onCaughtError=F,this.onRecoverableError=Z,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Oe,this.incompleteTransitions=new Map}function FU(h,g,_,N,P,F,Z,ge,Oe,it,xt,vt){return h=new Gse(h,g,_,Z,Oe,it,xt,vt,ge),g=1,F===!0&&(g|=24),F=ks(3,null,null,g),h.current=F,F.stateNode=h,g=g2(),g.refCount++,h.pooledCache=g,g.refCount++,F.memoizedState={element:N,isDehydrated:_,cache:g},v2(F),h}function UU(h){return h?(h=Mm,h):Mm}function zU(h,g,_,N,P,F){P=UU(P),N.context===null?N.context=P:N.pendingContext=P,N=Iu(g),N.payload={element:_},F=F===void 0?null:F,F!==null&&(N.callback=F),_=Fu(h,N,g),_!==null&&(fs(_,h,g),Px(_,h,g))}function BU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<g?_:g}}function FA(h,g){BU(h,g),(h=h.alternate)&&BU(h,g)}function $U(h){if(h.tag===13||h.tag===31){var g=Nh(h,67108864);g!==null&&fs(g,h,67108864),FA(h,67108864)}}function HU(h){if(h.tag===13||h.tag===31){var g=Os();g=pn(g);var _=Nh(h,g);_!==null&&fs(_,h,g),FA(h,g)}}var s_=!0;function Wse(h,g,_,N){var P=K.T;K.T=null;var F=G.p;try{G.p=2,UA(h,g,_,N)}finally{G.p=F,K.T=P}}function qse(h,g,_,N){var P=K.T;K.T=null;var F=G.p;try{G.p=8,UA(h,g,_,N)}finally{G.p=F,K.T=P}}function UA(h,g,_,N){if(s_){var P=zA(N);if(P===null)NA(h,g,N,o_,_),GU(h,N);else if(Xse(P,h,g,_,N))N.stopPropagation();else if(GU(h,N),g&4&&-1<Kse.indexOf(h)){for(;P!==null;){var F=Ft(P);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 ge=F;for(ge.pendingLanes|=2,ge.entangledLanes|=2;Z;){var Oe=1<<31-je(Z);ge.entanglements[1]|=Oe,Z&=~Oe}Sl(F),(Qn&6)===0&&(Hv=L()+500,Kx(0))}}break;case 31:case 13:ge=Nh(F,2),ge!==null&&fs(ge,F,2),Gv(),FA(F,2)}if(F=zA(N),F===null&&NA(h,g,N,o_,_),F===P)break;P=F}P!==null&&N.stopPropagation()}else NA(h,g,N,null,_)}}function zA(h){return h=$E(h),BA(h)}var o_=null;function BA(h){if(o_=null,h=Ct(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 o_=h,null}function VU(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 be:return 2;case Se:return 8;case se:case Pe:return 32;case Re:return 268435456;default:return 32}default:return 32}}var $A=!1,Xu=null,Yu=null,Zu=null,tb=new Map,nb=new Map,Qu=[],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 GU(h,g){switch(h){case"focusin":case"focusout":Xu=null;break;case"dragenter":case"dragleave":Yu=null;break;case"mouseover":case"mouseout":Zu=null;break;case"pointerover":case"pointerout":tb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":nb.delete(g.pointerId)}}function rb(h,g,_,N,P,F){return h===null||h.nativeEvent!==F?(h={blockedOn:g,domEventName:_,eventSystemFlags:N,nativeEvent:F,targetContainers:[P]},g!==null&&(g=Ft(g),g!==null&&$U(g)),h):(h.eventSystemFlags|=N,g=h.targetContainers,P!==null&&g.indexOf(P)===-1&&g.push(P),h)}function Xse(h,g,_,N,P){switch(g){case"focusin":return Xu=rb(Xu,h,g,_,N,P),!0;case"dragenter":return Yu=rb(Yu,h,g,_,N,P),!0;case"mouseover":return Zu=rb(Zu,h,g,_,N,P),!0;case"pointerover":var F=P.pointerId;return tb.set(F,rb(tb.get(F)||null,h,g,_,N,P)),!0;case"gotpointercapture":return F=P.pointerId,nb.set(F,rb(nb.get(F)||null,h,g,_,N,P)),!0}return!1}function WU(h){var g=Ct(h.target);if(g!==null){var _=a(g);if(_!==null){if(g=_.tag,g===13){if(g=o(_),g!==null){h.blockedOn=g,Nr(h.priority,function(){HU(_)});return}}else if(g===31){if(g=l(_),g!==null){h.blockedOn=g,Nr(h.priority,function(){HU(_)});return}}else if(g===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function l_(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var _=zA(h.nativeEvent);if(_===null){_=h.nativeEvent;var N=new _.constructor(_.type,_);BE=N,_.target.dispatchEvent(N),BE=null}else return g=Ft(_),g!==null&&$U(g),h.blockedOn=_,!1;g.shift()}return!0}function qU(h,g,_){l_(h)&&_.delete(g)}function Yse(){$A=!1,Xu!==null&&l_(Xu)&&(Xu=null),Yu!==null&&l_(Yu)&&(Yu=null),Zu!==null&&l_(Zu)&&(Zu=null),tb.forEach(qU),nb.forEach(qU)}function c_(h,g){h.blockedOn===g&&(h.blockedOn=null,$A||($A=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Yse)))}var u_=null;function KU(h){u_!==h&&(u_=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){u_===h&&(u_=null);for(var g=0;g<h.length;g+=3){var _=h[g],N=h[g+1],P=h[g+2];if(typeof N!="function"){if(BA(N||_)===null)continue;break}var F=Ft(_);F!==null&&(h.splice(g,3),g-=3,z2(F,{pending:!0,data:P,method:_.method,action:N},N,P))}}))}function Km(h){function g(Oe){return c_(Oe,h)}Xu!==null&&c_(Xu,h),Yu!==null&&c_(Yu,h),Zu!==null&&c_(Zu,h),tb.forEach(g),nb.forEach(g);for(var _=0;_<Qu.length;_++){var N=Qu[_];N.blockedOn===h&&(N.blockedOn=null)}for(;0<Qu.length&&(_=Qu[0],_.blockedOn===null);)WU(_),_.blockedOn===null&&Qu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(N=0;N<_.length;N+=3){var P=_[N],F=_[N+1],Z=P[yr]||null;if(typeof F=="function")Z||KU(_);else if(Z){var ge=null;if(F&&F.hasAttribute("formAction")){if(P=F,Z=F[yr]||null)ge=Z.formAction;else if(BA(P)!==null)continue}else ge=Z.action;typeof ge=="function"?_[N+1]=ge:(_.splice(N,3),N-=3),KU(_)}}}function XU(){function h(F){F.canIntercept&&F.info==="react-transition"&&F.intercept({handler:function(){return new Promise(function(Z){return P=Z})},focusReset:"manual",scroll:"manual"})}function g(){P!==null&&(P(),P=null),N||setTimeout(_,20)}function _(){if(!N&&!navigation.transition){var F=navigation.currentEntry;F&&F.url!=null&&navigation.navigate(F.url,{state:F.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var N=!1,P=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(_,100),function(){N=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),P!==null&&(P(),P=null)}}}function HA(h){this._internalRoot=h}d_.prototype.render=HA.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var _=g.current,N=Os();zU(_,N,h,g,null,null)},d_.prototype.unmount=HA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;zU(h.current,2,null,h,null,null),Gv(),g[xi]=null}};function d_(h){this._internalRoot=h}d_.prototype.unstable_scheduleHydration=function(h){if(h){var g=Ln();h={blockedOn:null,target:h,priority:g};for(var _=0;_<Qu.length&&g!==0&&g<Qu[_].priority;_++);Qu.splice(_,0,h),_===0&&WU(h)}};var YU=e.version;if(YU!=="19.2.3")throw Error(r(527,YU,"19.2.3"));G.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Zse={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var h_=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!h_.isDisabled&&h_.supportsFiber)try{Je=h_.inject(Zse),oe=h_}catch{}}return ab.createRoot=function(h,g){if(!i(h))throw Error(r(299));var _=!1,N="",P=r5,F=i5,Z=a5;return g!=null&&(g.unstable_strictMode===!0&&(_=!0),g.identifierPrefix!==void 0&&(N=g.identifierPrefix),g.onUncaughtError!==void 0&&(P=g.onUncaughtError),g.onCaughtError!==void 0&&(F=g.onCaughtError),g.onRecoverableError!==void 0&&(Z=g.onRecoverableError)),g=FU(h,1,!1,null,null,_,N,null,P,F,Z,XU),h[xi]=g.current,MA(h),new HA(g)},ab.hydrateRoot=function(h,g,_){if(!i(h))throw Error(r(299));var N=!1,P="",F=r5,Z=i5,ge=a5,Oe=null;return _!=null&&(_.unstable_strictMode===!0&&(N=!0),_.identifierPrefix!==void 0&&(P=_.identifierPrefix),_.onUncaughtError!==void 0&&(F=_.onUncaughtError),_.onCaughtError!==void 0&&(Z=_.onCaughtError),_.onRecoverableError!==void 0&&(ge=_.onRecoverableError),_.formState!==void 0&&(Oe=_.formState)),g=FU(h,1,!0,g,_??null,N,P,Oe,F,Z,ge,XU),g.context=UU(null),_=g.current,N=Os(),N=pn(N),P=Iu(N),P.callback=null,Fu(_,P,N),_=N,g.current.lanes=_,ln(g,_),Sl(g),h[xi]=g.current,MA(h),new d_(g)},ab.version="19.2.3",ab}var sz;function loe(){if(sz)return WA.exports;sz=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),WA.exports=ooe(),WA.exports}var coe=loe();const dn=t=>typeof t=="string",sb=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},oz=t=>t==null?"":""+t,uoe=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},doe=/###/g,lz=t=>t&&t.indexOf("###")>-1?t.replace(doe,"."):t,cz=t=>!t||dn(t),e0=(t,e,n)=>{const r=dn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(cz(t))return{};const a=lz(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return cz(t)?{}:{obj:t,k:lz(r[i])}},uz=(t,e,n)=>{const{obj:r,k:i}=e0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],o=e.slice(0,e.length-1),l=e0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=e0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},hoe=(t,e,n,r)=>{const{obj:i,k:a}=e0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},A1=(t,e)=>{const{obj:n,k:r}=e0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},foe=(t,e,n)=>{const r=A1(t,n);return r!==void 0?r:A1(e,n)},yq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?dn(t[r])||t[r]instanceof String||dn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):yq(t[r],e[r],n):t[r]=e[r]);return t},Xm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var moe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const poe=t=>dn(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},Jj=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=o}return i},M0=t=>t?.replace("_","-"),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 T1{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:(dn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new T1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new T1(this.logger,e)}}var Ul=new T1;let ZM=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 dz extends ZM{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):dn(r)&&a?l.push(...r.split(a)):l.push(r)));const c=A1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!dn(r)?c:Jj(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),uz(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(dn(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,o={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=A1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?yq(c,r,a):c={...c,...r},uz(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 vq={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 _q=Symbol("i18next/PATH_KEY");function _oe(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===_q?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function eP(t,e){const{[_q]:n}=t(_oe());return n.join(e?.keySeparator??".")}const hz={},YA=t=>!dn(t)&&typeof t!="boolean"&&typeof t!="number";class C1 extends ZM{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=Ul.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=YA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!yoe(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:dn(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:dn(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=eP(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,m=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let b=p?.res;const y=p?.usedKey||l,x=p?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,M=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!dn(i.count),T=C1.hasDefaultValue(i),k=A?this.pluralResolver.getSuffix(f,i.count,i):"",E=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=A&&!i.ordinal&&i.count===0,C=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${k}`]||i[`defaultValue${E}`]||i.defaultValue;let R=b;M&&!b&&T&&(R=C);const U=YA(R),O=Object.prototype.toString.apply(R);if(M&&R&&U&&v.indexOf(O)<0&&!(dn(S)&&Array.isArray(R))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,R,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(p.res=q,p.usedParams=this.getUsedParamsDetails(i),p):q}if(o){const q=Array.isArray(R),j=q?[]:{},W=q?x:y;for(const K in R)if(Object.prototype.hasOwnProperty.call(R,K)){const G=`${W}${o}${K}`;T&&!b?j[K]=this.translate(G,{...i,defaultValue:YA(C)?C[K]:void 0,joinArrays:!1,ns:c}):j[K]=this.translate(G,{...i,joinArrays:!1,ns:c}),j[K]===G&&(j[K]=R[K])}b=j}}else if(M&&dn(S)&&Array.isArray(b))b=b.join(S),b&&(b=this.extendTranslation(b,e,i,r));else{let q=!1,j=!1;!this.isValidLookup(b)&&T&&(q=!0,b=C),this.isValidLookup(b)||(j=!0,b=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:b,G=T&&C!==b&&this.options.updateMissing;if(j||q||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,l,G?C:b),o){const z=this.resolve(l,{...i,keySeparator:!1});z&&z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Q=[];const te=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&te&&te[0])for(let z=0;z<te.length;z++)Q.push(te[z]);else this.options.saveMissingTo==="all"?Q=this.languageUtils.toResolveHierarchy(i.lng||this.language):Q.push(i.lng||this.language);const J=(z,V,ne)=>{const ae=T&&ne!==b?ne:K;this.options.missingKeyHandler?this.options.missingKeyHandler(z,u,V,ae,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,u,V,ae,G,i),this.emit("missingKey",z,u,V,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?Q.forEach(z=>{const V=this.pluralResolver.getSuffixes(z,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(ne=>{J([z],l+ne,i[`defaultValue${ne}`]||C)})}):J(Q,l,C))}b=this.extendTranslation(b,e,i,p,r),j&&b===l&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${l}`),(j||q)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,q?b:void 0,i))}return a?(p.res=b,p.usedParams=this.getUsedParamsDetails(i),p):b}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=dn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!dn(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),m=f&&f.length;u<m&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=dn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=vq.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,o,l;return dn(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!dn(n.count),p=m&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(dn(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(x=>{this.isValidLookup(r)||(l=x,!hz[`${y[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(hz[`${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&&!dn(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class fz{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ul.create("languageUtils")}getScriptPartFromCode(e){if(e=M0(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=M0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(dn(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(o=>{if(o===a)return o;if(!(o.indexOf("-")<0&&a.indexOf("-")<0)&&(o.indexOf("-")>0&&a.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===a||o.indexOf(a)===0&&a.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),dn(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],a=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return dn(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):dn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const mz={zero:0,one:1,two:2,few:3,many:4,other:5},pz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class woe{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Ul.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=M0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),pz;if(!e.match(/-|_/))return pz;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)=>mz[i]-mz[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 gz=(t,e,n,r=".",i=!0)=>{let a=foe(t,e,n);return!a&&i&&dn(n)&&(a=Jj(t,n,r),a===void 0&&(a=Jj(e,n,r))),a},ZA=t=>t.replace(/\$/g,"$$$$");class xz{constructor(e={}){this.logger=Ul.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:b,nestingSuffixEscaped:y,nestingOptionsSeparator:x,maxReplaces:v,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:poe,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?Xm(a):o||"{{",this.suffix=l?Xm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=m?Xm(m):p||Xm("$t("),this.nestingSuffix=b?Xm(b):y||Xm(")"),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=gz(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(gz(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=>ZA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?ZA(this.escape(p)):ZA(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const b=a[1].trim();if(o=u(b),o===void 0)if(typeof d=="function"){const x=d(e,a,i);o=dn(x)?x:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),o="";else!dn(o)&&!this.useRawValueToEscape&&(o=oz(o));const y=p.safeValue(o);if(e=e.replace(a[0],y),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const p=m.match(/'/g),b=m.match(/"/g);((p?.length??0)%2===0&&!b||b.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!dn(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),a=n(l.call(this,i[1].trim(),o),o),a&&i[0]===e&&!dn(a))return a;dn(a)||(a=oz(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}},bz=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const o=r+JSON.stringify(a);let l=e[o];return l||(l=t(M0(r),i),e[o]=l),l(n)}},Moe=t=>(e,n,r)=>t(M0(n),r)(e);class Noe{constructor(e={}){this.logger=Ul.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?bz: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()]=bz(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 ZM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=Ul.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const m=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,d=!1,o[m]===void 0&&(o[m]=!0),a[m]===void 0&&(a[m]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{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();dn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),dn(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const QA=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),dn(t[1])&&(e.defaultValue=t[1]),dn(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),yz=t=>(dn(t.ns)&&(t.ns=[t.ns]),dn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),dn(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),m_=()=>{},Toe=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class t0 extends ZM{constructor(e={},n){if(super(),this.options=yz(e),this.services={},this.logger=Ul,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&&(dn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=QA();this.options={...r,...this.options,...yz(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=r.overloadTranslationOptionHandler),this.options.debug===!0&&typeof console<"u"&&console.warn("i18next is maintained with support from locize.com — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com");const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Ul.init(i(this.modules.logger),this.options):Ul.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Noe;const d=new fz(this.options);this.store=new dz(this.options.resources,this.options);const f=this.services;f.logger=Ul,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 xz(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 C1(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=m_),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const l=sb(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=m_){let r=n;const i=dn(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=sb();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=m_),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"&&vq.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const r=sb();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=dn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(dn(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(a,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([a,o].concat(l)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(a)?d=a.map(f=>(typeof f=="function"&&(f=eP(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=eP(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return dn(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(a,e)))}loadNamespaces(e,n){const r=sb();return this.options.ns?(dn(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=sb();dn(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new fz(QA());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new t0(e,n);return r.createInstance=t0.createInstance,r}cloneInstance(e={},n=m_){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new t0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new dz(l,i),a.services.resourceStore=a.store}if(e.interpolation){const c={...QA().interpolation,...this.options.interpolation,...e.interpolation},u={...i,interpolation:c};a.services.interpolator=new xz(u)}return a.translator=new C1(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const ss=t0.createInstance();ss.createInstance;ss.dir;ss.init;ss.loadResources;ss.reloadResources;ss.use;ss.changeLanguage;ss.getFixedT;ss.t;ss.exists;ss.setDefaultNamespace;ss.hasLoadedNamespace;ss.loadNamespaces;ss.loadLanguages;const 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);If(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},vz={},wq=(t,e,n,r)=>{If(n)&&vz[n]||(If(n)&&(vz[n]=new Date),Coe(t,e,n,r))},Sq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},tP=(t,e,n)=>{t.loadNamespaces(e,Sq(t,n))},_z=(t,e,n,r)=>{if(If(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return tP(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,Sq(t,r))},koe=(t,e,n={})=>!e.languages||!e.languages.length?(wq(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}}),If=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 nP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Ooe,transDefaultProps:void 0};const Loe=(t={})=>{nP={...nP,...t}},Ioe=()=>nP;let Mq;const Foe=t=>{Mq=t},Uoe=()=>Mq,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 JA={exports:{}},eT={};var wz;function Hoe(){if(wz)return eT;wz=1;var t=Gg();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var p=m(),b=r({inst:{value:p,getSnapshot:m}}),y=b[0].inst,x=b[1];return a(function(){y.value=p,y.getSnapshot=m,c(y)&&x({inst:y})},[f,p,m]),i(function(){return c(y)&&x({inst:y}),f(function(){c(y)&&x({inst:y})})},[f]),o(p),p}function c(f){var m=f.getSnapshot;f=f.value;try{var p=m();return!n(f,p)}catch{return!0}}function u(f,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return eT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,eT}var Sz;function Nq(){return Sz||(Sz=1,JA.exports=Hoe()),JA.exports}var wD=Nq();const Voe=(t,e)=>If(e)?e:joe(e)&&If(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Goe={t:Voe,ready:!1},Woe=()=>()=>{},Wg=(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||wq(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=If(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:R,bindI18nStore:U}=o,O=()=>{m.current+=1,C()};return R&&a.on(R,O),U&&a.store.on(U,O),()=>{R&&R.split(" ").forEach(q=>a.off(q,O)),U&&U.split(" ").forEach(q=>a.store.off(q,O))}},[a,o]),b=w.useRef(),y=w.useCallback(()=>{if(!a)return Goe;const C=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>koe(W,a,o)),R=e.lng||a.language,U=m.current,O=b.current;if(O&&O.ready===C&&O.lng===R&&O.keyPrefix===c&&O.revision===U)return O;const j={t:a.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:C,lng:R,keyPrefix:c,revision:U};return b.current=j,j},[a,f,c,o,e.lng]),[x,v]=w.useState(0),{t:S,ready:M}=wD.useSyncExternalStore(p,y,y);w.useEffect(()=>{if(a&&!M&&!l){const C=()=>v(R=>R+1);e.lng?_z(a,e.lng,f,C):tP(a,f,C)}},[a,e.lng,f,M,l,x]);const A=a||{},T=w.useRef(null),k=w.useRef(),E=C=>{const R=Object.getOwnPropertyDescriptors(C);R.__original&&delete R.__original;const U=Object.create(Object.getPrototypeOf(C),R);if(!Object.prototype.hasOwnProperty.call(U,"__original"))try{Object.defineProperty(U,"__original",{value:C,writable:!1,enumerable:!1,configurable:!1})}catch{}return U},D=w.useMemo(()=>{const C=A,R=C?.language;let U=C;C&&(T.current&&T.current.__original===C?k.current!==R?(U=E(C),T.current=U,k.current=R):U=T.current:(U=E(C),T.current=U,k.current=R));const O=[S,U,M];return O.t=S,O.i18n=U,O.ready=M,O},[S,A,M,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!M)throw new Promise(C=>{const R=()=>C();e.lng?_z(a,e.lng,f,R):tP(a,f,R)});return D},{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 Mz=/^[\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(!Mz.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!Mz.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},Nz={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 Nz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&Nz.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 Ym=null;const Ez=()=>{if(Ym!==null)return Ym;try{if(Ym=typeof window<"u"&&window.localStorage!==null,!Ym)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Ym=!1}return Ym};var tle={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&Ez())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&Ez()&&window.localStorage.setItem(n,t)}};let Zm=null;const Az=()=>{if(Zm!==null)return Zm;try{if(Zm=typeof window<"u"&&window.sessionStorage!==null,!Zm)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Zm=!1}return Zm};var nle={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&Az())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&Az()&&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 Eq=!1;try{document.cookie,Eq=!0}catch{}const Aq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Eq||Aq.splice(1,1);const ole=()=>({order:Aq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Tq{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)}))}}Tq.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}};ss.use(Tq).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 Tz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var Cz="popstate";function dle(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return rP("",{pathname:a,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:N0(i)}return fle(e,n,null,t)}function $r(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Ro(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function hle(){return Math.random().toString(36).substring(2,10)}function kz(t,e){return{usr:t.state,key:t.key,idx:e}}function rP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?qg(e):e,state:n,key:e&&e.key||r||hle()}}function N0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function qg(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substring(r),t=t.substring(0,r)),t&&(e.pathname=t)}return e}function 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=rP(y.location,x,v);u=d()+1;let M=kz(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=rP(y.location,x,v);u=d();let M=kz(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(Cz,f),c=x,()=>{i.removeEventListener(Cz,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:N0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Cq(t,e,n="/"){return ple(t,e,n,!1)}function ple(t,e,n,r){let i=typeof e=="string"?qg(e):e,a=hu(i.pathname||"/",n);if(a==null)return null;let o=kq(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 kq(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=ru([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}".`),kq(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 jq(o.path))a(o,l,!0,c)}),e}function jq(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=jq(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,jz=t=>t==="*";function Sle(t,e){let n=t.split("/"),r=n.length;return n.some(jz)&&(r+=wle),e&&(r+=yle),n.filter(i=>!jz(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=k1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=k1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:ru([a,f.pathname]),pathnameBase:jle(ru([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=ru([a,f.pathnameBase]))}return o}function k1(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){Ro(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function Ale(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Ro(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function hu(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"?qg(t):t,a;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?a=Pz(n.substring(1),"/"):a=Pz(n,e)):a=e,{pathname:a,search:Ple(r),hash:Rle(i)}}function Pz(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function tT(t,e,n,r){return`Cannot include a '${t}' character in a manually specified \`to.${e}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function kle(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function SD(t){let e=kle(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function MD(t,e,n,r=!1){let i;typeof t=="string"?i=qg(t):(i={...t},$r(!i.pathname||!i.pathname.includes("?"),tT("?","pathname","search",i)),$r(!i.pathname||!i.pathname.includes("#"),tT("#","pathname","hash",i)),$r(!i.search||!i.search.includes("#"),tT("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),f-=1;i.pathname=m.join("/")}l=f>=0?e[f]:"/"}let c=Cle(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var ru=t=>t.join("/").replace(/\/\/+/g,"/"),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 Pq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Rq(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(Pq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=hu(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{Ro(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Dq=["POST","PUT","PATCH","DELETE"];new Set(Dq);var Ile=["GET",...Dq];new Set(Ile);var Kg=w.createContext(null);Kg.displayName="DataRouter";var QM=w.createContext(null);QM.displayName="DataRouterState";var Fle=w.createContext(!1),Oq=w.createContext({isTransitioning:!1});Oq.displayName="ViewTransition";var Ule=w.createContext(new Map);Ule.displayName="Fetchers";var zle=w.createContext(null);zle.displayName="Await";var eo=w.createContext(null);eo.displayName="Navigation";var yy=w.createContext(null);yy.displayName="Location";var zo=w.createContext({outlet:null,matches:[],isDataRoute:!1});zo.displayName="Route";var ND=w.createContext(null);ND.displayName="RouteError";var Lq="REACT_ROUTER_ERROR",Ble="REDIRECT",$le="ROUTE_ERROR_RESPONSE";function Hle(t){if(t.startsWith(`${Lq}:${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(`${Lq}:${$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(Xg(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=w.useContext(eo),{hash:i,pathname:a,search:o}=vy(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:ru([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Xg(){return w.useContext(yy)!=null}function lc(){return $r(Xg(),"useLocation() may be used only in the context of a <Router> component."),w.useContext(yy).location}var Iq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Fq(t){w.useContext(eo).static||w.useLayoutEffect(t)}function pl(){let{isDataRoute:t}=w.useContext(zo);return t?sce():Wle()}function Wle(){$r(Xg(),"useNavigate() may be used only in the context of a <Router> component.");let t=w.useContext(Kg),{basename:e,navigator:n}=w.useContext(eo),{matches:r}=w.useContext(zo),{pathname:i}=lc(),a=JSON.stringify(SD(r)),o=w.useRef(!1);return Fq(()=>{o.current=!0}),w.useCallback((c,u={})=>{if(Ro(o.current,Iq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=MD(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:ru([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var qle=w.createContext(null);function Kle(t){let e=w.useContext(zo).outlet;return w.useMemo(()=>e&&w.createElement(qle.Provider,{value:t},e),[e,t])}function ED(){let{matches:t}=w.useContext(zo),e=t[t.length-1];return e?e.params:{}}function vy(t,{relative:e}={}){let{matches:n}=w.useContext(zo),{pathname:r}=lc(),i=JSON.stringify(SD(n));return w.useMemo(()=>MD(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Xle(t,e){return Uq(t,e)}function Uq(t,e,n,r,i){$r(Xg(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=w.useContext(eo),{matches:o}=w.useContext(zo),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||"";Bq(u,!f||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${S}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let m=lc(),p;if(e){let S=typeof e=="string"?qg(e):e;$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=Cq(t,{pathname:y});Ro(f||x!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Ro(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=ece(x&&x.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:ru([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:ru([d,a.encodeLocation?a.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&v?w.createElement(yy.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),zq=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(zo.Provider,{value:this.props.routeContext},w.createElement(ND.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?w.createElement(Qle,{error:t},e):e}};zq.contextType=Fle;var nT=new WeakMap;function Qle({children:t,error:e}){let{basename:n}=w.useContext(eo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=Hle(e.digest);if(r){let i=nT.get(e);if(i)throw i;let a=Rq(r.location,n);if(Pq&&!nT.get(e))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw nT.set(e,o),o}return w.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function Jle({routeContext:t,match:e,children:n}){let r=w.useContext(Kg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),w.createElement(zo.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?(Bq("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(zq,{location:n.location,revalidation:n.revalidation,component:y,error:p,children:S(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):S()},null)}function AD(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(Kg);return $r(e,AD(t)),e}function nce(t){let e=w.useContext(QM);return $r(e,AD(t)),e}function rce(t){let e=w.useContext(zo);return $r(e,AD(t)),e}function TD(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 TD("useRouteId")}function ace(){let t=w.useContext(ND),e=nce("useRouteError"),n=TD("useRouteError");return t!==void 0?t:e.errors?.[n]}function sce(){let{router:t}=tce("useNavigate"),e=TD("useNavigate"),n=w.useRef(!1);return Fq(()=>{n.current=!0}),w.useCallback(async(i,a={})=>{Ro(n.current,Iq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var Rz={};function Bq(t,e,n){!e&&!Rz[t]&&(Rz[t]=!0,Ro(!1,n))}w.memo(oce);function oce({routes:t,future:e,state:n,onError:r}){return Uq(t,void 0,n,r,e)}function j1({to:t,replace:e,state:n,relative:r}){$r(Xg(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=w.useContext(eo);Ro(!i,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:a}=w.useContext(zo),{pathname:o}=lc(),l=pl(),c=MD(t,SD(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 qi(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(!Xg(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:l,navigator:i,static:a,unstable_useTransitions:o,future:{}}),[l,i,a,o]);typeof n=="string"&&(n=qg(n));let{pathname:u="/",search:d="",hash:f="",state:m=null,key:p="default"}=n,b=w.useMemo(()=>{let y=hu(u,l);return y==null?null:{location:{pathname:y,search:d,hash:f,state:m,key:p},navigationType:r}},[l,u,d,f,m,p,r]);return Ro(b!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:w.createElement(eo.Provider,{value:c},w.createElement(yy.Provider,{children:e,value:b}))}function uce({children:t,location:e}){return Xle(iP(t),e)}function iP(t,e=[]){let n=[];return w.Children.forEach(t,(r,i)=>{if(!w.isValidElement(r))return;let a=[...e,i];if(r.type===w.Fragment){n.push.apply(n,iP(r.props.children,a));return}$r(r.type===qi,`[${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=iP(r.props.children,a)),n.push(o)}),n}var Jw="get",e1="application/x-www-form-urlencoded";function JM(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function dce(t){return JM(t)&&t.tagName.toLowerCase()==="button"}function hce(t){return JM(t)&&t.tagName.toLowerCase()==="form"}function fce(t){return JM(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 aP(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function gce(t,e){let n=aP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var p_=null;function xce(){if(p_===null)try{new FormData(document.createElement("form"),0),p_=!1}catch{p_=!0}return p_}var bce=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function rT(t){return t!=null&&!bce.has(t)?(Ro(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${e1}"`),null):t}function yce(t,e){let n,r,i,a,o;if(hce(t)){let l=t.getAttribute("action");r=l?hu(l,e):null,n=t.getAttribute("method")||Jw,i=rT(t.getAttribute("enctype"))||e1,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?hu(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||Jw,i=rT(t.getAttribute("formenctype"))||rT(l.getAttribute("enctype"))||e1,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(JM(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Jw,r=null,i=e1,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 CD(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&&hu(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 Dz(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 $q(){let t=w.useContext(Kg);return CD(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Tce(){let t=w.useContext(QM);return CD(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var kD=w.createContext(void 0);kD.displayName="FrameworkContext";function Hq(){let t=w.useContext(kD);return CD(t,"You must render this element inside a <HydratedRouter> element"),t}function Cce(t,e){let n=w.useContext(kD),[r,i]=w.useState(!1),[a,o]=w.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,m=w.useRef(null);w.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(S=>{o(S.isIntersecting)})},x=new IntersectionObserver(y,{threshold:.5});return m.current&&x.observe(m.current),()=>{x.disconnect()}}},[t]),w.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let p=()=>{i(!0)},b=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:ob(l,p),onBlur:ob(c,b),onMouseEnter:ob(u,p),onMouseLeave:ob(d,b),onTouchStart:ob(f,p)}]:[!1,m,{}]}function ob(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function kce({page:t,...e}){let{router:n}=$q(),r=w.useMemo(()=>Cq(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}=Hq(),[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=lc(),{future:i,manifest:a,routeModules:o}=Hq(),{basename:l}=$q(),{loaderData:c,matches:u}=Tce(),d=w.useMemo(()=>Dz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=w.useMemo(()=>Dz(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 Vq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,gs=w.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},b){let{basename:y,unstable_useTransitions:x}=w.useContext(eo),v=typeof u=="string"&&Vq.test(u),S=Rq(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 D(R){e&&e(R),R.defaultPrevented||E(R)}let C=w.createElement("a",{...p,...k,href:S.absoluteURL||M,onClick:S.isExternal||a?e:D,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});gs.displayName="Link";var Lb=w.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=vy(o,{relative:u.relative}),m=lc(),p=w.useContext(QM),{navigator:b,basename:y}=w.useContext(eo),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=hu(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},D=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 R=typeof a=="function"?a(E):a;return w.createElement(gs,{...u,"aria-current":D,className:C,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(E):c)});Lb.displayName="NavLink";var Lce=w.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Jw,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...p},b)=>{let{unstable_useTransitions:y}=w.useContext(eo),x=Bce(),v=$ce(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",M=typeof l=="string"&&Vq.test(l),A=T=>{if(c&&c(T),T.defaultPrevented)return;T.preventDefault();let k=T.nativeEvent.submitter,E=k?.getAttribute("formmethod")||o,D=()=>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(()=>D()):D()};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 Gq(t){let e=w.useContext(Kg);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=pl(),d=lc(),f=vy(t,{relative:a});return w.useCallback(m=>{if(pce(m,e)){m.preventDefault();let p=n!==void 0?n:N0(d)===N0(f),b=()=>u(t,{replace:p,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l});c?w.startTransition(()=>b()):b()}},[d,u,f,n,r,e,t,i,a,o,l,c])}function Wq(t){Ro(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=w.useRef(aP(t)),n=w.useRef(!1),r=lc(),i=w.useMemo(()=>gce(r.search,n.current?null:e.current),[r.search]),a=pl(),o=w.useCallback((l,c)=>{const u=aP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var Uce=0,zce=()=>`__${String(++Uce)}__`;function Bce(){let{router:t}=Gq("useSubmit"),{basename:e}=w.useContext(eo),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(eo),r=w.useContext(zo);$r(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...vy(t||".",{relative:e})},o=lc();if(t==null){a.search=o.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:ru([n,a.pathname])),N0(a)}function Hce(t,{relative:e}={}){let n=w.useContext(Oq);$r(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Gq("useViewTransitionState"),i=vy(t,{relative:e});if(!n.isTransitioning)return!1;let a=hu(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=hu(n.nextLocation.pathname,r)||n.nextLocation.pathname;return k1(i.pathname,o)!=null||k1(i.pathname,a)!=null}var Zc=bq();const Vce=ml(Zc);var um=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)}},uf=new Wce;function qce(t){setTimeout(t,0)}var Ff=typeof window>"u"||"Deno"in globalThis;function Fa(){}function Kce(t,e){return typeof t=="function"?t(e):t}function sP(t){return typeof t=="number"&&t>=0&&t!==1/0}function qq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Id(t,e){return typeof t=="function"?t(e):t}function yo(t,e){return typeof t=="function"?t(e):t}function Oz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==jD(o,e.options))return!1}else if(!E0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||a&&!a(e))}function Lz(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(Uf(e.options.mutationKey)!==Uf(a))return!1}else if(!E0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function jD(t,e){return(e?.queryKeyHashFn||Uf)(t)}function Uf(t){return JSON.stringify(t,(e,n)=>oP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function E0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>E0(t[n],e[n])):!1}var Xce=Object.prototype.hasOwnProperty;function PD(t,e,n=0){if(t===e)return t;if(n>500)return e;const r=Iz(t)&&Iz(e);if(!r&&!(oP(t)&&oP(e)))return e;const a=(r?t:Object.keys(t)).length,o=r?e:Object.keys(e),l=o.length,c=r?new Array(l):{};let u=0;for(let d=0;d<l;d++){const f=r?d:o[d],m=t[f],p=e[f];if(m===p){c[f]=m,(r?d<a:Xce.call(t,f))&&u++;continue}if(m===null||p===null||typeof m!="object"||typeof p!="object"){c[f]=p;continue}const b=PD(m,p,n+1);c[f]=b,b===m&&u++}return a===l&&u===a?t:c}function A0(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function Iz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function oP(t){if(!Fz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Fz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Fz(t){return Object.prototype.toString.call(t)==="[object Object]"}function Yce(t){return new Promise(e=>{uf.setTimeout(e,t)})}function lP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?PD(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 RD=Symbol();function Kq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===RD?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function DD(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 um{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!Ff&&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"}},OD=new eue;function cP(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var 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 um{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!Ff&&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}},P1=new rue;function iue(t){return Math.min(1e3*2**t,3e4)}function Xq(t){return(t??"online")==="online"?P1.isOnline():!0}var uP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Yq(t){let e=!1,n=0,r;const i=cP(),a=()=>i.status!=="pending",o=y=>{if(!a()){const x=new uP(y);m(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>OD.isFocused()&&(t.networkMode==="always"||P1.isOnline())&&t.canRun(),d=()=>Xq(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??(Ff?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 Zq=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),sP(this.gcTime)&&(this.#t=uf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Ff?1/0:300*1e3))}clearGcTimeout(){this.#t&&(uf.clearTimeout(this.#t),this.#t=void 0)}},aue=class extends Zq{#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=zz(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=zz(this.options);e.data!==void 0&&(this.setState(Uz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=lP(this.state.data,t,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#s({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Fa).catch(Fa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>yo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===RD||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Id(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:!qq(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=Kq(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=Yq({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof uP&&l.revert&&this.setState({...this.#e,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#s({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof uP){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Qq(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Uz(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 Qq(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Xq(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Uz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function zz(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 LD=class extends um{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=cP(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#m;#d;#h;#c;#u;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Bz(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return dP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return dP(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#e.removeObserver(this)}setOptions(t){const e=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof yo(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#e.setOptions(this.options),e._defaulted&&!A0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&$z(this.#e,n,this.options,e)&&this.#p(),this.updateResult(),r&&(this.#e!==n||yo(this.options.enabled,this.#e)!==yo(e.enabled,this.#e)||Id(this.options.staleTime,this.#e)!==Id(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||yo(this.options.enabled,this.#e)!==yo(e.enabled,this.#e)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#t.getQueryCache().build(this.#t,t),n=this.createResult(e,t);return 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(Fa)),e}#g(){this.#v();const t=Id(this.options.staleTime,this.#e);if(Ff||this.#i.isStale||!sP(t))return;const n=qq(this.#i.dataUpdatedAt,t)+1;this.#c=uf.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,!(Ff||yo(this.options.enabled,this.#e)===!1||!sP(this.#l)||this.#l===0)&&(this.#u=uf.setInterval(()=>{(this.options.refetchIntervalInBackground||OD.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(uf.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(uf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,a=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,m;if(e._optimisticResults){const D=this.hasListeners(),C=!D&&Bz(t,e),R=D&&$z(t,n,e,r);(C||R)&&(d={...d,...Qq(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:y}=d;m=d.data;let x=!1;if(e.placeholderData!==void 0&&m===void 0&&y==="pending"){let D;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(D=i.data,x=!0):D=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,D!==void 0&&(y="success",m=lP(i?.data,D,e),f=!0)}if(e.select&&m!==void 0&&!x)if(i&&m===a?.data&&e.select===this.#m)m=this.#d;else try{this.#m=e.select,m=e.select(m),m=lP(i?.data,m,e),this.#d=m,this.#s=null}catch(D){this.#s=D}this.#s&&(p=this.#s,m=this.#d,b=Date.now(),y="error");const v=d.fetchStatus==="fetching",S=y==="pending",M=y==="error",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:ID(t,e),refetch:this.refetch,promise:this.#o,isEnabled:yo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=E.data!==void 0,C=E.status==="error"&&!D,R=q=>{C?q.reject(E.error):D&&q.resolve(E.data)},U=()=>{const q=this.#o=E.promise=cP();R(q)},O=this.#o;switch(O.status){case"pending":t.queryHash===n.queryHash&&R(O);break;case"fulfilled":(C||E.data!==O.value)&&U();break;case"rejected":(!C||E.error!==O.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),A0(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#f.size)return!0;const a=new Set(i??this.#f);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#w(){const t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;const e=this.#e;this.#e=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){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 yo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Bz(t,e){return sue(t,e)||t.state.data!==void 0&&dP(t,e,e.refetchOnMount)}function dP(t,e,n){if(yo(e.enabled,t)!==!1&&Id(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&ID(t,e)}return!1}function $z(t,e,n,r){return(t!==e||yo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&ID(t,n)}function ID(t,e){return yo(e.enabled,t)!==!1&&t.isStaleByTime(Id(e.staleTime,t))}function oue(t,e){return!A0(t.getCurrentResult(),e)}function Hz(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=Kq(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:Vz,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:Vz(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 Vz(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 Zq{#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||Jq(),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=Yq({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 Jq(){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 um{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=g_(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=g_(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=g_(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=g_(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=>Lz(e,n))}findAll(t={}){return this.getAll().filter(e=>Lz(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(Fa))))}};function g_(t){return t.options.scope?.id}var due=class extends um{#t;#e=void 0;#n;#i;constructor(e,n){super(),this.#t=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#t.defaultMutationOptions(e),A0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&Uf(n.mutationKey)!==Uf(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??Jq();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 Gz(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 um{#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||!A0(d,m)});!c&&!u||(c&&(this.#d=r,this.#r=i),this.#e=a,this.hasListeners()&&(c&&(Gz(n,i).forEach(d=>{d.destroy()}),Gz(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=PD(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 LD(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 um{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??jD(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=>Oz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Oz(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=OD.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=P1.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(Id(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(Fa).catch(Fa)}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(Fa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Fa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(Id(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Fa).catch(Fa)}fetchInfiniteQuery(t){return t.behavior=Hz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Fa).catch(Fa)}ensureInfiniteQueryData(t){return t.behavior=Hz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return P1.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(Uf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{E0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(Uf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{E0(t,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=jD(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===RD&&(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()}},eK=w.createContext(void 0),on=t=>{const e=w.useContext(eK);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(eK.Provider,{value:t,children:e})),tK=w.createContext(!1),nK=()=>w.useContext(tK);tK.Provider;function xue(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var bue=w.createContext(xue()),rK=()=>w.useContext(bue),iK=(t,e,n)=>{const r=n?.state.error&&typeof t.throwOnError=="function"?DD(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||r)&&(e.isReset()||(t.retryOnMount=!1))},aK=t=>{w.useEffect(()=>{t.clearReset()},[t])},sK=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||DD(n,[t.error,r])),oK=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))}},lK=(t,e)=>t.isLoading&&t.isFetching&&!e,hP=(t,e)=>t?.suspense&&e.isPending,R1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function yue({queries:t,...e},n){const r=on(),i=nK(),a=rK(),o=w.useMemo(()=>t.map(y=>{const x=r.defaultQueryOptions(y);return x._optimisticResults=i?"isRestoring":"optimistic",x}),[t,r,i]);o.forEach(y=>{oK(y);const x=r.getQueryCache().get(y.queryHash);iK(y,a,x)}),aK(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)):Fa,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),w.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const p=c.some((y,x)=>hP(o[x],y))?c.flatMap((y,x)=>{const v=o[x];if(v){const S=new LD(r,v);if(hP(v,y))return R1(v,S,a);lK(y,i)&&R1(v,S,a)}return[]}):[];if(p.length>0)throw Promise.all(p);const b=c.find((y,x)=>{const v=o[x];return v&&sK({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=nK(),i=rK(),a=on(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",oK(o),iK(o,i,l),aK(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)):Fa;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),w.useEffect(()=>{u.setOptions(o)},[o,u]),hP(o,d))throw R1(o,u,i);if(sK({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&&!Ff&&lK(d,r)&&(c?R1(o,u,i):l?.promise)?.catch(Fa).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function ut(t,e){return vue(t,LD)}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(Fa)},[r]);if(i.error&&DD(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const cK=(...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 Wz=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:cK("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:cK(`lucide-${_ue(Wz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Wz(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"}]],Ja=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"}]],T0=Ke("arrow-down",jue);const Pue=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],uK=Ke("arrow-left",Pue);const Rue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],fP=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"}]],dK=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"}]],pg=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"}]],Sf=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"}]],Bs=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"}]],hK=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"}]],eN=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"}]],zf=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"}]],ts=Ke("check",ide);const ade=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Di=Ke("chevron-down",ade);const sde=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Bf=Ke("chevron-left",sde);const ode=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Zs=Ke("chevron-right",ode);const lde=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],fu=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"}]],aa=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"}]],iT=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"}]],On=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"}]],tN=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"}]],na=Ke("circle-x",xde);const bde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],mP=Ke("circle",bde);const yde=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Xn=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"}]],nN=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"}]],fK=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"}]],ol=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"}]],x_=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"}]],iu=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"}]],pP=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"}]],FD=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"}]],UD=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"}]],Fd=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"}]],aT=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"}]],_y=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"}]],Yd=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"}]],mK=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"}]],Mf=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"}]],D1=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"}]],O1=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"}]],Ya=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"}]],rN=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"}]],Ud=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"}]],Aa=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"}]],ll=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"}]],pK=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"}]],iN=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"}]],aN=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"}]],eg=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"}]],gP=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"}]],zd=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"}]],gg=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"}]],gK=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"}]],sN=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"}]],C0=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"}]],oN=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"}]],wy=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"}]],Zl=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"}]],df=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"}]],xP=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"}]],cl=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"}]],lN=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"}]],Gl=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"}]],Yg=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"}]],xK=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"}]],bP=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"}]],cN=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"}]],qz=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"}]],sT=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"}]],Kz=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"}]],yP=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"}]],bK=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"}]],yK=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"}]],vK=Ke("minimize",sfe);const ofe=[["path",{d:"M5 12h14",key:"1ays0h"}]],vP=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"}]],L1=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"}]],_P=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"}]],Ql=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"}]],zD=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"}]],BD=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"}]],$f=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"}]],uN=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"}]],sa=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"}]],Do=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"}]],Ws=Ke("plug",Sfe);const Mfe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],er=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"}]],dN=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"}]],Mu=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"}]],Wr=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"}]],_K=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"}]],dm=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"}]],ys=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"}]],I1=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"}]],Na=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"}]],$D=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"}]],Zh=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"}]],Zd=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"}]],hN=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"}]],wP=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"}]],wK=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"}]],k0=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"}]],Xz=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"}]],j0=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"}]],Oo=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"}]],Lo=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"}]],Hf=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"}]],SK=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"}]],Yz=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"}]],xg=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"}]],MK=Ke("target",ame);const sme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],NK=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"}]],fN=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"}]],Cd=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"}]],un=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"}]],EK=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"}]],AK=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"}]],An=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"}]],HD=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"}]],mi=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"}]],SP=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"}]],hf=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"}]],VD=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"}]],Zg=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"}]],tg=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"}]],TK=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"}]],Qd=Ke("wrench",Ome);const Lme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ht=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"}]],Vf=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"}]],GD=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"}]],WD=Ke("zoom-out",Ume),xn="/api/v1";let F1=localStorage.getItem("auth_token");function Ib(t){F1=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Zz(){return F1}async function Ce(t,e={}){const n={"Content-Type":"application/json",...e.headers};F1&&(n.Authorization=`Bearer ${F1}`);const r=await fetch(`${xn}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&Ib(null);const a=(await r.json().catch(()=>({}))).detail,o=typeof a=="string"?a:a?JSON.stringify(a):`HTTP ${r.status}`;throw new Error(o)}return await r.json()}const fe={getAuthStatus:()=>Ce("/auth/status"),setupAuth:t=>Ce("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Ce("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Ce("/auth/logout",{method:"POST"}),getCurrentUser:()=>Ce("/auth/me"),disableAuth:()=>Ce("/auth/disable",{method:"POST"}),getUsers:()=>Ce("/users/"),getUser:t=>Ce(`/users/${t}`),createUser:t=>Ce("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Ce(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:t=>Ce(`/users/${t}`,{method:"DELETE"}),getPrinters:()=>Ce("/printers/"),getPrinter:t=>Ce(`/printers/${t}`),createPrinter:t=>Ce("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Ce(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Ce(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Ce(`/printers/${t}/status`),refreshPrinterStatus:t=>Ce(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Ce(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Ce(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Ce(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Ce(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Ce(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Ce(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Ce(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Ce(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Ce(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Ce(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Ce(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Ce(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Ce(`/printers/${t}/logging`),clearMQTTLogs:t=>Ce(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Ce(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${xn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFilesAsZip:async(t,e)=>{const n=await fetch(`${xn}/printers/${t}/files/download-zip`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${n.status}`)}return n.blob()},deletePrinterFile:(t,e)=>Ce(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Ce(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),Ce(`/archives/?${i}`)},getArchive:t=>Ce(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),Ce(`/archives/search?${n}`)},rebuildSearchIndex:()=>Ce("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Ce(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Ce(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Ce(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Ce("/archives/stats"),recalculateCosts:()=>Ce("/archives/recalculate-costs",{method:"POST"}),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Ce(`/archives/analysis/failures?${e}`)},compareArchives:t=>Ce(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Ce(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${xn}/archives/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${xn}/archives/stats/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>Ce(`/archives/${t}/duplicates`),backfillContentHashes:()=>Ce("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${xn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${xn}/archives/${t}/download`,getArchiveGcode:t=>`${xn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${xn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${xn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Ce(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Ce(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getTimelapseInfo:t=>Ce(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Ce(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i=await fetch(`${xn}/archives/${t}/timelapse/process`,{method:"POST",body:r});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${xn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/photos`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteArchivePhoto:(t,e)=>Ce(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${xn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${xn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/source`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteSource3mf:t=>Ce(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${xn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/archives/${t}/f3d`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteF3d:t=>Ce(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${xn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Ce(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Ce(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Ce(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${xn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${xn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Ce(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Ce(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Ce(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${xn}/archives/upload?printer_id=${e}`:`${xn}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const r=e?`${xn}/archives/upload-bulk?printer_id=${e}`:`${xn}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>Ce("/settings/"),updateSettings:t=>Ce("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Ce("/settings/mqtt/status"),resetSettings:()=>Ce("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.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:()=>Ce("/settings/check-ffmpeg"),getCloudStatus:()=>Ce("/cloud/status"),cloudLogin:(t,e,n="global")=>Ce("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Ce("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Ce("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Ce("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Ce(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Ce(`/cloud/settings/${t}`),createCloudSetting:t=>Ce("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Ce(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Ce(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Ce("/cloud/devices"),getCloudFields:t=>Ce(`/cloud/fields/${t}`),getAllCloudFields:()=>Ce("/cloud/fields"),getFilamentInfo:t=>Ce("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Ce("/smart-plugs/"),getSmartPlug:t=>Ce(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Ce(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Ce("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Ce(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Ce(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Ce(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Ce(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Ce("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${xn}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>Ce("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${xn}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>Ce("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Ce("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Ce(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Ce("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Ce(`/queue/?${n}`)},getQueueItem:t=>Ce(`/queue/${t}`),addToQueue:t=>Ce("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Ce(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Ce(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Ce("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Ce(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Ce(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Ce(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Ce("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Ce(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Ce(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Ce(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Ce(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Ce(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Ce(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Ce(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Ce(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Ce(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Ce(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Ce(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Ce(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Ce(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Ce("/filaments/"),getFilament:t=>Ce(`/filaments/${t}`),getFilamentsByType:t=>Ce(`/filaments/by-type/${t}`),getNotificationProviders:()=>Ce("/notifications/"),getNotificationProvider:t=>Ce(`/notifications/${t}`),createNotificationProvider:t=>Ce("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Ce(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Ce(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Ce(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Ce("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Ce("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Ce("/notification-templates"),getNotificationTemplate:t=>Ce(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Ce(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Ce(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Ce("/notification-templates/variables"),previewTemplate:t=>Ce("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),Ce(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Ce(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Ce(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Ce("/spoolman/status"),connectSpoolman:()=>Ce("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Ce("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Ce(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Ce("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Ce("/spoolman/spools"),getSpoolmanFilaments:()=>Ce("/spoolman/filaments"),getUnlinkedSpools:()=>Ce("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Ce(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Ce("/updates/version"),checkForUpdates:()=>Ce("/updates/check"),applyUpdate:()=>Ce("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Ce("/updates/status"),getMaintenanceTypes:()=>Ce("/maintenance/types"),createMaintenanceType:t=>Ce("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Ce(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Ce(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Ce("/maintenance/overview"),getPrinterMaintenance:t=>Ce(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Ce(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Ce(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Ce(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Ce("/maintenance/summary"),setPrinterHours:(t,e)=>Ce(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Ce(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Ce(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${xn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${xn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Ce(`/printers/${t}/camera/test`),checkPlateEmpty:(t,e)=>{const n=new URLSearchParams;return n.set("use_external",String(e?.useExternal??!1)),n.set("include_debug_image",String(e?.includeDebugImage??!1)),Ce(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Ce(`/printers/${t}/camera/plate-detection/status`),calibratePlateDetection:(t,e)=>{const n=new URLSearchParams;return e?.label&&n.set("label",e.label),n.set("use_external",String(e?.useExternal??!1)),Ce(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Ce(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Ce(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${xn}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Ce(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Ce(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Ce("/external-links/"),getExternalLink:t=>Ce(`/external-links/${t}`),createExternalLink:t=>Ce("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Ce(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Ce(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Ce("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>Ce(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${xn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Ce(`/projects/?${e}`)},getProject:t=>Ce(`/projects/${t}`),createProject:t=>Ce("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Ce(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Ce(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Ce(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Ce(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Ce(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Ce(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${xn}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${xn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Ce(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Ce(`/projects/${t}/bom`),createBOMItem:(t,e)=>Ce(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Ce(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Ce(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Ce("/projects/templates/"),createTemplateFromProject:t=>Ce(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Ce(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Ce(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Ce(`/projects/${t}/export?format=json`),importProject:t=>Ce("/projects/import",{method:"POST",body:JSON.stringify(t)}),getAPIKeys:()=>Ce("/api-keys/"),createAPIKey:t=>Ce("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Ce(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Ce(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Ce(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Ce("/system/info"),getLibraryFolders:()=>Ce("/library/folders"),createLibraryFolder:t=>Ce("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Ce(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Ce(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Ce(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Ce(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Ce(`/library/files?${n}`)},getLibraryFile:t=>Ce(`/library/files/${t}`),uploadLibraryFile:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`?folder_id=${e}`:"",i=await fetch(`${xn}/library/files${r}`,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},extractZipFile:async(t,e,n=!0,r=!1)=>{const i=new FormData;i.append("file",t);const a=new URLSearchParams;e&&a.set("folder_id",String(e)),a.set("preserve_structure",String(n)),a.set("create_folder_from_zip",String(r));const o=await fetch(`${xn}/library/files/extract-zip?${a}`,{method:"POST",body:i});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.json()},updateLibraryFile:(t,e)=>Ce(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Ce(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${xn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${xn}/library/files/${t}/thumbnail`,getLibraryFileGcodeUrl:t=>`${xn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Ce("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Ce("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Ce("/library/stats"),addLibraryFilesToQueue:t=>Ce("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Ce(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Ce(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Ce(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Ce("/github-backup/config"),saveGitHubBackupConfig:t=>Ce("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Ce("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Ce("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Ce(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Ce("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Ce("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Ce("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Ce(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Ce(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},Ml={getInfo:()=>Ce("/discovery/info"),getStatus:()=>Ce("/discovery/status"),startDiscovery:(t=10)=>Ce(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Ce("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Ce("/discovery/printers"),startSubnetScan:(t,e=1)=>Ce("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Ce("/discovery/scan/status"),stopSubnetScan:()=>Ce("/discovery/scan/stop",{method:"POST"})},t1={getSettings:()=>Ce("/settings/virtual-printer"),getModels:()=>Ce("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),Ce(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Bp={list:()=>Ce("/pending-uploads/"),getCount:()=>Ce("/pending-uploads/count"),get:t=>Ce(`/pending-uploads/${t}`),archive:(t,e)=>Ce(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Ce(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Ce("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Ce("/pending-uploads/discard-all",{method:"DELETE"})},n1={checkUpdates:()=>Ce("/firmware/updates"),checkPrinterUpdate:t=>Ce(`/firmware/updates/${t}`),prepareUpload:t=>Ce(`/firmware/updates/${t}/prepare`),startUpload:t=>Ce(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Ce(`/firmware/updates/${t}/upload/status`)},ng={getDebugLoggingState:()=>Ce("/support/debug-logging"),setDebugLogging:t=>Ce("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${xn}/support/bundle`);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${t.status}`)}const n=t.headers.get("Content-Disposition")?.match(/filename=(.+)/),r=n?n[1]:"bambuddy-support.zip",i=await t.blob(),a=window.URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)},getLogs:t=>{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&e.set("level",t.level),t?.search&&e.set("search",t.search);const n=e.toString();return Ce(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Ce("/support/logs",{method:"DELETE"})},CK=w.createContext(void 0);function zme({children:t}){const[e,n]=w.useState(()=>{const E=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return E||D||"dark"}),[r,i]=w.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=w.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=w.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=w.useState(()=>localStorage.getItem("light-style")||"classic"),[f,m]=w.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,b]=w.useState(()=>localStorage.getItem("light-accent")||"green");w.useEffect(()=>{fe.getSettings().then(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),fe.updateSettings({dark_style:E}).catch(()=>{})},S=E=>{o(E),localStorage.setItem("dark-background",E),fe.updateSettings({dark_background:E}).catch(()=>{})},M=E=>{c(E),localStorage.setItem("dark-accent",E),fe.updateSettings({dark_accent:E}).catch(()=>{})},A=E=>{d(E),localStorage.setItem("light-style",E),fe.updateSettings({light_style:E}).catch(()=>{})},T=E=>{m(E),localStorage.setItem("light-background",E),fe.updateSettings({light_background:E}).catch(()=>{})},k=E=>{b(E),localStorage.setItem("light-accent",E),fe.updateSettings({light_accent:E}).catch(()=>{})};return s.jsx(CK.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 uh(){const t=w.useContext(CK);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 ir({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Mt({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 Qz({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}=Wg(),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(Mt,{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(xP,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(zr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(Qz,{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(Qz,{children:"Esc"})," or click outside to close"]})})]})})})}function Me({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",o={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function zn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",isLoading:a=!1,loadingText:o,onConfirm:l,onCancel:c}){w.useEffect(()=>{const f=m=>{m.key==="Escape"&&!a&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[c,a]);const d={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a?void 0:c,children:s.jsx(St,{className:"w-full max-w-md",onClick:f=>f.stopPropagation(),children:s.jsxs(Mt,{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(An,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Me,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:r}),s.jsx(Me,{onClick:l,className:`flex-1 ${d.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(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:()=>fe.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=mt({mutationFn:f=>fe.controlSmartPlug(t.id,f),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=i?.reachable??!1,u=o.isPending,d=()=>{n&&(o.mutate(n),r(null))};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`p-1.5 rounded ${c?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:s.jsx(Ws,{className:`w-4 h-4 ${c?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),s.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?s.jsx(dt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(tg,{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(Vf,{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(Zg,{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(Mu,{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(dN,{className:"w-4 h-4"})})]})]}),n&&s.jsx(zn,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:d,onCancel:()=>r(null)})]})}function Jz({onClose:t}){const{data:e,isLoading:n}=ut({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return s.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:s.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[s.jsx(Ws,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),s.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(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(Ws,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):s.jsx("div",{className:"space-y-1",children:r.map(i=>s.jsx(Hme,{plug:i},i.id))})})]})}const kK=[{name:"globe",icon:zd},{name:"link",icon:Yg},{name:"external-link",icon:zr},{name:"book",icon:$ue},{name:"file-text",icon:Ya},{name:"home",icon:oN},{name:"star",icon:Hf},{name:"heart",icon:Nhe},{name:"bookmark",icon:Vue},{name:"shopping-cart",icon:wK},{name:"music",icon:_P},{name:"video",icon:VD},{name:"image",icon:wy},{name:"camera",icon:zf},{name:"map",icon:Zhe},{name:"compass",icon:Cde},{name:"coffee",icon:Nde},{name:"gift",icon:fhe},{name:"wrench",icon:Qd},{name:"zap",icon:Vf},{name:"cloud",icon:nN},{name:"database",icon:iu},{name:"folder",icon:pK},{name:"mail",icon:Xhe},{name:"phone",icon:_fe},{name:"user",icon:SP},{name:"users",icon:hf},{name:"server",icon:Zh},{name:"terminal",icon:NK},{name:"code",icon:fK}];function mN(t){return kK.find(n=>n.name===t)?.icon||Yg}function Vme({value:t,onChange:e}){const[n,r]=w.useState(!1),i=mN(t);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[s.jsx(i,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),s.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:s.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:kK.map(({name:a,icon:o})=>s.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const eB=768;function jK(){const[t,e]=w.useState(()=>typeof window<"u"?window.innerWidth<eB:!1);return w.useEffect(()=>{const n=window.matchMedia(`(max-width: ${eB-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const PK=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 fe.getAuthStatus();if(!d.current)return;if(i(x.auth_enabled),o(x.requires_setup),x.auth_enabled)if(Zz())try{const S=await fe.getCurrentUser();if(!d.current)return;n(S)}catch{if(Ib(null),!d.current)return;n(null)}else n(null);else n(null)}catch{if(!d.current)return;i(!1),n(null)}finally{d.current&&c(!1)}};w.useEffect(()=>(d.current=!0,f(),()=>{d.current=!1}),[]),w.useEffect(()=>{if(!l&&a&&!r){const x=window.location.pathname;x!=="/setup"&&!x.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const m=async(x,v)=>{const S=await fe.login({username:x,password:v});Ib(S.access_token),n(S.user)},p=()=>{Ib(null),n(null),fe.logout().catch(()=>{}),window.location.href="/login"},b=async()=>{if(r&&Zz())try{const x=await fe.getCurrentUser();d.current&&n(x)}catch{Ib(null),d.current&&n(null)}},y=async()=>{await f()};return s.jsx(PK.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,login:m,logout:p,refreshUser:b,refreshAuth:y},children:t})}function dh(){const t=w.useContext(PK);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const P0=[{id:"printers",to:"/",icon:Wr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Ja,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:nN,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Qd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Aa,labelKey:"nav.projects"},{id:"files",to:"/files",icon:ll,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:hN,labelKey:"nav.settings"}];function Wme(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return P0.map(e=>e.id)}return P0.map(e=>e.id)}function qme(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function oT(t){return t.startsWith("ext-")}function RK(){return localStorage.getItem("defaultView")||"/"}function Kme(t){localStorage.setItem("defaultView",t)}function Xme(){const t=pl(),e=lc(),{mode:n,toggleMode:r}=uh(),{t:i}=Wg(),a=jK(),{user:o,authEnabled:l,logout:c}=dh(),[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),[D,C]=w.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[R,U]=w.useState(null),{data:O}=ut({queryKey:["version"],queryFn:fe.getVersion,staleTime:1/0}),{data:q}=ut({queryKey:["settings"],queryFn:fe.getSettings,staleTime:300*1e3}),{data:j}=ut({queryKey:["updateCheck"],queryFn:fe.checkForUpdates,enabled:q?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:W}=ut({queryKey:["external-links"],queryFn:fe.getExternalLinks}),{data:K}=ut({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs,staleTime:30*1e3}),G=K?.some(X=>X.show_in_switchbar)??!1,{data:Q}=ut({queryKey:["debugLogging"],queryFn:ng.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:te}=ut({queryKey:["queue","pending"],queryFn:()=>fe.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),J=te?.length??0,{data:z}=ut({queryKey:["pending-uploads","count"],queryFn:Bp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),V=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 he=w.useMemo(()=>new Map(P0.map(X=>[X.id,X])),[]),pe=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 ue of v)I&&ue==="settings"||(he.has(ue)||pe.has(ue))&&(X.push(ue),B.add(ue));for(const ue of P0)I&&ue.id==="settings"||B.has(ue.id)||(X.push(ue.id),B.add(ue.id));for(const ue of W||[]){const Ae=`ext-${ue.id}`;B.has(Ae)||(X.push(Ae),B.add(Ae))}return X})(),Ee=(X,B)=>{A(B),X.dataTransfer.effectAllowed="move",X.dataTransfer.setData("text/plain",B)},xe=(X,B)=>{X.preventDefault(),X.dataTransfer.dropEffect="move",k(B)},Ne=()=>{k(null)},_e=(X,B)=>{if(X.preventDefault(),M===null||M===B){A(null),k(null);return}const I=[...ie],ue=I.indexOf(M),Ae=I.indexOf(B);if(ue===-1||Ae===-1){A(null),k(null);return}I.splice(ue,1),I.splice(Ae,0,M),S(I),qme(I),A(null),k(null)},le=()=>{A(null),k(null)},Ve=j?.update_available&&j.latest_version&&j.latest_version!==D,H=()=>{j?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",j.latest_version),C(j.latest_version))};w.useEffect(()=>{if(!E.current&&e.pathname==="/"){const X=RK();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 ue=ie[I-1];if(X.preventDefault(),oT(ue)){const Ae=ue.replace("ext-","");t(`/external/${Ae}`)}else{const Ae=he.get(ue);Ae&&t(Ae.to)}return}switch(X.key){case"?":X.preventDefault(),b(!0);break;case"Escape":b(!1);break}}},[t,ie,he]);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(oT(X)){const I=pe.get(X);if(!I)return null;const ue=I.custom_icon?null:mN(I.icon);return s.jsx("li",{draggable:!0,onDragStart:Ae=>Ee(Ae,X),onDragOver:Ae=>xe(Ae,X),onDragLeave:Ne,onDrop:Ae=>_e(Ae,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(Lb,{to:`/external/${I.id}`,className:({isActive:Ae})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Ae?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?I.name:void 0,children:[u&&!a&&s.jsx(gg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),I.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${I.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):ue&&s.jsx(ue,{className:"w-5 h-5 flex-shrink-0"}),(a||u)&&s.jsx("span",{children:I.name})]})},X)}else{const I=he.get(X);if(!I)return null;const{to:ue,icon:Ae,labelKey:Ie}=I,ce=X==="queue"&&J>0,$=X==="archives"&&V>0,L=ce?J:$?V:0,Y=ce||$;return s.jsx("li",{draggable:!0,onDragStart:be=>Ee(be,X),onDragOver:be=>xe(be,X),onDragLeave:Ne,onDrop:be=>_e(be,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(Lb,{to:ue,className:({isActive:be})=>`flex items-center ${a||u?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${be?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!u?i(Ie):void 0,children:[u&&!a&&s.jsx(gg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ae,{className:"w-5 h-5 flex-shrink-0"}),Y&&s.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${$?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:L>99?"99+":L})]}),(a||u)&&s.jsx("span",{children:i(Ie)})]})},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(Bf,{className:"w-5 h-5"}):s.jsx(Zs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||u?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[G&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ws,{className:"w-5 h-5"})}),y&&s.jsx(Jz,{onClose:()=>x(!1)})]}),s.jsx(Lb,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zl,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(gP,{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(xP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(Yz,{className:"w-5 h-5"}):s.jsx(L1,{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(yP,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",O?.version||"..."]}),j?.update_available&&s.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:j.latest_version}),children:[s.jsx(iT,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j?.update_available&&s.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:j.latest_version}),children:s.jsx(iT,{className:"w-5 h-5"})}),G&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>x(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${y?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ws,{className:"w-5 h-5"})}),y&&s.jsx(Jz,{onClose:()=>x(!1)})]}),s.jsx(Lb,{to:"/system",className:({isActive:X})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${X?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Zl,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(gP,{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(xP,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(Yz,{className:"w-5 h-5"}):s.jsx(L1,{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(yP,{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(eN,{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"})})]})}),Ve&&s.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(iT,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:j?.latest_version,defaultValue:`Version ${j?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:H,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Ht,{className:"w-4 h-4"})})]}),s.jsx(lce,{})]}),p&&s.jsx($me,{onClose:()=>b(!1),sidebarItems:ie.map(X=>{if(oT(X)){const B=pe.get(X);return B?{type:"external",label:B.name}:null}else{const B=he.get(X);return B?{type:"nav",label:B.labelKey,labelKey:B.labelKey}:null}}).filter(Boolean)}),R&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:s.jsx("div",{className:"bg-bambu-dark-secondary border-2 border-yellow-500 rounded-xl shadow-2xl max-w-md w-full animate-in fade-in zoom-in duration-200",children:s.jsxs("div",{className:"p-6 text-center",children:[s.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:s.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),s.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:"Print Paused!"}),s.jsx("p",{className:"text-lg text-white mb-2",children:R.printer_name}),s.jsx("p",{className:"text-bambu-gray mb-6",children:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print."}),s.jsx("button",{onClick:()=>U(null),className:"w-full py-3 px-6 bg-yellow-500 hover:bg-yellow-600 text-black font-semibold rounded-lg transition-colors",children:"I Understand"})]})})})]})}function n0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Mi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function bg(t,e){const n=Mi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function yg(t,e="system",n){const r=Mi(t);if(!r)return"";const a=n0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Yme(t,e="system",n){const i=n0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const DK=w.createContext(void 0);function Gn(){const t=w.useContext(DK);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Zme={success:s.jsx(On,{className:"w-5 h-5 text-green-400"}),error:s.jsx(na,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(aa,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Zl,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(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(DK.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(Ht,{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 tB(t){if(t===0)return"0 GB";const e=t/(1024*1024*1024);return e>=1?`${e.toFixed(1)} GB`:`${(t/(1024*1024)).toFixed(0)} MB`}function tpe(t,e){if(e)return pK;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Mf;case"gcode":return Ya;case"mp4":case"avi":return Ud;case"png":case"jpg":case"jpeg":return wy;default:return rN}}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}=Gn(),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 j=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n]);const{data:v,isLoading:S,refetch:M}=ut({queryKey:["printerFiles",t,a],queryFn:()=>fe.getPrinterFiles(t,a)}),{data:A}=ut({queryKey:["printerStorage",t],queryFn:()=>fe.getPrinterStorage(t),staleTime:3e4}),T=mt({mutationFn:async j=>{for(const W of j)await fe.deletePrinterFile(t,W)},onSuccess:()=>{r(`Deleted ${f.length} file${f.length>1?"s":""}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(new Set),m([])},onError:j=>{r(`Delete failed: ${j.message}`,"error")}}),k=j=>{o(j),c(new Set)},E=()=>{if(a==="/")return;const j=a.split("/").filter(Boolean);j.pop(),o(j.length?"/"+j.join("/"):"/"),c(new Set)},D=(j,W)=>{W.stopPropagation(),c(K=>{const G=new Set(K);return G.has(j)?G.delete(j):G.add(j),G})},C=()=>{if(!v?.files)return;const j=v.files.filter(W=>!W.is_directory&&(!u||W.name.toLowerCase().includes(u.toLowerCase()))).map(W=>W.path);c(new Set(j))},R=()=>{c(new Set)},U=async()=>{if(l.size===0)return;const j=Array.from(l);if(j.length===1){window.open(fe.getPrinterFileDownloadUrl(t,j[0]),"_blank"),c(new Set);return}x({current:0,total:j.length});try{const W=await fe.downloadPrinterFilesAsZip(t,j),K=URL.createObjectURL(W),G=document.createElement("a");G.href=K,G.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(K),r(`Downloaded ${j.length} files as ZIP`),c(new Set)}catch(W){r(`Download failed: ${W instanceof Error?W.message:"Unknown error"}`,"error")}finally{x(null)}},O=()=>{l.size!==0&&m(Array.from(l))},q=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:j=>j.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(sN,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[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: ",tB(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: ",tB(A.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[q.map(j=>s.jsx("button",{onClick:()=>{k(j.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===j.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:j.label},j.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Na,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:j=>d(j.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsx(dK,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:p,onChange:j=>b(j.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",children:npe.map(j=>s.jsx("option",{value:j.value,children:j.label},j.value))})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>M(),disabled:S,children:s.jsx(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(Bf,{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(j=>!u||j.name.toLowerCase().includes(u.toLowerCase())).sort((j,W)=>{if(j.is_directory&&!W.is_directory)return-1;if(!j.is_directory&&W.is_directory)return 1;switch(p){case"name-asc":return j.name.localeCompare(W.name);case"name-desc":return W.name.localeCompare(j.name);case"size-asc":return j.size-W.size;case"size-desc":return W.size-j.size;case"date-asc":{const K=j.mtime?new Date(j.mtime).getTime():0,G=W.mtime?new Date(W.mtime).getTime():0;return K-G}case"date-desc":{const K=j.mtime?new Date(j.mtime).getTime():0;return(W.mtime?new Date(W.mtime).getTime():0)-K}default:return j.name.localeCompare(W.name)}}).map(j=>{const W=tpe(j.name,j.is_directory),K=l.has(j.path);return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${K?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{j.is_directory&&k(j.path)},children:[j.is_directory?null:s.jsx("button",{onClick:G=>D(j.path,G),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:K?s.jsx(Oo,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Lo,{className:"w-5 h-5"})}),s.jsx(W,{className:`w-5 h-5 flex-shrink-0 ${j.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:j.name}),!j.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:epe(j.size)}),j.is_directory&&s.jsx(Bf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},j.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:l.size>0?`${l.size} selected`:u?`${v?.files?.filter(j=>j.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${v?.files?.length||0} items`:`${v?.files?.length||0} items`}),v?.files?.some(j=>!j.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:l.size>0?s.jsxs("button",{onClick:R,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(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(Oo,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",disabled:l.size===0||y!==null,onClick:U,children:y?s.jsxs(s.Fragment,{children:[s.jsx(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(Me,{variant:"secondary",disabled:l.size===0||T.isPending,onClick:O,className:"text-red-400 hover:text-red-300",children:[T.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"Delete",l.size>1?` (${l.size})`:""]})]})]})]}),f.length>0&&s.jsx(zn,{title:f.length>1?`Delete ${f.length} Files`:"Delete File",message:f.length>1?`Delete ${f.length} selected files? This cannot be undone.`:`Delete "${f[0].split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{T.mutate(f)},onCancel:()=>m([])})]})}const ipe="embeddedCameraState_",nB=5,ape=2e3,spe=3e4,ope=5e3,lT={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 ye=localStorage.getItem(i);if(ye){const je=JSON.parse(ye);return{x:Math.min(Math.max(0,je.x),window.innerWidth-100),y:Math.min(Math.max(0,je.y),window.innerHeight-100),width:Math.max(200,Math.min(je.width,window.innerWidth-20)),height:Math.max(150,Math.min(je.height,window.innerHeight-20))}}}catch{}const oe=n*30;return{...lT,x:Math.max(0,lT.x-oe),y:Math.max(0,lT.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),[D,C]=w.useState({x:0,y:0}),[R,U]=w.useState(null),[O,q]=w.useState(null),[j,W]=w.useState(!1),[K,G]=w.useState(!0),[Q,te]=w.useState(Date.now()),[J,z]=w.useState(0),[V,ne]=w.useState(!1),[ae,he]=w.useState(0),pe=w.useRef(null),ie=w.useRef(null),Ee=w.useRef(null),xe=w.useRef(null),Ne=w.useRef(null),{data:_e}=ut({queryKey:["printer",t],queryFn:()=>fe.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`,ye=()=>{t>0&&!le.current&&(le.current=!0,navigator.sendBeacon(oe))},je=ie.current;return()=>{je&&(je.src=""),ye(),Ee.current&&clearTimeout(Ee.current),xe.current&&clearInterval(xe.current),Ne.current&&clearInterval(Ne.current)}},[t]),w.useEffect(()=>{if(K){const oe=setTimeout(()=>G(!1),3e3);return()=>clearTimeout(oe)}},[K,Q]);const Ve=w.useCallback(()=>{if(J>=nB){ne(!1),W(!0);return}const oe=Math.min(ape*Math.pow(2,J),spe);ne(!0),he(Math.ceil(oe/1e3)),xe.current=setInterval(()=>{he(ye=>ye<=1?(xe.current&&clearInterval(xe.current),0):ye-1)},1e3),Ee.current=setTimeout(()=>{z(ye=>ye+1),ne(!1),G(!0),W(!1),ie.current&&(ie.current.src=""),te(Date.now())},oe)},[J]);w.useEffect(()=>{if(K||V||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 ye=await oe.json();(ye.stalled||!ye.active&&!j)&&(Ne.current&&(clearInterval(Ne.current),Ne.current=null),G(!1),Ve())}}catch{}},ope),()=>{Ne.current&&(clearInterval(Ne.current),Ne.current=null)}},[K,j,V,b,t,Ve]),w.useEffect(()=>{const oe=()=>{const ye=!!document.fullscreenElement;v(ye),ye||(M(1),T({x:0,y:0}))};return document.addEventListener("fullscreenchange",oe),()=>document.removeEventListener("fullscreenchange",oe)},[]);const H=()=>{pe.current&&(document.fullscreenElement?document.exitFullscreen():pe.current.requestFullscreen())},ee=()=>{M(oe=>Math.min(oe+.5,4))},X=()=>{M(oe=>{const ye=Math.max(oe-.5,1);return ye===1&&T({x:0,y:0}),ye})},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}))},ue=w.useCallback(()=>{if(!pe.current||!ie.current)return{x:200,y:150};const oe=pe.current.getBoundingClientRect(),ye=oe.width*(S-1)/2,je=oe.height*(S-1)/2;return{x:Math.max(50,ye),y:Math.max(50,je)}},[S]),Ae=oe=>{if(k&&S>1){const ye=oe.clientX-D.x,je=oe.clientY-D.y,$e=ue();T({x:Math.max(-$e.x,Math.min($e.x,ye)),y:Math.max(-$e.y,Math.min($e.y,je))})}},Ie=()=>{E(!1)},ce=oe=>{if(oe.length<2)return 0;const ye=oe[0].clientX-oe[1].clientX,je=oe[0].clientY-oe[1].clientY;return Math.sqrt(ye*ye+je*je)},$=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},L=oe=>{oe.touches.length===2?(oe.preventDefault(),U(ce(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&&R!==null){oe.preventDefault();const ye=ce(oe.touches),je=ye/R;M(ft=>{const re=Math.max(1,Math.min(4,ft*je));return re===1&&T({x:0,y:0}),re}),U(ye);const $e=$(oe.touches);if(O){const ft=ue();T(re=>({x:Math.max(-ft.x,Math.min(ft.x,re.x+($e.x-O.x))),y:Math.max(-ft.y,Math.min(ft.y,re.y+($e.y-O.y)))}))}q($e)}else if(oe.touches.length===1&&k&&S>1){oe.preventDefault();const ye=oe.touches[0].clientX-D.x,je=oe.touches[0].clientY-D.y,$e=ue();T({x:Math.max(-$e.x,Math.min($e.x,ye)),y:Math.max(-$e.y,Math.min($e.y,je))})}},be=oe=>{oe.touches.length<2&&(U(null),q(null)),oe.touches.length===0&&E(!1)},Se=()=>{M(1),T({x:0,y:0})},se=()=>{G(!1),J<nB?Ve():W(!0)},Pe=()=>{G(!1),W(!1),z(0),ne(!1),Ee.current&&clearTimeout(Ee.current),xe.current&&clearInterval(xe.current)},Re=()=>{G(!0),W(!1),z(0),ne(!1),Ee.current&&clearTimeout(Ee.current),xe.current&&clearInterval(xe.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),ie.current&&(ie.current.src=""),setTimeout(()=>te(Date.now()),100)},Xe=oe=>{oe.target.closest(".no-drag")||(u(!0),p({x:oe.clientX-o.x,y:oe.clientY-o.y}))},et=oe=>{oe.stopPropagation(),f(!0)};w.useEffect(()=>{const oe=je=>{if(c)l($e=>({...$e,x:Math.max(0,Math.min(je.clientX-m.x,window.innerWidth-$e.width)),y:Math.max(0,Math.min(je.clientY-m.y,window.innerHeight-$e.height))}));else if(d&&pe.current){const $e=pe.current.getBoundingClientRect();l(ft=>({...ft,width:Math.max(200,Math.min(je.clientX-$e.left,window.innerWidth-ft.x-10)),height:Math.max(150,Math.min(je.clientY-$e.top,window.innerHeight-ft.y-10))}))}},ye=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ye),()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ye)}},[c,d,m]);const Je=`/api/v1/printers/${t}/camera/stream?fps=10&t=${Q}`;return s.jsxs("div",{ref:pe,className:`${x?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:x?void 0:{left:o.x,top:o.y,width:b?200:o.width,height:b?40:o.height,cursor:c?"grabbing":"default"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing",onMouseDown:Xe,children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(gg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:_e?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:Re,disabled:K||V,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(vK,{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(bK,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(yK,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:s.jsx(Ht,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!b&&s.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:B,onMouseMove:Ae,onMouseUp:Ie,onMouseLeave:Ie,onTouchStart:L,onTouchMove:Y,onTouchEnd:be,style:{touchAction:"none"},children:[K&&!V&&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"})}),V&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Zg,{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..."]})]})}),j&&!V&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(An,{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:Re,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:Je,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:se,onLoad:Pe,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(WD,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:Se,className:"px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]",title:"Reset zoom",children:[Math.round(S*100),"%"]}),s.jsx("button",{onClick:ee,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(GD,{className:"w-3.5 h-3.5 text-white"})})]}),!x&&s.jsx("div",{className:"absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors",onMouseDown:et,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function 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:()=>fe.getMQTTLogs(t),refetchInterval:1e3}),x=mt({mutationFn:()=>fe.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=mt({mutationFn:()=>fe.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=mt({mutationFn:()=>fe.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});w.useEffect(()=>{const C=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[n]),w.useEffect(()=>{i&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[p?.logs,i]);const M=C=>{l(R=>{const U=new Set(R);return U.has(C)?U.delete(C):U.add(C),U})},A=C=>new Date(C).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(C,R)=>{if(C==null)return"<empty>";const U=typeof C=="string"?JSON.parse(C):C,O=JSON.stringify(U,null,R?2:0);return!R&&O.length>100?O.substring(0,100)+"...":O},k=p?.logging_enabled??!1,E=w.useMemo(()=>p?.logs??[],[p?.logs]),D=w.useMemo(()=>E.filter(C=>{if(d!=="all"&&C.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),U=C.topic.toLowerCase().includes(R),q=JSON.stringify(C.payload).toLowerCase().includes(R);return U||q}return!0}),[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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[k?s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Lo,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Me,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[s.jsx(Do,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending||E.length===0,children:[s.jsx(un,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Me,{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:[D.length,"/",E.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Na,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:C=>u(C.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&s.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Ht,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),s.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(T0,{className:"w-3 h-3"}),"In"]}),s.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(pg,{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'})]}):D.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages match your filter"}),s.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):s.jsx("div",{className:"space-y-1",children:D.map((C,R)=>{const U=o.has(R),O=C.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${U?"bg-bambu-dark-secondary":""}`,onClick:()=>M(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:A(C.timestamp)}),s.jsx("span",{className:`shrink-0 ${O?"text-blue-400":"text-green-400"}`,title:O?"Incoming":"Outgoing",children:O?s.jsx(T0,{className:"w-3 h-3"}):s.jsx(pg,{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)})]},R)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:k?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):s.jsx("span",{children:"Logging stopped"})}),s.jsx(Me,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const MP={"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:An};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:An};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:aa};default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Zl}}}function NP(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=NP(e.attr,n);return MP[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=NP(i.attr,a);return MP[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(An,{className:"w-5 h-5 text-orange-400"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(aa,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:"No errors"})]}):s.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:o,color:l,bgColor:c,Icon:u}=upe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=NP(i.attr,d),m=MP[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=Mi(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:()=>fe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(gs,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(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(Xn,{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(Zs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function OK(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=OK(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Bn(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=OK(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 qD(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 LK(t){return typeof t!="string"?!1:bpe.has(t)}function IK(t){return typeof t=="string"&&t.startsWith("data-")}function ns(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(LK(n)||IK(n))&&(e[n]=t[n]);return e}function Gf(t){if(t==null)return null;if(w.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return ns(e)}return typeof t=="object"&&!Array.isArray(t)?ns(t):null}function Ta(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(LK(n)||IK(n)||qD(n))&&(e[n]=t[n]);return e}function ype(t){return t==null?null:w.isValidElement(t)?Ta(t.props):typeof t=="object"&&!Array.isArray(t)?Ta(t):null}var vpe=["children","width","height","viewBox","className","style","title","desc"];function EP(){return EP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},EP.apply(null,arguments)}function _pe(t,e){if(t==null)return{};var n,r,i=wpe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function wpe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var KD=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=Bn("recharts-surface",o);return w.createElement("svg",EP({},Ta(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 AP(){return AP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},AP.apply(null,arguments)}function 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 qr=w.forwardRef((t,e)=>{var{children:n,className:r}=t,i=Mpe(t,Spe),a=Bn("recharts-layer",r);return w.createElement("g",AP({className:a},Ta(i),{ref:e}),n)}),FK=w.createContext(null),Epe=()=>w.useContext(FK);function Er(t){return function(){return t}}const UK=Math.cos,U1=Math.sin,gl=Math.sqrt,z1=Math.PI,pN=2*z1,TP=Math.PI,CP=2*TP,Qh=1e-6,Ape=CP-Qh;function zK(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 zK;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?zK: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>Qh)if(!(Math.abs(f*c-u*d)>Qh)||!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((TP-Math.acos((y+m-x)/(2*v*S)))/2),A=M/S,T=M/v;Math.abs(A-1)>Qh&&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)>Qh||Math.abs(this._y1-d)>Qh)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%CP+CP),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>Qh&&this._append`A${r},${r},0,${+(m>=TP)},${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 XD(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 YD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function BK(t){this._context=t}BK.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}};function gN(t){return new BK(t)}function $K(t){return t[0]}function HK(t){return t[1]}function VK(t,e){var n=Er(!0),r=null,i=gN,a=null,o=XD(l);t=typeof t=="function"?t:t===void 0?$K:Er(t),e=typeof e=="function"?e:e===void 0?HK:Er(e);function l(c){var u,d=(c=YD(c)).length,f,m=!1,p;for(r==null&&(a=i(p=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===m&&((m=!m)?a.lineStart():a.lineEnd()),m&&a.point(+t(f,u,c),+e(f,u,c));if(p)return a=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Er(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Er(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Er(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function b_(t,e,n){var r=null,i=Er(!0),a=null,o=gN,l=null,c=XD(u);t=typeof t=="function"?t:t===void 0?$K:Er(+t),e=typeof e=="function"?e:Er(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?HK:Er(+n);function u(f){var m,p,b,y=(f=YD(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 VK().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Er(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Er(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Er(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Er(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Er(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Er(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Er(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),u):o},u.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),u):a},u}class GK{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 GK(t,!0)}function jpe(t){return new GK(t,!1)}const ZD={draw(t,e){const n=gl(e/z1);t.moveTo(n,0),t.arc(0,0,n,0,pN)}},Ppe={draw(t,e){const n=gl(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},WK=gl(1/3),Rpe=WK*2,Dpe={draw(t,e){const n=gl(e/Rpe),r=n*WK;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Ope={draw(t,e){const n=gl(e),r=-n/2;t.rect(r,r,n,n)}},Lpe=.8908130915292852,qK=U1(z1/10)/U1(7*z1/10),Ipe=U1(pN/10)*qK,Fpe=-UK(pN/10)*qK,Upe={draw(t,e){const n=gl(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=pN*a/5,l=UK(o),c=U1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},cT=gl(3),zpe={draw(t,e){const n=-gl(e/(cT*3));t.moveTo(0,n*2),t.lineTo(-cT*n,-n),t.lineTo(cT*n,-n),t.closePath()}},uo=-.5,ho=gl(3)/2,kP=1/gl(12),Bpe=(kP/2+1)*3,$pe={draw(t,e){const n=gl(e/Bpe),r=n/2,i=n*kP,a=r,o=n*kP+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(uo*r-ho*i,ho*r+uo*i),t.lineTo(uo*a-ho*o,ho*a+uo*o),t.lineTo(uo*l-ho*c,ho*l+uo*c),t.lineTo(uo*r+ho*i,uo*i-ho*r),t.lineTo(uo*a+ho*o,uo*o-ho*a),t.lineTo(uo*l+ho*c,uo*c-ho*l),t.closePath()}};function Hpe(t,e){let n=null,r=XD(i);t=typeof t=="function"?t:Er(t||ZD),e=typeof e=="function"?e:Er(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:Er(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Er(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function B1(){}function $1(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 KK(t){this._context=t}KK.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:$1(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:$1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Vpe(t){return new KK(t)}function XK(t){this._context=t}XK.prototype={areaStart:B1,areaEnd:B1,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:$1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Gpe(t){return new XK(t)}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(){(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:$1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Wpe(t){return new YK(t)}function ZK(t){this._context=t}ZK.prototype={areaStart:B1,areaEnd:B1,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 ZK(t)}function rB(t){return t<0?-1:1}function iB(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(rB(a)+rB(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function aB(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function uT(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,o-l*n,a,o)}function H1(t){this._context=t}H1.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:uT(this,this._t0,aB(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(t=+t,e=+e,!(t===this._x1&&e===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,uT(this,aB(this,n=iB(this,t,e)),n);break;default:uT(this,this._t0,n=iB(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function QK(t){this._context=new JK(t)}(QK.prototype=Object.create(H1.prototype)).point=function(t,e){H1.prototype.point.call(this,e,t)};function JK(t){this._context=t}JK.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 H1(t)}function Xpe(t){return new QK(t)}function eX(t){this._context=t}eX.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=sB(t),i=sB(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[o],e[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function sB(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function Ype(t){return new eX(t)}function xN(t,e){this._context=t,this._t=e}xN.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}break}}this._x=t,this._y=e}};function Zpe(t){return new xN(t,.5)}function Qpe(t){return new xN(t,0)}function Jpe(t){return new xN(t,1)}function Wf(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 jP(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=Er([]),e=jP,n=Wf,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=YD(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Er(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Er(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?jP:typeof a=="function"?a:Er(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Wf,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}Wf(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}Wf(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,Wf(t,e)}}var dT={},hT={},oB;function sge(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(hT)),hT}var fT={},lB;function tX(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}t.isDeepKey=e})(fT)),fT}var mT={},cB;function QD(){return cB||(cB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="string"||typeof n=="symbol"?n:Object.is(n?.valueOf?.(),-0)?"-0":String(n)}t.toKey=e})(mT)),mT}var pT={},gT={},uB;function oge(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(n==null)return"";if(typeof n=="string")return n;if(Array.isArray(n))return n.map(e).join(",");const r=String(n);return r==="0"&&Object.is(Number(n),-0)?"-0":r}t.toString=e})(gT)),gT}var dB;function JD(){return dB||(dB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oge(),n=QD();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(pT)),pT}var hB;function eO(){return hB||(hB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sge(),n=tX(),r=QD(),i=JD();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(dT)),dT}var xT,fB;function lge(){return fB||(fB=1,xT=eO().get),xT}var cge=lge();const qf=ml(cge);var uge=4;function kd(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+kd(l)+a:i+a},"")}var Ji=t=>t===0?0:t>0?1:-1,ul=t=>typeof t=="number"&&t!=+t,Kf=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,zt=t=>(typeof t=="number"||t instanceof Number)&&!ul(t),Io=t=>zt(t)||typeof t=="string",dge=0,R0=t=>{var e=++dge;return"".concat(t||"").concat(e)},Ba=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!zt(e)&&typeof e!="string")return r;var a;if(Kf(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return ul(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},nX=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 Jn(t,e,n){return zt(t)&&zt(e)?kd(t+n*(e-t)):e}function rX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):qf(r,e))===n)}var Vr=t=>t===null||typeof t>"u",Sy=t=>Vr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function vs(t){return t!=null}function hh(){}var hge=["type","size","sizeType"];function PP(){return PP=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},PP.apply(null,arguments)}function mB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mB(Object(n),!0).forEach(function(r){fge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 iX={symbolCircle:ZD,symbolCross:Ppe,symbolDiamond:Dpe,symbolSquare:Ope,symbolStar:Upe,symbolTriangle:zpe,symbolWye:$pe},bge=Math.PI/180,yge=t=>{var e="symbol".concat(Sy(t));return iX[e]||ZD},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)=>{iX["symbol".concat(Sy(t))]=e},tO=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=gge(t,hge),a=pB(pB({},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=Ta(a);return zt(u)&&zt(d)&&zt(n)?w.createElement("path",PP({},f,{className:Bn("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};tO.registerSymbol=_ge;var aX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,nO=(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=>{qD(i)&&(r[i]=(a=>n[i](n,a)))}),r},wge=(t,e,n)=>r=>(t(e,n,r),null),My=(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];qD(i)&&typeof a=="function"&&(r||(r={}),r[i]=wge(a,e,n))}),r};function gB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sge(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gB(Object(n),!0).forEach(function(r){Mge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 Kr(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 V1(){return V1=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},V1.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 Age(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){Tge(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 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 xo=32,jge={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Pge(t){var{data:e,iconType:n,inactiveColor:r}=t,i=xo/2,a=xo/6,o=xo/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return w.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:xo,y2:i,className:"recharts-legend-icon"})}if(c==="line")return w.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(xo,"M").concat(2*o,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return w.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(xo/8,"h").concat(xo,"v").concat(xo*3/4,"h").concat(-xo,"z"),className:"recharts-legend-icon"});if(w.isValidElement(e.legendIcon)){var d=Age({},e);return delete d.legendIcon,w.cloneElement(e.legendIcon,d)}return w.createElement(tO,{fill:l,cx:i,cy:i,size:xo,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:xo,height:xo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var m=d.formatter||i,p=Bn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var b=d.inactive?a:d.color,y=m?m(d.value,d,f):d.value;return w.createElement("li",V1({className:p,style:c,key:"legend-item-".concat(f)},My(t,d,f)),w.createElement(KD,{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=Kr(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,V1({},e,{payload:n})))},bT={},yT={},bB;function Oge(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],l=r(o,a,n);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(yT)),yT}var vT={},yB;function Lge(){return yB||(yB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return function(...i){return n.apply(this,i.slice(0,r))}}t.ary=e})(vT)),vT}var _T={},vB;function sX(){return vB||(vB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(_T)),_T}var wT={},ST={},MT={},_B;function Ige(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(MT)),MT}var wB;function rO(){return wB||(wB=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})(ST)),ST}var NT={},SB;function Fge(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(NT)),NT}var MB;function Uge(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rO(),n=Fge();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(wT)),wT}var ET={},AT={},NB;function zge(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eO();function n(r){return function(i){return e.get(i,r)}}t.property=n})(AT)),AT}var TT={},CT={},kT={},jT={},EB;function oX(){return EB||(EB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(jT)),jT}var PT={},AB;function lX(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null||typeof n!="object"&&typeof n!="function"}t.isPrimitive=e})(PT)),PT}var RT={},TB;function cX(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.isEqualsSameValueZero=e})(RT)),RT}var CB;function Bge(){return CB||(CB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oX(),n=lX(),r=cX();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})(kT)),kT}var kB;function uX(){return kB||(kB=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})(CT)),CT}var DT={},OT={},LT={},jB;function $ge(){return jB||(jB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}t.getSymbols=e})(LT)),LT}var IT={},PB;function iO(){return PB||(PB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}t.getTag=e})(IT)),IT}var FT={},RB;function dX(){return RB||(RB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",m="[object ArrayBuffer]",p="[object Object]",b="[object Error]",y="[object DataView]",x="[object Uint8Array]",v="[object Uint8ClampedArray]",S="[object Uint16Array]",M="[object Uint32Array]",A="[object BigUint64Array]",T="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",D="[object BigInt64Array]",C="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=b,t.float32ArrayTag=C,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=k,t.int32ArrayTag=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})(FT)),FT}var UT={},DB;function Hge(){return DB||(DB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(UT)),UT}var OB;function hX(){return OB||(OB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$ge(),n=iO(),r=dX(),i=lX(),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})(OT)),OT}var LB;function Vge(){return LB||(LB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hX();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(DT)),DT}var IB;function Gge(){return IB||(IB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uX(),n=Vge();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(TT)),TT}var zT={},BT={},$T={},FB;function Wge(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hX(),n=iO(),r=dX();function i(a,o){return e.cloneDeepWith(a,(l,c,u,d)=>{const f=o?.(l,c,u,d);if(f!==void 0)return f;if(typeof a=="object"){if(n.getTag(a)===r.objectTag&&typeof a.constructor!="function"){const m={};return d.set(a,m),e.copyProperties(m,a,u,d),m}switch(Object.prototype.toString.call(a)){case r.numberTag:case r.stringTag:case r.booleanTag:{const m=new a.constructor(a?.valueOf());return e.copyProperties(m,a),m}case r.argumentsTag:{const m={};return e.copyProperties(m,a),m.length=a.length,m[Symbol.iterator]=a[Symbol.iterator],m}default:return}}})}t.cloneDeepWith=i})($T)),$T}var UB;function qge(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Wge();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(BT)),BT}var HT={},VT={},zB;function fX(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return e.test(r)}}t.isIndex=n})(VT)),VT}var GT={},BB;function Kge(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iO();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(GT)),GT}var $B;function Xge(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tX(),n=fX(),r=Kge(),i=JD();function a(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(HT)),HT}var HB;function Yge(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uX(),n=QD(),r=qge(),i=eO(),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})(zT)),zT}var VB;function Zge(){return VB||(VB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sX(),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})(ET)),ET}var GB;function Qge(){return GB||(GB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Oge(),n=Lge(),r=sX(),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})(bT)),bT}var WT,WB;function Jge(){return WB||(WB=1,WT=Qge().uniqBy),WT}var exe=Jge();const qB=ml(exe);function mX(t,e,n){return e===!0?qB(t,n):typeof e=="function"?qB(t,e):t}var qT={exports:{}},KT={};var KB;function txe(){if(KB)return KT;KB=1;var t=Gg(),e=Nq();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return KT.useSyncExternalStoreWithSelector=function(u,d,f,m,p){var b=a(null);if(b.current===null){var y={hasValue:!1,value:null};b.current=y}else y=b.current;b=l(function(){function v(k){if(!S){if(S=!0,M=k,k=m(k),p!==void 0&&y.hasValue){var E=y.value;if(p(E,k))return A=E}return A=k}if(E=A,r(M,k))return E;var D=m(k);return p!==void 0&&p(E,D)?(M=k,E):(M=k,A=D)}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},KT}var XB;function nxe(){return XB||(XB=1,qT.exports=txe()),qT.exports}var pX=nxe(),aO=w.createContext(null),rxe=t=>t,Mr=()=>{var t=w.useContext(aO);return t?t.store.dispatch:rxe},r1=()=>{},ixe=()=>r1,axe=(t,e)=>t===e;function Vt(t){var e=w.useContext(aO),n=w.useMemo(()=>e?r=>{if(r!=null)return t(r)}:r1,[e,t]);return pX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:ixe,e?e.store.getState:r1,e?e.store.getState:r1,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 YB=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,ZB=1;function y_(){return{s:fxe,v:void 0,o:null,p:null}}function gX(t,e={}){let n=y_();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=y_(),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=y_(),b.set(p,l)):l=y}}const u=l;let d;if(l.s===ZB)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=ZB,u.v=d,d}return o.clearCache=()=>{n=y_(),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=gX,argsMemoizeOptions:b=[]}=d,y=YB(m),x=YB(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 tt=mxe(gX),pxe=Object.assign((t,e=tt)=>{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}),XT={},YT={},ZT={},QB;function gxe(){return QB||(QB=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})(ZT)),ZT}var QT={},JT={},JB;function xX(){return JB||(JB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(JT)),JT}var e8;function xxe(){return e8||(e8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xX(),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})(QT)),QT}var t8;function bxe(){return t8||(t8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gxe(),n=xxe(),r=JD();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,b)=>{let y=p;for(let x=0;x<b.length&&y!=null;++x)y=y[b[x]];return y},d=(p,b)=>b==null||p==null?b:typeof p=="object"&&"key"in p?Object.hasOwn(b,p.key)?b[p.key]:u(b,p.path):typeof p=="function"?p(b):Array.isArray(p)?u(b,p):typeof b=="object"?b[p]:b,f=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(b=>d(b,p))})).slice().sort((p,b)=>{for(let y=0;y<f.length;y++){const x=e.compareValues(p.criteria[y],b.criteria[y],l[y]);if(x!==0)return x}return 0}).map(p=>p.original)}t.orderBy=i})(YT)),YT}var eC={},n8;function yxe(){return n8||(n8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(eC)),eC}var tC={},r8;function bX(){return r8||(r8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fX(),n=rO(),r=oX(),i=cX();function a(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.isEqualsSameValueZero(c[l],o):!1}t.isIterateeCall=a})(tC)),tC}var i8;function vxe(){return i8||(i8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bxe(),n=yxe(),r=bX();function i(a,...o){const l=o.length;return l>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(a,n.flatten(o),["asc"])}t.sortBy=i})(XT)),XT}var nC,a8;function _xe(){return a8||(a8=1,nC=vxe().sortBy),nC}var wxe=_xe();const bN=ml(wxe);var yX=t=>t.legend.settings,Sxe=t=>t.legend.size,Mxe=t=>t.legend.payload,Nxe=tt([Mxe,yX],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?bN(r,n):r});function Exe(){return Vt(Nxe)}var v_=1;function vX(){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)>v_||Math.abs(o.left-e.left)>v_||Math.abs(o.top-e.top)>v_||Math.abs(o.width-e.width)>v_)&&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 xa(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",s8=Axe,rC=()=>Math.random().toString(36).substring(7).split("").join("."),Txe={INIT:`@@redux/INIT${rC()}`,REPLACE:`@@redux/REPLACE${rC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${rC()}`},G1=Txe;function sO(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 _X(t,e,n){if(typeof t!="function")throw new Error(xa(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(xa(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(xa(1));return n(_X)(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(xa(3));return i}function f(x){if(typeof x!="function")throw new Error(xa(4));if(c)throw new Error(xa(5));let v=!0;u();const S=l++;return o.set(S,x),function(){if(v){if(c)throw new Error(xa(6));v=!1,u(),o.delete(S),a=null}}}function m(x){if(!sO(x))throw new Error(xa(7));if(typeof x.type>"u")throw new Error(xa(8));if(typeof x.type!="string")throw new Error(xa(17));if(c)throw new Error(xa(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(xa(10));r=x,m({type:G1.REPLACE})}function b(){const x=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(xa(11));function S(){const A=v;A.next&&A.next(d())}return S(),{unsubscribe:x(S)}},[s8](){return this}}}return m({type:G1.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[s8]:b}}function Cxe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:G1.INIT})>"u")throw new Error(xa(12));if(typeof n(void 0,{type:G1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(xa(13))})}function wX(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(xa(14));u[f]=b,c=c||b!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function W1(...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(xa(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=W1(...l)(i.dispatch),{...i,dispatch:a}}}function SX(t){return sO(t)&&"type"in t&&typeof t.type=="string"}var MX=Symbol.for("immer-nothing"),o8=Symbol.for("immer-draftable"),rs=Symbol.for("immer-state");function Qo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Gs=Object,vg=Gs.getPrototypeOf,q1="constructor",yN="prototype",RP="configurable",K1="enumerable",i1="writable",D0="value",mu=t=>!!t&&!!t[rs];function dl(t){return t?NX(t)||_N(t)||!!t[o8]||!!t[q1]?.[o8]||wN(t)||SN(t):!1}var jxe=Gs[yN][q1].toString(),l8=new WeakMap;function NX(t){if(!t||!oO(t))return!1;const e=vg(t);if(e===null||e===Gs[yN])return!0;const n=Gs.hasOwnProperty.call(e,q1)&&e[q1];if(n===Object)return!0;if(!$p(n))return!1;let r=l8.get(n);return r===void 0&&(r=Function.toString.call(n),l8.set(n,r)),r===jxe}function vN(t,e,n=!0){Ny(t)===0?(n?Reflect.ownKeys(t):Gs.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Ny(t){const e=t[rs];return e?e.type_:_N(t)?1:wN(t)?2:SN(t)?3:0}var c8=(t,e,n=Ny(t))=>n===2?t.has(e):Gs[yN].hasOwnProperty.call(t,e),DP=(t,e,n=Ny(t))=>n===2?t.get(e):t[e],X1=(t,e,n,r=Ny(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 _N=Array.isArray,wN=t=>t instanceof Map,SN=t=>t instanceof Set,oO=t=>typeof t=="object",$p=t=>typeof t=="function",iC=t=>typeof t=="boolean";function Rxe(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var qc=t=>t.copy_||t.base_,lO=t=>t.modified_?t.copy_:t.base_;function OP(t,e){if(wN(t))return new Map(t);if(SN(t))return new Set(t);if(_N(t))return Array[yN].slice.call(t);const n=NX(t);if(e===!0||e==="class_only"&&!n){const r=Gs.getOwnPropertyDescriptors(t);delete r[rs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[i1]===!1&&(l[i1]=!0,l[RP]=!0),(l.get||l.set)&&(r[o]={[RP]:!0,[i1]:!0,[K1]:l[K1],[D0]:t[o]})}return Gs.create(vg(t),r)}else{const r=vg(t);if(r!==null&&n)return{...t};const i=Gs.create(r);return Gs.assign(i,t)}}function cO(t,e=!1){return MN(t)||mu(t)||!dl(t)||(Ny(t)>1&&Gs.defineProperties(t,{set:__,add:__,clear:__,delete:__}),Gs.freeze(t),e&&vN(t,(n,r)=>{cO(r,!0)},!1)),t}function Dxe(){Qo(2)}var __={[D0]:Dxe};function MN(t){return t===null||!oO(t)?!0:Gs.isFrozen(t)}var Y1="MapSet",LP="Patches",u8="ArrayMethods",EX={};function Xf(t){const e=EX[t];return e||Qo(0,t),e}var d8=t=>!!EX[t],O0,AX=()=>O0,Oxe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:d8(Y1)?Xf(Y1):void 0,arrayMethodsPlugin_:d8(u8)?Xf(u8):void 0});function h8(t,e){e&&(t.patchPlugin_=Xf(LP),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function IP(t){FP(t),t.drafts_.forEach(Lxe),t.drafts_=null}function FP(t){t===O0&&(O0=t.parent_)}var f8=t=>O0=Oxe(O0,t);function Lxe(t){const e=t[rs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function m8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[rs].modified_&&(IP(e),Qo(4)),dl(t)&&(t=p8(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[rs].base_,t,e)}else t=p8(e,n);return Ixe(e,t,!0),IP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==MX?t:void 0}function p8(t,e){if(MN(e))return e;const n=e[rs];if(!n)return Z1(e,t.handledSet_,t);if(!NN(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);kX(n,t)}return n.copy_}function Ixe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&cO(e,n)}function TX(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var NN=(t,e)=>t.scope_===e,Fxe=[];function CX(t,e,n,r){const i=qc(t),a=t.type_;if(r!==void 0&&DP(i,r,a)===e){X1(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;vN(i,(c,u)=>{if(mu(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)X1(i,l,n,a)}function Uxe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!NN(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=lO(a);CX(t,a.draft_??a,o,n),kX(a,i)})}function kX(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)}TX(t)}}function zxe(t,e,n){const{scope_:r}=t;if(mu(n)){const i=n[rs];NN(i,r)&&i.callbacks_.push(function(){a1(t);const o=lO(i);CX(t,n,o,e)})}else dl(n)&&t.callbacks_.push(function(){const a=qc(t);t.type_===3?a.has(n)&&Z1(n,r.handledSet_,r):DP(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&Z1(DP(t.copy_,e,t.type_),r.handledSet_,r)})}function Z1(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||mu(t)||e.has(t)||!dl(t)||MN(t)||(e.add(t),vN(t,(r,i)=>{if(mu(i)){const a=i[rs];if(NN(a,n)){const o=lO(a);X1(t,r,o,t.type_),TX(a)}}else dl(i)&&Z1(i,e,n)})),t}function Bxe(t,e){const n=_N(t),r={type_:n?1:0,scope_:e?e.scope_:AX(),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=Q1;n&&(i=[r],a=L0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var Q1={get(t,e){if(e===rs)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof e=="string";if(r&&n?.isArrayOperationMethod(e))return n.createMethodInterceptor(t,e);const i=qc(t);if(!c8(i,e,t.type_))return $xe(t,i,e);const a=i[e];if(t.finalized_||!dl(a)||r&&t.operationMethod&&n?.isMutatingArrayMethod(t.operationMethod)&&Rxe(e))return a;if(a===aC(t.base_,e)){a1(t);const o=t.type_===1?+e:e,l=zP(t.scope_,a,t,o);return t.copy_[o]=l}return a},has(t,e){return e in qc(t)},ownKeys(t){return Reflect.ownKeys(qc(t))},set(t,e,n){const r=jX(qc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=aC(qc(t),e),a=i?.[rs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Pxe(n,i)&&(n!==void 0||c8(t.base_,e,t.type_)))return!0;a1(t),UP(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 a1(t),aC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),UP(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=qc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[i1]:!0,[RP]:t.type_!==1||e!=="length",[K1]:r[K1],[D0]:n[e]}},defineProperty(){Qo(11)},getPrototypeOf(t){return vg(t.base_)},setPrototypeOf(){Qo(12)}},L0={};for(let t in Q1){let e=Q1[t];L0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}L0.deleteProperty=function(t,e){return L0.set.call(this,t,e,void 0)};L0.set=function(t,e,n){return Q1.set.call(this,t[0],e,n,t[0])};function aC(t,e){const n=t[rs];return(n?qc(n):t)[e]}function $xe(t,e,n){const r=jX(e,n);return r?D0 in r?r[D0]:r.get?.call(t.draft_):void 0}function jX(t,e){if(!(e in t))return;let n=vg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=vg(n)}}function UP(t){t.modified_||(t.modified_=!0,t.parent_&&UP(t.parent_))}function a1(t){t.copy_||(t.assigned_=new Map,t.copy_=OP(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($p(n)&&!$p(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}$p(r)||Qo(6),i!==void 0&&!$p(i)&&Qo(7);let a;if(dl(n)){const o=f8(this),l=zP(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?IP(o):FP(o)}return h8(o,i),m8(a,o)}else if(!n||!oO(n)){if(a=r(n),a===void 0&&(a=n),a===MX&&(a=void 0),this.autoFreeze_&&cO(a,!0),i){const o=[],l=[];Xf(LP).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Qo(1,n)},this.produceWithPatches=(n,r)=>{if($p(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},iC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),iC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),iC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){dl(e)||Qo(8),mu(e)&&(e=sl(e));const n=f8(this),r=zP(n,e,void 0);return r[rs].isManual_=!0,FP(n),r}finishDraft(e,n){const r=e&&e[rs];(!r||!r.isManual_)&&Qo(9);const{scope_:i}=r;return h8(i,n),m8(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=Xf(LP).applyPatches_;return mu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function zP(t,e,n,r){const[i,a]=wN(e)?Xf(Y1).proxyMap_(e,n):SN(e)?Xf(Y1).proxySet_(e,n):Bxe(e,n);return(n?.scope_??AX()).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 sl(t){return mu(t)||Qo(10,t),PX(t)}function PX(t){if(!dl(t)||MN(t))return t;const e=t[rs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=OP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=OP(t,!0);return vN(n,(i,a)=>{X1(n,i,PX(a))},r),e&&(e.finalized_=!1),n}var Vxe=new Hxe,RX=Vxe.produce;function DX(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Gxe=DX(),Wxe=DX,qxe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?W1:W1.apply(null,arguments)};function Fo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(qs(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>SX(r)&&r.type===t,n}var OX=class Fb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Fb.prototype)}static get[Symbol.species](){return Fb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Fb(...e[0].concat(this)):new Fb(...e.concat(this))}};function g8(t){return dl(t)?RX(t,()=>{}):t}function w_(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 OX;return n&&(Kxe(n)?o.push(Gxe):o.push(Wxe(n.extraArgument))),o},LX="RTK_autoBatch",Fr=()=>t=>({payload:t,meta:{[LX]:!0}}),x8=t=>e=>{setTimeout(e,t)},IX=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:x8(10):t.type==="callback"?t.queueNotification:x8(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),m=r.subscribe(f);return l.add(d),()=>{m(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[LX],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 OX(t);return r&&i.push(IX(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(sO(n))l=wX(n);else throw new Error(qs(1));let c;typeof r=="function"?c=r(e):c=e();let u=W1;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 _X(l,a,p)}function FX(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(qs(28));if(l in e)throw new Error(qs(29));return e[l]=o,i},addAsyncThunk(a,o){return o.pending&&(e[a.pending.type]=o.pending),o.rejected&&(e[a.rejected.type]=o.rejected),o.fulfilled&&(e[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function Qxe(t){return typeof t=="function"}function Jxe(t,e){let[n,r,i]=FX(e),a;if(Qxe(t))a=()=>g8(t());else{const l=g8(t);a=()=>l}function o(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(mu(d)){const p=f(d,c);return p===void 0?d:p}else{if(dl(d))return RX(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(qs(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(qs(12));if(T in c.sliceCaseReducersByType)throw new Error(qs(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"?FX(r.extraReducers):[r.extraReducers],k={...M,...c.sliceCaseReducersByType};return Jxe(r.initialState,E=>{for(let D in k)E.addCase(D,k[D]);for(let D of c.sliceMatchers)E.addMatcher(D.matcher,D.reducer);for(let D of A)E.addMatcher(D.matcher,D.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 D=E[M];return typeof D>"u"&&A&&(D=w_(p,T,x)),D}function k(E=f){const D=w_(m,A,()=>new WeakMap);return w_(D,E,()=>{const C={};for(const[R,U]of Object.entries(r.selectors??{}))C[R]=abe(U,E,()=>w_(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 Es=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(qs(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?Fo(t,o):Fo(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(qs(18));const{payloadCreator:a,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||S_,pending:l||S_,rejected:c||S_,settled:u||S_})}function S_(){}var dbe="task",UX="listener",zX="completed",uO="cancelled",hbe=`task-${uO}`,fbe=`task-${zX}`,BP=`${UX}-${uO}`,mbe=`${UX}-${zX}`,EN=class{constructor(t){this.code=t,this.message=`${dbe} ${uO} (reason: ${t})`}name="TaskAbortError";message},dO=(t,e)=>{if(typeof t!="function")throw new TypeError(qs(32))},J1=()=>{},BX=(t,e=J1)=>(t.catch(e),t),$X=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Nf=t=>{if(t.aborted)throw new EN(t.reason)};function HX(t,e){let n=J1;return new Promise((r,i)=>{const a=()=>i(new EN(t.reason));if(t.aborted){a();return}n=$X(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=J1})}var pbe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof EN?"cancelled":"rejected",error:n}}finally{e?.()}},eS=t=>e=>BX(HX(t,e).then(n=>(Nf(t),n))),VX=t=>{const e=eS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:rg}=Object,b8={},AN="listenerMiddleware",gbe=(t,e)=>{const n=r=>$X(t,()=>r.abort(t.reason));return(r,i)=>{dO(r);const a=new AbortController;n(a);const o=pbe(async()=>{Nf(t),Nf(a.signal);const l=await r({pause:eS(a.signal),delay:VX(a.signal),signal:a.signal});return Nf(a.signal),l},()=>a.abort(fbe));return i?.autoJoin&&e.push(o.catch(J1)),{result:eS(t)(o),cancel(){a.abort(hbe)}}}},xbe=(t,e)=>{const n=async(r,i)=>{Nf(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 HX(e,Promise.race(l));return Nf(e),c}finally{a()}};return(r,i)=>BX(n(r,i))},GX=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Fo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(qs(21));return dO(a),{predicate:i,type:e,effect:a}},WX=rg(t=>{const{type:e,predicate:n,effect:r}=GX(t);return{id:tbe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(qs(22))}}},{withTypes:()=>WX}),y8=(t,e)=>{const{type:n,effect:r,predicate:i}=GX(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},$P=t=>{t.pending.forEach(e=>{e.abort(BP)})},bbe=(t,e)=>()=>{for(const n of e.keys())$P(n);t.clear()},v8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},qX=rg(Fo(`${AN}/add`),{withTypes:()=>qX}),ybe=Fo(`${AN}/removeAll`),KX=rg(Fo(`${AN}/remove`),{withTypes:()=>KX}),vbe=(...t)=>{console.error(`${AN}/error`,...t)},Ey=(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;dO(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),b=>{p.unsubscribe(),b?.cancelActive&&$P(p)}),c=p=>{const b=y8(e,p)??WX(p);return l(b)};rg(c,{withTypes:()=>c});const u=p=>{const b=y8(e,p);return b&&(b.unsubscribe(),p.cancelActive&&$P(b)),!!b};rg(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,rg({},y,{getOriginalState:x,condition:(A,T)=>S(A,T).then(Boolean),take:S,delay:VX(v.signal),pause:eS(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(BP),k.delete(A))})},cancel:()=>{v.abort(BP),p.pending.delete(v)},throwIfCancelled:()=>{Nf(v.signal)}})))}catch(A){A instanceof EN||v8(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(!SX(y))return b(y);if(qX.match(y))return c(y.payload);if(ybe.match(y)){f();return}if(KX.match(y))return u(y.payload);let x=p.getState();const v=()=>{if(x===b8)throw new Error(qs(23));return x};let S;try{if(S=b(y),e.size>0){const M=p.getState(),A=Array.from(e.values());for(const T of A){let k=!1;try{k=T.predicate(y,M,x)}catch(E){k=!1,v8(o,E,{raisedBy:"predicate"})}k&&d(T,y,p,v)}}}finally{x=b8}return S},startListening:c,stopListening:u,clearListeners:f}};function qs(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var _be={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},XX=Es({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}=XX.actions,Ebe=XX.reducer;function YX(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function mn(t){return Number.isFinite(t)}function Jl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function _8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Kp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_8(Object(n),!0).forEach(function(r){Abe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 tr(t,e,n){return Vr(t)||Vr(e)?n:Io(e)?qf(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"&&zt(t[a]))return Kp(Kp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&zt(t[o]))return Kp(Kp({},t),{},{[o]:t[o]+(i||0)})}return t},xl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",ZX=(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},QX=(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?Ji(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 mn(A)?{coordinate:A+y,value:v,offset:y,index:S}:null}).filter(vs);return x}return c&&u?u.map((v,S)=>{var M=o.map(v);return mn(M)?{coordinate:M+y,value:v,index:S,offset:y}:null}).filter(vs):o.ticks&&d!=null?o.ticks(d).map((v,S)=>{var M=o.map(v);return mn(M)?{coordinate:M+y,value:v,index:S,offset:y}:null}).filter(vs):o.domain().map((v,S)=>{var M=o.map(v);return mn(M)?{coordinate:M+y,value:r?r[v]:v,index:S,offset:y}:null}).filter(vs)},jbe=(t,e)=>{if(!e||e.length!==2||!zt(e[0])||!zt(e[1]))return t;var n=Math.min(e[0],e[1]),r=Math.max(e[0],e[1]),i=[t[0],t[1]];return(!zt(t[0])||t[0]<n)&&(i[0]=n),(!zt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},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=ul(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=ul(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:Wf,silhouette:ige,wiggle:age,positive:Rbe},Obe=(t,e,n)=>{var r,i=(r=Dbe[n])!==null&&r!==void 0?r:Wf,a=nge().keys(e).value((l,c)=>Number(tr(l,c,0))).order(jP).offset(i),o=a(t);return o.forEach((l,c)=>{l.forEach((u,d)=>{var f=tr(t[d],e[c],0);Array.isArray(f)&&f.length===2&&zt(f[0])&&zt(f[1])&&(u[0]=f[0],u[1]=f[1])})}),o};function JX(t){return t==null?void 0:String(t)}function tS(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=rX(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=tr(i,Vr(o)?e.dataKey:o),u=e.scale.map(c);return zt(u)?u:null}var w8=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=tr(a,e.dataKey,e.scale.domain()[o]);if(Vr(l))return null;var c=e.scale.map(l);return zt(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(zt);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=YX(u,e,n),f=Ibe(d);return!mn(f[0])||!mn(f[1])?c:[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},S8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,M8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Jd=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=bN(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c?.coordinate||0)-(u?.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function N8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return Kp(Kp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function fh(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,Nu=t=>t.layout.width,Eu=t=>t.layout.height,$be=t=>t.layout.scale,eY=t=>t.layout.margin,TN=tt(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),CN=tt(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),tY="data-recharts-item-index",nY="data-recharts-item-id",Ay=60;function E8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function M_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E8(Object(n),!0).forEach(function(r){Hbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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=CN(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Ay;return n+i}return n},0)}function Kbe(t){var e=CN(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Ay;return n+i}return n},0)}function Xbe(t){var e=TN(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Ybe(t){var e=TN(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var Ui=tt([Nu,Eu,eY,Wbe,qbe,Kbe,Xbe,Ybe,yX,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=M_(M_({},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 M_(M_({brushBottom:p},m),{},{width:Math.max(b,0),height:Math.max(y,0)})}),Zbe=tt(Ui,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),hO=tt(Nu,Eu,(t,e)=>({x:0,y:0,width:t,height:e})),Qbe=w.createContext(null),zi=()=>w.useContext(Qbe)!=null,kN=t=>t.brush,jN=tt([kN,Ui,eY],(t,e,n)=>({height:t.height,x:zt(t.x)?t.x:e.left,y:zt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:zt(t.width)?t.width:e.width})),sC={},oC={},lC={},A8;function Jbe(){return A8||(A8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),y()};let m=null;const p=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},r)},b=()=>{m!==null&&(clearTimeout(m),m=null)},y=()=>{b(),o=void 0,l=null},x=()=>{d()},v=function(...S){if(i?.aborted)return;o=this,l=S;const M=m==null;p(),c&&M&&d()};return v.schedule=p,v.cancel=y,v.flush=x,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(lC)),lC}var T8;function e0e(){return T8||(T8=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})(oC)),oC}var C8;function t0e(){return C8||(C8=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})(sC)),sC}var cC,k8;function n0e(){return k8||(k8=1,cC=t0e().throttle),cC}var r0e=n0e();const i0e=ml(r0e);var nS=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},zl={width:"100%",height:"100%",debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},rY=(t,e,n)=>{var{width:r=zl.width,height:i=zl.height,aspect:a,maxHeight:o}=n,l=Kf(r)?t:Number(r),c=Kf(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=Kf(e),i=Kf(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=zl.width,a=zl.height):i===void 0?i=r&&r>0?void 0:zl.width:a===void 0&&(a=r&&r>0?void 0:zl.height),{width:i,height:a}}function HP(){return HP=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},HP.apply(null,arguments)}function j8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function P8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j8(Object(n),!0).forEach(function(r){d0e(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 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 iY=w.createContext(zl.initialDimension);function m0e(t){return Jl(t.width)&&Jl(t.height)}function aY(t){var{children:e,width:n,height:r}=t,i=w.useMemo(()=>({width:n,height:r}),[n,r]);return m0e(i)?w.createElement(iY.Provider,{value:i},e):null}var fO=()=>w.useContext(iY),p0e=w.forwardRef((t,e)=>{var{aspect:n,initialDimension:r=zl.initialDimension,width:i,height:a,minWidth:o=zl.minWidth,minHeight:l,maxHeight:c,children:u,debounce:d=zl.debounce,id:f,className:m,onResize:p,style:b={}}=t,y=w.useRef(null),x=w.useRef();x.current=p,w.useImperativeHandle(e,()=>y.current);var[v,S]=w.useState({containerWidth:r.width,containerHeight:r.height}),M=w.useCallback((D,C)=>{S(R=>{var U=Math.round(D),O=Math.round(C);return R.containerWidth===U&&R.containerHeight===O?R:{containerWidth:U,containerHeight:O}})},[]);w.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return hh;var D=O=>{var q,j=O[0];if(j!=null){var{width:W,height:K}=j.contentRect;M(W,K),(q=x.current)===null||q===void 0||q.call(x,W,K)}};d>0&&(D=i0e(D,d,{trailing:!0,leading:!1}));var C=new ResizeObserver(D),{width:R,height:U}=y.current.getBoundingClientRect();return M(R,U),C.observe(y.current),()=>{C.disconnect()}},[M,d]);var{containerWidth:A,containerHeight:T}=v;nS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:k,calculatedHeight:E}=rY(A,T,{width:i,height:a,aspect:n,maxHeight:c});return nS(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:Bn("recharts-responsive-container",m),style:P8(P8({},b),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},w.createElement("div",{style:c0e({width:i,height:a})},w.createElement(aY,{width:k,height:E},u)))}),s1=w.forwardRef((t,e)=>{var n=fO();if(Jl(n.width)&&Jl(n.height))return t.children;var{width:r,height:i}=u0e({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=rY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return zt(a)&&zt(o)?w.createElement(aY,{width:a,height:o},t.children):w.createElement(p0e,HP({},t,{width:r,height:i,ref:e}))});function mO(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 Ty=()=>{var t,e=zi(),n=Vt(Zbe),r=Vt(jN),i=(t=Vt(kN))===null||t===void 0?void 0:t.padding;return!e||!r||!i?n:{width:r.width-i.left-i.right,height:r.height-i.top-i.bottom,x:i.left,y:i.top}},g0e={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},sY=()=>{var t;return(t=Vt(Ui))!==null&&t!==void 0?t:g0e},pO=()=>Vt(Nu),gO=()=>Vt(Eu),x0e=()=>Vt(t=>t.layout.margin),Un=t=>t.layout.layoutType,mh=()=>Vt(Un),xO=()=>{var t=mh();if(t==="horizontal"||t==="vertical")return t},oY=t=>{var e=t.layout.layoutType;if(e==="centric"||e==="radial")return e},b0e=()=>{var t=mh();return t!==void 0},Cy=t=>{var e=Mr(),n=zi(),{width:r,height:i}=t,a=fO(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),w.useEffect(()=>{!n&&Jl(o)&&Jl(l)&&e(Mbe({width:o,height:l}))},[e,n,o,l]),null},lY=Symbol.for("immer-nothing"),R8=Symbol.for("immer-draftable"),Qs=Symbol.for("immer-state");function Jo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var I0=Object.getPrototypeOf;function _g(t){return!!t&&!!t[Qs]}function Yf(t){return t?cY(t)||Array.isArray(t)||!!t[R8]||!!t.constructor?.[R8]||ky(t)||RN(t):!1}var y0e=Object.prototype.constructor.toString(),D8=new WeakMap;function cY(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=D8.get(n);return r===void 0&&(r=Function.toString.call(n),D8.set(n,r)),r===y0e}function rS(t,e,n=!0){PN(t)===0?(n?Reflect.ownKeys(t):Object.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function PN(t){const e=t[Qs];return e?e.type_:Array.isArray(t)?1:ky(t)?2:RN(t)?3:0}function VP(t,e){return PN(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function uY(t,e,n){const r=PN(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 ky(t){return t instanceof Map}function RN(t){return t instanceof Set}function Jh(t){return t.copy_||t.base_}function GP(t,e){if(ky(t))return new Map(t);if(RN(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=cY(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Qs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(I0(t),r)}else{const r=I0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function bO(t,e=!1){return DN(t)||_g(t)||!Yf(t)||(PN(t)>1&&Object.defineProperties(t,{set:N_,add:N_,clear:N_,delete:N_}),Object.freeze(t),e&&Object.values(t).forEach(n=>bO(n,!0))),t}function _0e(){Jo(2)}var N_={value:_0e};function DN(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var w0e={};function Zf(t){const e=w0e[t];return e||Jo(0,t),e}var F0;function dY(){return F0}function S0e(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function O8(t,e){e&&(Zf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function WP(t){qP(t),t.drafts_.forEach(M0e),t.drafts_=null}function qP(t){t===F0&&(F0=t.parent_)}function L8(t){return F0=S0e(F0,t)}function M0e(t){const e=t[Qs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function I8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Qs].modified_&&(WP(e),Jo(4)),Yf(t)&&(t=iS(e,t),e.parent_||aS(e,t)),e.patches_&&Zf("Patches").generateReplacementPatches_(n[Qs].base_,t,e.patches_,e.inversePatches_)):t=iS(e,n,[]),WP(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==lY?t:void 0}function iS(t,e,n){if(DN(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Qs];if(!i)return rS(e,(a,o)=>F8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return aS(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),rS(o,(c,u)=>F8(t,i,a,c,u,n,l),r),aS(t,a,!1),n&&t.patches_&&Zf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function F8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=DN(i);if(!(l&&!o)){if(_g(i)){const c=a&&e&&e.type_!==3&&!VP(e.assigned_,r)?a.concat(r):void 0,u=iS(t,i,c);if(uY(n,r,u),_g(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(Yf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;iS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(ky(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&aS(t,i)}}}function aS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&bO(e,n)}function N0e(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:dY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=yO;n&&(i=[r],a=U0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var yO={get(t,e){if(e===Qs)return t;const n=Jh(t);if(!VP(n,e))return E0e(t,n,e);const r=n[e];return t.finalized_||!Yf(r)?r:r===uC(t.base_,e)?(dC(t),t.copy_[e]=XP(r,t)):r},has(t,e){return e in Jh(t)},ownKeys(t){return Reflect.ownKeys(Jh(t))},set(t,e,n){const r=hY(Jh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=uC(Jh(t),e),a=i?.[Qs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(v0e(n,i)&&(n!==void 0||VP(t.base_,e)))return!0;dC(t),KP(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return uC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,dC(t),KP(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Jh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Jo(11)},getPrototypeOf(t){return I0(t.base_)},setPrototypeOf(){Jo(12)}},U0={};rS(yO,(t,e)=>{U0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});U0.deleteProperty=function(t,e){return U0.set.call(this,t,e,void 0)};U0.set=function(t,e,n){return yO.set.call(this,t[0],e,n,t[0])};function uC(t,e){const n=t[Qs];return(n?Jh(n):t)[e]}function E0e(t,e,n){const r=hY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function hY(t,e){if(!(e in t))return;let n=I0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=I0(n)}}function KP(t){t.modified_||(t.modified_=!0,t.parent_&&KP(t.parent_))}function dC(t){t.copy_||(t.copy_=GP(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"&&Jo(6),r!==void 0&&typeof r!="function"&&Jo(7);let i;if(Yf(e)){const a=L8(this),o=XP(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?WP(a):qP(a)}return O8(a,r),I8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===lY&&(i=void 0),this.autoFreeze_&&bO(i,!0),r){const a=[],o=[];Zf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Jo(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){Yf(t)||Jo(8),_g(t)&&(t=T0e(t));const e=L8(this),n=XP(t,void 0);return n[Qs].isManual_=!0,qP(e),n}finishDraft(t,e){const n=t&&t[Qs];(!n||!n.isManual_)&&Jo(9);const{scope_:r}=n;return O8(r,e),I8(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=Zf("Patches").applyPatches_;return _g(t)?r(t,e):this.produce(t,i=>r(i,e))}};function XP(t,e){const n=ky(t)?Zf("MapSet").proxyMap_(t,e):RN(t)?Zf("MapSet").proxySet_(t,e):N0e(t,e);return(e?e.scope_:dY()).drafts_.push(n),n}function T0e(t){return _g(t)||Jo(10,t),fY(t)}function fY(t){if(!Yf(t)||DN(t))return t;const e=t[Qs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=GP(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=GP(t,!0);return rS(n,(i,a)=>{uY(n,i,fY(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:[]},mY=Es({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=sl(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Fr()},removeLegendPayload:{reducer(t,e){var n=sl(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Fr()}}}),{setLegendSize:U8,setLegendSettings:j0e,addLegendPayload:pY,replaceLegendPayload:gY,removeLegendPayload:xY}=mY.actions,P0e=mY.reducer,R0e=["contextPayload"];function YP(){return YP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},YP.apply(null,arguments)}function z8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function wg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z8(Object(n),!0).forEach(function(r){D0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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=mX(e,t.payloadUniqBy,U0e),i=wg(wg({},n),{},{payload:r});return w.isValidElement(t.content)?w.cloneElement(t.content,i):typeof t.content=="function"?w.createElement(t.content,i):w.createElement(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}),wg(wg({},u),d)}function $0e(t){var e=Mr();return w.useEffect(()=>{e(j0e(t))},[e,t]),null}function H0e(t){var e=Mr();return w.useEffect(()=>(e(U8(t)),()=>{e(U8({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 vO(t){var e=Kr(t,G0e),n=Exe(),r=Epe(),i=x0e(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=vX([n]),f=pO(),m=gO();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:wg(wg({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,YP({},e,b,{margin:i,chartWidth:f,chartHeight:m,contextPayload:n})));return Zc.createPortal(v,x)}vO.displayName="Legend";function ZP(){return ZP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ZP.apply(null,arguments)}function B8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B8(Object(n),!0).forEach(function(r){W0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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)&&Io(t[0])&&Io(t[1])?t.join(" ~ "):t}var Qm={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=Qm.separator,contentStyle:n,itemStyle:r,labelStyle:i=Qm.labelStyle,payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:m=Qm.accessibilityLayer}=t,p=()=>{if(a&&a.length){var T={padding:0,margin:0},k=(l?bN(a,l):a).map((E,D)=>{if(E.type==="none")return null;var C=E.formatter||o||X0e,{value:R,name:U}=E,O=R,q=U;if(C){var j=C(R,U,E,D,a);if(Array.isArray(j))[O,q]=j;else if(j!=null)O=j;else return null}var W=lb(lb({},Qm.itemStyle),{},{color:E.color||Qm.itemStyle.color},r);return w.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:W},Io(q)?w.createElement("span",{className:"recharts-tooltip-item-name"},q):null,Io(q)?w.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,w.createElement("span",{className:"recharts-tooltip-item-value"},O),w.createElement("span",{className:"recharts-tooltip-item-unit"},E.unit||""))});return w.createElement("ul",{className:"recharts-tooltip-item-list",style:T},k)}return null},b=lb(lb({},Qm.contentStyle),n),y=lb({margin:0},i),x=!Vr(d),v=x?d:"",S=Bn("recharts-default-tooltip",c),M=Bn("recharts-tooltip-label",u);x&&f&&a!==void 0&&a!==null&&(v=f(d,a));var A=m?{role:"status","aria-live":"assertive"}:{};return w.createElement("div",ZP({className:S,style:b},A),w.createElement("p",{className:M,style:y},w.isValidElement(v)?v:"".concat(v)),p())},cb="recharts-tooltip-wrapper",Z0e={visibility:"hidden"};function Q0e(t){var{coordinate:e,translateX:n,translateY:r}=t;return Bn(cb,{["".concat(cb,"-right")]:zt(n)&&e&&zt(e.x)&&n>=e.x,["".concat(cb,"-left")]:zt(n)&&e&&zt(e.x)&&n<e.x,["".concat(cb,"-bottom")]:zt(r)&&e&&zt(e.y)&&r>=e.y,["".concat(cb,"-top")]:zt(r)&&e&&zt(e.y)&&r<e.y})}function $8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offset:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&zt(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var m=c[r];if(m==null)return 0;if(o[r]){var p=d,b=m;return p<b?Math.max(f,m):Math.max(d,m)}if(u==null)return 0;var y=f+l,x=m+u;return y>x?Math.max(d,m):Math.max(f,m)}function 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=$8({allowEscapeViewBox:e,coordinate:n,key:"x",offset:i,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:u,viewBoxDimension:u.width}),m=$8({allowEscapeViewBox:e,coordinate:n,key:"y",offset:r,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:u,viewBoxDimension:u.height}),d=J0e({translateX:f,translateY:m,useTranslate3d:c})):d=Z0e,{cssProperties:d,cssClasses:Q0e({translateX:f,translateY:m,coordinate:n})}}function H8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function E_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H8(Object(n),!0).forEach(function(r){QP(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function QP(t,e,n){return(e=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),QP(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),QP(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:m,viewBox:p,wrapperStyle:b,lastBoundingBox:y,innerRef:x,hasPortalFromProps:v}=this.props,S=typeof u=="number"?u:u.x,M=typeof u=="number"?u:u.y,{cssClasses: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?{}:E_(E_({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=E_(E_({},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 bY=()=>{var t;return(t=Vt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};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 V8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function G8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V8(Object(n),!0).forEach(function(r){iye(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 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 W8={curveBasisClosed:Gpe,curveBasisOpen:Wpe,curveBasis:Vpe,curveBumpX:kpe,curveBumpY:jpe,curveLinearClosed:qpe,curveLinear:gN,curveMonotoneX:Kpe,curveMonotoneY:Xpe,curveNatural:Ype,curveStep:Zpe,curveStepAfter:Jpe,curveStepBefore:Qpe},sS=t=>mn(t.x)&&mn(t.y),q8=t=>t.base!=null&&sS(t.base)&&sS(t),ub=t=>t.x,db=t=>t.y,oye=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Sy(t));if((n==="curveMonotone"||n==="curveBump")&&e){var r=W8["".concat(n).concat(e==="vertical"?"Y":"X")];if(r)return r}return W8[n]||gN},K8={connectNulls:!1,type:"linear"},lye=t=>{var{type:e=K8.type,points:n=[],baseLine:r,layout:i,connectNulls:a=K8.connectNulls}=t,o=oye(e,i),l=a?n.filter(sS):n;if(Array.isArray(r)){var c,u=n.map((b,y)=>G8(G8({},b),{},{base:r[y]}));i==="vertical"?c=b_().y(db).x1(ub).x0(b=>b.base.x):c=b_().x(ub).y1(db).y0(b=>b.base.y);var d=c.defined(q8).curve(o),f=a?u.filter(q8):u;return d(f)}var m;i==="vertical"&&zt(r)?m=b_().y(db).x1(ub).x0(r):zt(r)?m=b_().x(ub).y1(db).y0(r):m=VK().x(ub).y(db);var p=m.defined(sS).curve(o);return p(l)},ig=t=>{var{className:e,points:n,path:r,pathRef:i}=t,a=mh();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",JP({},ns(t),nO(t),{className:Bn("recharts-curve",e),d:l===null?void 0:l,ref:i}))},cye=["x","y","top","left","width","height","className"];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 X8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function uye(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X8(Object(n),!0).forEach(function(r){dye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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!zt(e)||!zt(n)||!zt(a)||!zt(o)||!zt(r)||!zt(i)?null:w.createElement("path",e3({},Ta(u),{className:Bn("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 Y8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Z8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y8(Object(n),!0).forEach(function(r){yye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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())),yY=(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))),z0=(t,e)=>Object.keys(e).reduce((n,r)=>Z8(Z8({},n),{},{[r]:t(r,e[r])}),{});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 Pi(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){Mye(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 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 oS=(t,e,n)=>t+(e-t)*n,t3=t=>{var{from:e,to:n}=t;return e!==n},vY=(t,e,n)=>{var r=z0((i,a)=>{if(t3(a)){var[o,l]=t(a.from,a.to,a.velocity);return Pi(Pi({},a),{},{from:o,velocity:l})}return a},e);return n<1?z0((i,a)=>t3(a)&&r[i]!=null?Pi(Pi({},a),{},{velocity:oS(a.velocity,r[i].velocity,n),from:oS(a.from,r[i].from,n)}):a,e):vY(t,r,n-1)};function Aye(t,e,n,r,i,a){var o,l=r.reduce((m,p)=>Pi(Pi({},m),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>z0((m,p)=>p.from,l),u=()=>!Object.values(l).filter(t3).length,d=null,f=m=>{o||(o=m);var p=m-o,b=p/n.dt;l=vY(n,l,b),i(Pi(Pi(Pi({},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:Pi(Pi({},f),{},{[m]:[p,b]})},{}),u,d=f=>{u||(u=f);var m=(f-u)/r,p=z0((y,x)=>oS(...x,n(m)),c);if(a(Pi(Pi(Pi({},t),e),p)),m<1)l=o.setTimeout(d);else{var b=z0((y,x)=>oS(...x,n(1)),c);a(Pi(Pi(Pi({},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(Pi(Pi({},t),e)),()=>{}):n.isStepper===!0?Aye(t,e,n,o,i,a):Tye(t,e,n,r,o,i,a)};var lS=1e-4,_Y=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],wY=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),J8=(t,e)=>n=>{var r=_Y(t,e);return wY(r,n)},kye=(t,e)=>n=>{var r=_Y(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return wY(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=J8(t,n),a=J8(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)<lS||b<lS)return a(f);f=l(f-p/b)}return a(f)};return c.isStepper=!1,c},e6=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)<lS&&Math.abs(f)<lS?[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 e6(t);case"spring":return Dye();default:if(t.split("(")[0]==="cubic-bezier")return e6(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),jy={isSsr:Bye()},$ye={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},t6={t:0},hC={t:1};function Qg(t){var e=Kr(t,$ye),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!jy.isSsr:n,f=zye(e.animationId,e.animationManager),[m,p]=w.useState(d?t6:hC),b=w.useRef(null);return w.useEffect(()=>{d||p(hC)},[d]),w.useEffect(()=>{if(!d||!r)return hh;var y=Cye(t6,hC,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 Jg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=w.useRef(R0(e)),r=w.useRef(t);return r.current!==t&&(n.current=R0(e),r.current=t),n.current}var Hye=["radius"],Vye=["radius"],n6,r6,i6,a6,s6,o6,l6,c6,u6,d6;function h6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function f6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h6(Object(n),!0).forEach(function(r){Gye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 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 m6(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 Nl(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var p6=(t,e,n,r,i)=>{var a=kd(n),o=kd(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(n6||(n6=Nl(["M",",",""])),t,e+c*m[0]),m[0]>0&&(f+=ri(r6||(r6=Nl(["A ",",",",0,0,",",",",",""])),m[0],m[0],d,t+u*m[0],e)),f+=ri(i6||(i6=Nl(["L ",",",""])),t+n-u*m[1],e),m[1]>0&&(f+=ri(a6||(a6=Nl(["A ",",",",0,0,",`,
- `,",",""])),m[1],m[1],d,t+n,e+c*m[1])),f+=ri(s6||(s6=Nl(["L ",",",""])),t+n,e+r-c*m[2]),m[2]>0&&(f+=ri(o6||(o6=Nl(["A ",",",",0,0,",`,
- `,",",""])),m[2],m[2],d,t+n-u*m[2],e+r)),f+=ri(l6||(l6=Nl(["L ",",",""])),t+u*m[3],e+r),m[3]>0&&(f+=ri(c6||(c6=Nl(["A ",",",",0,0,",`,
- `,",",""])),m[3],m[3],d,t,e+r-c*m[3])),f+="Z"}else if(l>0&&i===+i&&i>0){var v=Math.min(l,i);f=ri(u6||(u6=Nl(["M ",",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",",",`
- L `,",",`
- A `,",",",0,0,",",",","," Z"])),t,e+c*v,v,v,d,t+u*v,e,t+n-u*v,e,v,v,d,t+n,e+c*v,t+n,e+r-c*v,v,v,d,t+n-u*v,e+r,t+u*v,e+r,v,v,d,t,e+r-c*v)}else f=ri(d6||(d6=Nl(["M ",","," h "," v "," h "," Z"])),t,e,n,r,-n);return f},g6={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},SY=t=>{var e=Kr(t,g6),n=w.useRef(null),[r,i]=w.useState(-1);w.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:m,animationBegin:p,isAnimationActive:b,isUpdateAnimationActive:y}=e,x=w.useRef(l),v=w.useRef(c),S=w.useRef(a),M=w.useRef(o),A=w.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),T=Jg(A,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var k=Bn("recharts-rectangle",d);if(!y){var E=Ta(e),{radius:D}=E,C=m6(E,Hye);return w.createElement("path",cS({},C,{x:kd(a),y:kd(o),width:kd(l),height:kd(c),radius:typeof u=="number"?u:void 0,className:k,d:p6(a,o,l,c,u)}))}var R=x.current,U=v.current,O=S.current,q=M.current,j="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),K=yY(["strokeDasharray"],m,typeof f=="string"?f:g6.animationEasing);return w.createElement(Qg,{animationId:T,key:T,canBegin:r>0,duration:m,easing:f,isActive:y,begin:p},G=>{var Q=Jn(R,l,G),te=Jn(U,c,G),J=Jn(O,a,G),z=Jn(q,o,G);n.current&&(x.current=Q,v.current=te,S.current=J,M.current=z);var V;b?G>0?V={transition:K,strokeDasharray:W}:V={strokeDasharray:j}:V={strokeDasharray:W};var ne=Ta(e),{radius:ae}=ne,he=m6(ne,Vye);return w.createElement("path",cS({},he,{radius:typeof u=="number"?u:void 0,className:k,d:p6(J,z,Q,te,u),ref:n,style:f6(f6({},V),e.style)}))})};function x6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function b6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x6(Object(n),!0).forEach(function(r){Xye(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 uS=Math.PI/180,Qye=t=>t*180/Math.PI,Ei=(t,e,n,r)=>({x:t+Math.cos(-uS*r)*n,y:e+Math.sin(-uS*r)*n}),MY=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?b6(b6({},e),{},{radius:i,angle:nve(d,e)}):null};function NY(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=Ei(e,n,r,i),l=Ei(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}var y6,v6,_6,w6,S6,M6,N6;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 ff(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var ive=(t,e)=>{var n=Ji(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},A_=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)/uS,f=c?i:i+a*d,m=Ei(e,n,u,f),p=Ei(e,n,r,f),b=c?i-a*d:i,y=Ei(e,n,u*Math.cos(d*uS),b);return{center:m,circleTangency:p,lineTangency:y,theta:d}},EY=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=ive(a,o),c=a+l,u=Ei(e,n,i,a),d=Ei(e,n,i,c),f=ri(y6||(y6=ff(["M ",",",`
- A `,",",`,0,
- `,",",`,
- `,",",`
- `])),u.x,u.y,i,i,+(Math.abs(l)>180),+(a>c),d.x,d.y);if(r>0){var m=Ei(e,n,r,a),p=Ei(e,n,r,c);f+=ri(v6||(v6=ff(["L ",",",`
- A `,",",`,0,
- `,",",`,
- `,","," Z"])),p.x,p.y,r,r,+(Math.abs(l)>180),+(a<=c),m.x,m.y)}else f+=ri(_6||(_6=ff(["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=Ji(u-c),{circleTangency:f,lineTangency:m,theta:p}=A_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:b,lineTangency:y,theta:x}=A_({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(w6||(w6=ff(["M ",",",`
- a`,",",",0,0,1,",`,0
- a`,",",",0,0,1,",`,0
- `])),m.x,m.y,a,a,a*2,a,a,-a*2):EY({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S=ri(S6||(S6=ff(["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}=A_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:k,lineTangency:E,theta:D}=A_({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-D;if(C<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+=ri(M6||(M6=ff(["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(N6||(N6=ff(["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},AY=t=>{var e=Kr(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=Bn("recharts-sector",f),p=a-i,b=Ba(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=EY({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),w.createElement("path",n3({},Ta(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(aX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=Ei(r,i,a,l),u=Ei(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return NY(e)}}var fC={},mC={},pC={},E6;function lve(){return E6||(E6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xX();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(pC)),pC}var A6;function cve(){return A6||(A6=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})(mC)),mC}var T6;function uve(){return T6||(T6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bX(),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})(fC)),fC}var gC,C6;function dve(){return C6||(C6=1,gC=uve().range),gC}var hve=dve();const TY=ml(hve);function Bd(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 _O(t){let e,n,r;t.length!==2?(e=Bd,n=(l,c)=>Bd(t(l),c),r=(l,c)=>t(l)-c):(e=t===Bd||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 CY(t){return t===null?NaN:+t}function*pve(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const gve=_O(Bd),Py=gve.right;_O(CY).center;class k6 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(j6(this,e))}has(e){return super.has(j6(this,e))}set(e,n){return super.set(xve(this,e),n)}delete(e){return super.delete(bve(this,e))}}function j6({_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=Bd){if(t===Bd)return kY;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 kY(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 dS(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?dS(t,e,n*2):[l,c,u]}function r3(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?dS(e,t,n):dS(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 i3(t,e,n){return e=+e,t=+t,n=+n,dS(t,e,n)[2]}function a3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?i3(e,t,n):i3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function P6(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function R6(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function jY(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?kY: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));jY(t,e,p,b,i)}const a=t[e];let o=n,l=r;for(hb(t,n,e),i(t[r],a)>0&&hb(t,n,r);o<l;){for(hb(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?hb(t,n,l):(++l,hb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function hb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function Mve(t,e,n){if(t=Float64Array.from(pve(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return R6(t);if(e>=1)return P6(t);var r,i=(r-1)*e,a=Math.floor(i),o=P6(jY(t,a).subarray(0,a+1)),l=R6(t.subarray(a+1));return o+(l-o)*(i-a)}}function Nve(t,e,n=CY){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 Bo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Au(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 s3=Symbol("implicit");function wO(){var t=new k6,e=[],n=[],r=s3;function i(a){let o=t.get(a);if(o===void 0){if(r!==s3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new k6;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return wO(e,n).unknown(r)},Bo.apply(i,arguments),i}function SO(){var t=wO().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 SO(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},Bo.apply(f(),arguments)}function PY(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return PY(e())},t}function Ave(){return PY(SO.apply(null,arguments).paddingInner(1))}function MO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function RY(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Ry(){}var B0=.7,hS=1/B0,ag="\\s*([+-]?\\d+)\\s*",$0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Tve=/^#([0-9a-f]{3,8})$/,Cve=new RegExp(`^rgb\\(${ag},${ag},${ag}\\)$`),kve=new RegExp(`^rgb\\(${Wl},${Wl},${Wl}\\)$`),jve=new RegExp(`^rgba\\(${ag},${ag},${ag},${$0}\\)$`),Pve=new RegExp(`^rgba\\(${Wl},${Wl},${Wl},${$0}\\)$`),Rve=new RegExp(`^hsl\\(${$0},${Wl},${Wl}\\)$`),Dve=new RegExp(`^hsla\\(${$0},${Wl},${Wl},${$0}\\)$`),D6={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};MO(Ry,H0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:O6,formatHex:O6,formatHex8:Ove,formatHsl:Lve,formatRgb:L6,toString:L6});function O6(){return this.rgb().formatHex()}function Ove(){return this.rgb().formatHex8()}function Lve(){return DY(this).formatHsl()}function L6(){return this.rgb().formatRgb()}function H0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Tve.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?I6(e):n===3?new _s(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?T_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?T_(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 _s(e[1],e[2],e[3],1):(e=kve.exec(t))?new _s(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=jve.exec(t))?T_(e[1],e[2],e[3],e[4]):(e=Pve.exec(t))?T_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Rve.exec(t))?z6(e[1],e[2]/100,e[3]/100,1):(e=Dve.exec(t))?z6(e[1],e[2]/100,e[3]/100,e[4]):D6.hasOwnProperty(t)?I6(D6[t]):t==="transparent"?new _s(NaN,NaN,NaN,0):null}function I6(t){return new _s(t>>16&255,t>>8&255,t&255,1)}function T_(t,e,n,r){return r<=0&&(t=e=n=NaN),new _s(t,e,n,r)}function Ive(t){return t instanceof Ry||(t=H0(t)),t?(t=t.rgb(),new _s(t.r,t.g,t.b,t.opacity)):new _s}function o3(t,e,n,r){return arguments.length===1?Ive(t):new _s(t,e,n,r??1)}function _s(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}MO(_s,o3,RY(Ry,{brighter(t){return t=t==null?hS:Math.pow(hS,t),new _s(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?B0:Math.pow(B0,t),new _s(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new _s(Ef(this.r),Ef(this.g),Ef(this.b),fS(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:F6,formatHex:F6,formatHex8:Fve,formatRgb:U6,toString:U6}));function F6(){return`#${mf(this.r)}${mf(this.g)}${mf(this.b)}`}function Fve(){return`#${mf(this.r)}${mf(this.g)}${mf(this.b)}${mf((isNaN(this.opacity)?1:this.opacity)*255)}`}function U6(){const t=fS(this.opacity);return`${t===1?"rgb(":"rgba("}${Ef(this.r)}, ${Ef(this.g)}, ${Ef(this.b)}${t===1?")":`, ${t})`}`}function fS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Ef(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function mf(t){return t=Ef(t),(t<16?"0":"")+t.toString(16)}function z6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new el(t,e,n,r)}function DY(t){if(t instanceof el)return new el(t.h,t.s,t.l,t.opacity);if(t instanceof Ry||(t=H0(t)),!t)return new el;if(t instanceof el)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 el(o,l,c,t.opacity)}function Uve(t,e,n,r){return arguments.length===1?DY(t):new el(t,e,n,r??1)}function el(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}MO(el,Uve,RY(Ry,{brighter(t){return t=t==null?hS:Math.pow(hS,t),new el(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?B0:Math.pow(B0,t),new el(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new _s(xC(t>=240?t-240:t+120,i,r),xC(t,i,r),xC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new el(B6(this.h),C_(this.s),C_(this.l),fS(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=fS(this.opacity);return`${t===1?"hsl(":"hsla("}${B6(this.h)}, ${C_(this.s)*100}%, ${C_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function B6(t){return t=(t||0)%360,t<0?t+360:t}function C_(t){return Math.max(0,Math.min(1,t||0))}function xC(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const NO=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?OY:function(e,n){return n-e?Bve(e,n,t):NO(isNaN(e)?n:e)}}function OY(t,e){var n=e-t;return n?zve(t,n):NO(isNaN(t)?e:t)}const $6=(function t(e){var n=$ve(e);function r(i,a){var o=n((i=o3(i)).r,(a=o3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=OY(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]=ex(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(l){for(o=0;o<r;++o)a[o]=i[o](l);return a}}function Wve(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function mS(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]=ex(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var l3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,bC=new RegExp(l3.source,"g");function Kve(t){return function(){return t}}function Xve(t){return function(e){return t(e)+""}}function Yve(t,e){var n=l3.lastIndex=bC.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=l3.exec(t))&&(i=bC.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:mS(r,i)})),n=bC.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?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 ex(t,e){var n=typeof e,r;return e==null||n==="boolean"?NO(e):(n==="number"?mS:n==="string"?(r=H0(e))?(e=r,$6):Yve:e instanceof H0?$6:e instanceof Date?Wve:Vve(e)?Hve:Array.isArray(e)?Gve:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?qve:mS)(t,e)}function EO(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=ex);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[l](o-l)}}function Qve(t){return function(){return t}}function pS(t){return+t}var H6=[0,1];function Za(t){return t}function c3(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=c3(i,r),a=n(o,a)):(r=c3(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]=c3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Py(t,l,1,r)-1;return a[c](i[c](l))}}function Dy(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function ON(){var t=H6,e=H6,n=ex,r,i,a,o=Za,l,c,u;function d(){var m=Math.min(t.length,e.length);return o!==Za&&(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),mS)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,pS),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=EO,d()},f.clamp=function(m){return arguments.length?(o=m?!0:Za,d()):o!==Za},f.interpolate=function(m){return arguments.length?(n=m,d()):n},f.unknown=function(m){return arguments.length?(a=m,f):a},function(m,p){return r=m,i=p,d()}}function AO(){return ON()(Za,Za)}function n_e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function gS(t,e){if(!isFinite(t)||t===0)return null;var n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"),r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Sg(t){return t=gS(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 V0(t){if(!(e=a_e.exec(t)))throw new Error("invalid format: "+t);var e;return new TO({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]})}V0.prototype=TO.prototype;function TO(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+""}TO.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 xS;function o_e(t,e){var n=gS(t,e);if(!n)return xS=void 0,t.toPrecision(e);var r=n[0],i=n[1],a=i-(xS=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")+gS(t,Math.max(0,e+a-1))[0]}function V6(t,e){var n=gS(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const G6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d: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)=>V6(t*100,e),r:V6,s:o_e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function W6(t){return t}var q6=Array.prototype.map,K6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function l_e(t){var e=t.grouping===void 0||t.thousands===void 0?W6:r_e(q6.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?W6:i_e(q6.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f,m){f=V0(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"):G6[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():""),D=(x==="$"?r:/[%p]/.test(k)?o:"")+(m&&m.suffix!==void 0?m.suffix:""),C=G6[k],R=/[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(O){var q=E,j=D,W,K,G;if(k==="c")j=C(O)+j,O="";else{O=+O;var Q=O<0||1/O<0;if(O=isNaN(O)?c:C(Math.abs(O),A),T&&(O=s_e(O)),Q&&+O==0&&y!=="+"&&(Q=!1),q=(Q?y==="("?y:l:y==="-"||y==="("?"":y)+q,j=(k==="s"&&!isNaN(O)&&xS!==void 0?K6[8+xS/3]:"")+j+(Q&&y==="("?")":""),R){for(W=-1,K=O.length;++W<K;)if(G=O.charCodeAt(W),48>G||G>57){j=(G===46?i+O.slice(W+1):O.slice(W))+j,O=O.slice(0,W);break}}}M&&!v&&(O=e(O,1/0));var te=q.length+O.length+j.length,J=te<S?new Array(S-te+1).join(p):"";switch(M&&v&&(O=e(J+O,J.length?S-j.length:1/0),J=""),b){case"<":O=q+O+j+J;break;case"=":O=q+J+O+j;break;case"^":O=J.slice(0,te=J.length>>1)+q+O+j+J.slice(te);break;default:O=J+q+O+j;break}return a(O)}return U.toString=function(){return f+""},U}function d(f,m){var p=Math.max(-8,Math.min(8,Math.floor(Sg(m)/3)))*3,b=Math.pow(10,-p),y=u((f=V0(f),f.type="f",f),{suffix:K6[8+p/3]});return function(x){return y(b*x)}}return{format:u,formatPrefix:d}}var k_,CO,LY;c_e({thousands:",",grouping:[3],currency:["$",""]});function c_e(t){return k_=l_e(t),CO=k_.format,LY=k_.formatPrefix,k_}function u_e(t){return Math.max(0,-Sg(Math.abs(t)))}function d_e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Sg(e)/3)))*3-Sg(Math.abs(t)))}function h_e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Sg(e)-Sg(t))+1}function IY(t,e,n,r){var i=a3(t,e,n),a;switch(r=V0(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),LY(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 CO(r)}function ph(t){var e=t.domain;return t.ticks=function(n){var r=e();return r3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return IY(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=i3(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 FY(){var t=AO();return t.copy=function(){return Dy(t,FY())},Bo.apply(t,arguments),ph(t)}function UY(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,pS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return UY(t).unknown(e)},t=arguments.length?Array.from(t,pS):[0,1],ph(n)}function zY(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function X6(t){return Math.log(t)}function Y6(t){return Math.exp(t)}function 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 Z6(t){return(e,n)=>-t(-e,n)}function kO(t){const e=t(X6,Y6),n=e.domain;let r=10,i,a;function o(){return i=x_e(r),a=g_e(r),n()[0]<0?(i=Z6(i),a=Z6(a),t(f_e,m_e)):t(X6,Y6),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let m=i(u),p=i(d),b,y;const x=l==null?10:+l;let v=[];if(!(r%1)&&p-m<x){if(m=Math.floor(m),p=Math.ceil(p),u>0){for(;m<=p;++m)for(b=1;b<r;++b)if(y=m<0?b/a(-m):b*a(m),!(y<u)){if(y>d)break;v.push(y)}}else for(;m<=p;++m)for(b=r-1;b>=1;--b)if(y=m>0?b/a(-m):b*a(m),!(y<u)){if(y>d)break;v.push(y)}v.length*2<x&&(v=r3(u,d,x))}else v=r3(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=V0(c)).precision==null&&(c.trim=!0),c=CO(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(zY(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function BY(){const t=kO(ON()).domain([1,10]);return t.copy=()=>Dy(t,BY()).base(t.base()),Bo.apply(t,arguments),t}function Q6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function J6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function jO(t){var e=1,n=t(Q6(e),J6(e));return n.constant=function(r){return arguments.length?t(Q6(e=+r),J6(e)):e},ph(n)}function $Y(){var t=jO(ON());return t.copy=function(){return Dy(t,$Y()).constant(t.constant())},Bo.apply(t,arguments)}function e$(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 PO(t){var e=t(Za,Za),n=1;function r(){return n===1?t(Za,Za):n===.5?t(b_e,y_e):t(e$(n),e$(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},ph(e)}function RO(){var t=PO(ON());return t.copy=function(){return Dy(t,RO()).exponent(t.exponent())},Bo.apply(t,arguments),t}function v_e(){return RO.apply(null,arguments).exponent(.5)}function t$(t){return Math.sign(t)*t*t}function __e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function HY(){var t=AO(),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(t$(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,pS)).map(t$)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return HY(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},Bo.apply(i,arguments),ph(i)}function VY(){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[Py(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(Bd),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 VY().domain(t).range(e).unknown(r)},Bo.apply(a,arguments)}function GY(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Py(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 GY().domain([t,e]).range(i).unknown(a)},Bo.apply(ph(o),arguments)}function WY(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Py(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 WY().domain(t).range(e).unknown(n)},Bo.apply(i,arguments)}const yC=new Date,vC=new Date;function Bi(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=>Bi(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(yC.setTime(+a),vC.setTime(+o),t(yC),t(vC),Math.floor(n(yC,vC))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const bS=Bi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);bS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Bi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):bS);bS.range;const Qc=1e3,To=Qc*60,Jc=To*60,pu=Jc*24,DO=pu*7,n$=pu*30,_C=pu*365,pf=Bi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Qc)},(t,e)=>(e-t)/Qc,t=>t.getUTCSeconds());pf.range;const OO=Bi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Qc)},(t,e)=>{t.setTime(+t+e*To)},(t,e)=>(e-t)/To,t=>t.getMinutes());OO.range;const LO=Bi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*To)},(t,e)=>(e-t)/To,t=>t.getUTCMinutes());LO.range;const IO=Bi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Qc-t.getMinutes()*To)},(t,e)=>{t.setTime(+t+e*Jc)},(t,e)=>(e-t)/Jc,t=>t.getHours());IO.range;const FO=Bi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Jc)},(t,e)=>(e-t)/Jc,t=>t.getUTCHours());FO.range;const Oy=Bi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*To)/pu,t=>t.getDate()-1);Oy.range;const LN=Bi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/pu,t=>t.getUTCDate()-1);LN.range;const qY=Bi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/pu,t=>Math.floor(t/pu));qY.range;function hm(t){return Bi(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*To)/DO)}const IN=hm(0),yS=hm(1),w_e=hm(2),S_e=hm(3),Mg=hm(4),M_e=hm(5),N_e=hm(6);IN.range;yS.range;w_e.range;S_e.range;Mg.range;M_e.range;N_e.range;function fm(t){return Bi(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)/DO)}const FN=fm(0),vS=fm(1),E_e=fm(2),A_e=fm(3),Ng=fm(4),T_e=fm(5),C_e=fm(6);FN.range;vS.range;E_e.range;A_e.range;Ng.range;T_e.range;C_e.range;const UO=Bi(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());UO.range;const zO=Bi(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());zO.range;const gu=Bi(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());gu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Bi(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)});gu.range;const xu=Bi(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());xu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Bi(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)});xu.range;function KY(t,e,n,r,i,a){const o=[[pf,1,Qc],[pf,5,5*Qc],[pf,15,15*Qc],[pf,30,30*Qc],[a,1,To],[a,5,5*To],[a,15,15*To],[a,30,30*To],[i,1,Jc],[i,3,3*Jc],[i,6,6*Jc],[i,12,12*Jc],[r,1,pu],[r,2,2*pu],[n,1,DO],[e,1,n$],[e,3,3*n$],[t,1,_C]];function l(u,d,f){const m=d<u;m&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),b=p?p.range(u,+d+1):[];return m?b.reverse():b}function c(u,d,f){const m=Math.abs(d-u)/f,p=_O(([,,x])=>x).right(o,m);if(p===o.length)return t.every(a3(u/_C,d/_C,f));if(p===0)return bS.every(Math.max(a3(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]=KY(xu,zO,FN,qY,FO,LO),[P_e,R_e]=KY(gu,UO,IN,Oy,IO,OO);function wC(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function SC(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function fb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function 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=mb(i),d=pb(i),f=mb(a),m=pb(a),p=mb(o),b=pb(o),y=mb(l),x=pb(l),v=mb(c),S=pb(c),M={a:G,A:Q,b:te,B:J,c:null,d:l$,e:l$,f:rwe,g:fwe,G:pwe,H:ewe,I:twe,j:nwe,L:XY,m:iwe,M:awe,p:z,q:V,Q:d$,s:h$,S:swe,u:owe,U:lwe,V:cwe,w:uwe,W:dwe,x:null,X:null,y:hwe,Y:mwe,Z:gwe,"%":u$},A={a:ne,A:ae,b:he,B:pe,c:null,d:c$,e:c$,f:vwe,g:kwe,G:Pwe,H:xwe,I:bwe,j:ywe,L:ZY,m:_we,M:wwe,p:ie,q:Ee,Q:d$,s:h$,S:Swe,u:Mwe,U:Nwe,V:Ewe,w:Awe,W:Twe,x:null,X:null,y:Cwe,Y:jwe,Z:Rwe,"%":u$},T={a:R,A:U,b:O,B:q,c:j,d:s$,e:s$,f:Y_e,g:a$,G:i$,H:o$,I:o$,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:a$,Y:i$,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(xe,Ne){return function(_e){var le=[],Ve=-1,H=0,ee=xe.length,X,B,I;for(_e instanceof Date||(_e=new Date(+_e));++Ve<ee;)xe.charCodeAt(Ve)===37&&(le.push(xe.slice(H,Ve)),(B=r$[X=xe.charAt(++Ve)])!=null?X=xe.charAt(++Ve):B=X==="e"?" ":"0",(I=Ne[X])&&(X=I(_e,B)),le.push(X),H=Ve+1);return le.push(xe.slice(H,Ve)),le.join("")}}function E(xe,Ne){return function(_e){var le=fb(1900,void 0,1),Ve=D(le,xe,_e+="",0),H,ee;if(Ve!=_e.length)return null;if("Q"in le)return new Date(le.Q);if("s"in le)return new Date(le.s*1e3+("L"in le?le.L:0));if(Ne&&!("Z"in le)&&(le.Z=0),"p"in le&&(le.H=le.H%12+le.p*12),le.m===void 0&&(le.m="q"in le?le.q:0),"V"in le){if(le.V<1||le.V>53)return null;"w"in le||(le.w=1),"Z"in le?(H=SC(fb(le.y,0,1)),ee=H.getUTCDay(),H=ee>4||ee===0?vS.ceil(H):vS(H),H=LN.offset(H,(le.V-1)*7),le.y=H.getUTCFullYear(),le.m=H.getUTCMonth(),le.d=H.getUTCDate()+(le.w+6)%7):(H=wC(fb(le.y,0,1)),ee=H.getDay(),H=ee>4||ee===0?yS.ceil(H):yS(H),H=Oy.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?SC(fb(le.y,0,1)).getUTCDay():wC(fb(le.y,0,1)).getDay(),le.m=0,le.d="W"in le?(le.w+6)%7+le.W*7-(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,SC(le)):wC(le)}}function D(xe,Ne,_e,le){for(var Ve=0,H=Ne.length,ee=_e.length,X,B;Ve<H;){if(le>=ee)return-1;if(X=Ne.charCodeAt(Ve++),X===37){if(X=Ne.charAt(Ve++),B=T[X in r$?Ne.charAt(Ve++):X],!B||(le=B(xe,_e,le))<0)return-1}else if(X!=_e.charCodeAt(le++))return-1}return le}function C(xe,Ne,_e){var le=u.exec(Ne.slice(_e));return le?(xe.p=d.get(le[0].toLowerCase()),_e+le[0].length):-1}function R(xe,Ne,_e){var le=p.exec(Ne.slice(_e));return le?(xe.w=b.get(le[0].toLowerCase()),_e+le[0].length):-1}function U(xe,Ne,_e){var le=f.exec(Ne.slice(_e));return le?(xe.w=m.get(le[0].toLowerCase()),_e+le[0].length):-1}function O(xe,Ne,_e){var le=v.exec(Ne.slice(_e));return le?(xe.m=S.get(le[0].toLowerCase()),_e+le[0].length):-1}function q(xe,Ne,_e){var le=y.exec(Ne.slice(_e));return le?(xe.m=x.get(le[0].toLowerCase()),_e+le[0].length):-1}function j(xe,Ne,_e){return D(xe,e,Ne,_e)}function W(xe,Ne,_e){return D(xe,n,Ne,_e)}function K(xe,Ne,_e){return D(xe,r,Ne,_e)}function G(xe){return o[xe.getDay()]}function Q(xe){return a[xe.getDay()]}function te(xe){return c[xe.getMonth()]}function J(xe){return l[xe.getMonth()]}function z(xe){return i[+(xe.getHours()>=12)]}function V(xe){return 1+~~(xe.getMonth()/3)}function ne(xe){return o[xe.getUTCDay()]}function ae(xe){return a[xe.getUTCDay()]}function he(xe){return c[xe.getUTCMonth()]}function pe(xe){return l[xe.getUTCMonth()]}function ie(xe){return i[+(xe.getUTCHours()>=12)]}function Ee(xe){return 1+~~(xe.getUTCMonth()/3)}return{format:function(xe){var Ne=k(xe+="",M);return Ne.toString=function(){return xe},Ne},parse:function(xe){var Ne=E(xe+="",!1);return Ne.toString=function(){return xe},Ne},utcFormat:function(xe){var Ne=k(xe+="",A);return Ne.toString=function(){return xe},Ne},utcParse:function(xe){var Ne=E(xe+="",!0);return Ne.toString=function(){return xe},Ne}}}var r$={"-":"",_:" ",0:"0"},oa=/^\s*\d+/,O_e=/^%/,L_e=/[\\^$*+?|[\]().{}]/g;function Yn(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 mb(t){return new RegExp("^(?:"+t.map(I_e).join("|")+")","i")}function pb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function F_e(t,e,n){var r=oa.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function U_e(t,e,n){var r=oa.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function z_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function B_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function $_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function i$(t,e,n){var r=oa.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function a$(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function 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=oa.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=oa.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function s$(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function W_e(t,e,n){var r=oa.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function o$(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function q_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function K_e(t,e,n){var r=oa.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function X_e(t,e,n){var r=oa.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Y_e(t,e,n){var r=oa.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function 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=oa.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function J_e(t,e,n){var r=oa.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function l$(t,e){return Yn(t.getDate(),e,2)}function ewe(t,e){return Yn(t.getHours(),e,2)}function twe(t,e){return Yn(t.getHours()%12||12,e,2)}function nwe(t,e){return Yn(1+Oy.count(gu(t),t),e,3)}function XY(t,e){return Yn(t.getMilliseconds(),e,3)}function rwe(t,e){return XY(t,e)+"000"}function iwe(t,e){return Yn(t.getMonth()+1,e,2)}function awe(t,e){return Yn(t.getMinutes(),e,2)}function swe(t,e){return Yn(t.getSeconds(),e,2)}function owe(t){var e=t.getDay();return e===0?7:e}function lwe(t,e){return Yn(IN.count(gu(t)-1,t),e,2)}function YY(t){var e=t.getDay();return e>=4||e===0?Mg(t):Mg.ceil(t)}function cwe(t,e){return t=YY(t),Yn(Mg.count(gu(t),t)+(gu(t).getDay()===4),e,2)}function uwe(t){return t.getDay()}function dwe(t,e){return Yn(yS.count(gu(t)-1,t),e,2)}function hwe(t,e){return Yn(t.getFullYear()%100,e,2)}function fwe(t,e){return t=YY(t),Yn(t.getFullYear()%100,e,2)}function mwe(t,e){return Yn(t.getFullYear()%1e4,e,4)}function pwe(t,e){var n=t.getDay();return t=n>=4||n===0?Mg(t):Mg.ceil(t),Yn(t.getFullYear()%1e4,e,4)}function gwe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Yn(e/60|0,"0",2)+Yn(e%60,"0",2)}function c$(t,e){return Yn(t.getUTCDate(),e,2)}function xwe(t,e){return Yn(t.getUTCHours(),e,2)}function bwe(t,e){return Yn(t.getUTCHours()%12||12,e,2)}function ywe(t,e){return Yn(1+LN.count(xu(t),t),e,3)}function ZY(t,e){return Yn(t.getUTCMilliseconds(),e,3)}function vwe(t,e){return ZY(t,e)+"000"}function _we(t,e){return Yn(t.getUTCMonth()+1,e,2)}function wwe(t,e){return Yn(t.getUTCMinutes(),e,2)}function Swe(t,e){return Yn(t.getUTCSeconds(),e,2)}function Mwe(t){var e=t.getUTCDay();return e===0?7:e}function Nwe(t,e){return Yn(FN.count(xu(t)-1,t),e,2)}function QY(t){var e=t.getUTCDay();return e>=4||e===0?Ng(t):Ng.ceil(t)}function Ewe(t,e){return t=QY(t),Yn(Ng.count(xu(t),t)+(xu(t).getUTCDay()===4),e,2)}function Awe(t){return t.getUTCDay()}function Twe(t,e){return Yn(vS.count(xu(t)-1,t),e,2)}function Cwe(t,e){return Yn(t.getUTCFullYear()%100,e,2)}function kwe(t,e){return t=QY(t),Yn(t.getUTCFullYear()%100,e,2)}function jwe(t,e){return Yn(t.getUTCFullYear()%1e4,e,4)}function Pwe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Ng(t):Ng.ceil(t),Yn(t.getUTCFullYear()%1e4,e,4)}function Rwe(){return"+0000"}function u$(){return"%"}function d$(t){return+t}function h$(t){return Math.floor(+t/1e3)}var Jm,JY,eZ;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 Jm=D_e(t),JY=Jm.format,Jm.parse,eZ=Jm.utcFormat,Jm.utcParse,Jm}function Owe(t){return new Date(t)}function Lwe(t){return t instanceof Date?+t:+new Date(+t)}function BO(t,e,n,r,i,a,o,l,c,u){var d=AO(),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(zY(E,k)):d},d.copy=function(){return Dy(d,BO(t,e,n,r,i,a,o,l,c,u))},d}function Iwe(){return Bo.apply(BO(P_e,R_e,gu,UO,IN,Oy,IO,OO,pf,JY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Fwe(){return Bo.apply(BO(k_e,j_e,xu,zO,FN,LN,FO,LO,pf,eZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function UN(){var t=0,e=1,n,r,i,a,o=Za,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(m){var p,b;return arguments.length?([p,b]=m,o=f(p,b),u):[o(0),o(1)]}}return u.range=d(ex),u.rangeRound=d(EO),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 gh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function tZ(){var t=ph(UN()(Za));return t.copy=function(){return gh(t,tZ())},Au.apply(t,arguments)}function nZ(){var t=kO(UN()).domain([1,10]);return t.copy=function(){return gh(t,nZ()).base(t.base())},Au.apply(t,arguments)}function rZ(){var t=jO(UN());return t.copy=function(){return gh(t,rZ()).constant(t.constant())},Au.apply(t,arguments)}function $O(){var t=PO(UN());return t.copy=function(){return gh(t,$O()).exponent(t.exponent())},Au.apply(t,arguments)}function Uwe(){return $O.apply(null,arguments).exponent(.5)}function iZ(){var t=[],e=Za;function n(r){if(r!=null&&!isNaN(r=+r))return e((Py(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(Bd),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 iZ(e).domain(t)},Au.apply(n,arguments)}function zN(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=Za,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(ex),p.rangeRound=b(EO),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 aZ(){var t=ph(zN()(Za));return t.copy=function(){return gh(t,aZ())},Au.apply(t,arguments)}function sZ(){var t=kO(zN()).domain([.1,1,10]);return t.copy=function(){return gh(t,sZ()).base(t.base())},Au.apply(t,arguments)}function oZ(){var t=jO(zN());return t.copy=function(){return gh(t,oZ()).constant(t.constant())},Au.apply(t,arguments)}function HO(){var t=PO(zN());return t.copy=function(){return gh(t,HO()).exponent(t.exponent())},Au.apply(t,arguments)}function zwe(){return HO.apply(null,arguments).exponent(.5)}const Ub=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:SO,scaleDiverging:aZ,scaleDivergingLog:sZ,scaleDivergingPow:HO,scaleDivergingSqrt:zwe,scaleDivergingSymlog:oZ,scaleIdentity:UY,scaleImplicit:s3,scaleLinear:FY,scaleLog:BY,scaleOrdinal:wO,scalePoint:Ave,scalePow:RO,scaleQuantile:VY,scaleQuantize:GY,scaleRadial:HY,scaleSequential:tZ,scaleSequentialLog:nZ,scaleSequentialPow:$O,scaleSequentialQuantile:iZ,scaleSequentialSqrt:Uwe,scaleSequentialSymlog:rZ,scaleSqrt:v_e,scaleSymlog:$Y,scaleThreshold:WY,scaleTime:Iwe,scaleUtc:Fwe,tickFormat:IY},Symbol.toStringTag,{value:"Module"}));var Tu=t=>t.chartData,BN=tt([Tu],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),VO=(t,e,n,r)=>r?BN(t):Tu(t),lZ=(t,e,n)=>n?BN(t):Tu(t);function bu(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(mn(e)&&mn(n))return!0}return!1}function f$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function cZ(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(mn(n))i=n;else if(typeof n=="function")return;if(mn(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(bu(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(bu(r))return f$(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(zt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&S8.test(i)){var c=S8.exec(i);if(c==null||c[1]==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(zt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&M8.test(a)){var d=M8.exec(a);if(d==null||d[1]==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var m=[o,l];if(bu(m))return e==null?m:f$(m,e,n)}}}var tx=1e9,$we={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},WO,Br=!0,Uo="[DecimalError] ",Af=Uo+"Invalid argument: ",GO=Uo+"Exponent out of range: ",nx=Math.floor,ef=Math.pow,Hwe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$s,Yi=1e7,Dr=7,uZ=9007199254740991,_S=nx(uZ/Dr),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)*Dr;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 au(this,new this.constructor(t))};qt.dividedToIntegerBy=qt.idiv=function(t){var e=this,n=e.constructor;return Sr(au(e,new n(t),0,1),n.precision)};qt.equals=qt.eq=function(t){return!this.cmp(t)};qt.exponent=function(){return Ti(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($s))throw Error(Uo+"NaN");if(n.s<1)throw Error(Uo+(n.s?"NaN":"-Infinity"));return n.eq($s)?new r(0):(Br=!1,e=au(G0(n,a),G0(t,a),a),Br=!0,Sr(e,i))};qt.minus=qt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?fZ(e,t):dZ(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(Uo+"NaN");return n.s?(Br=!1,e=au(n,t,0,1).times(t),Br=!0,n.minus(e)):Sr(new r(n),i)};qt.naturalExponential=qt.exp=function(){return hZ(this)};qt.naturalLogarithm=qt.ln=function(){return G0(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?dZ(e,t):fZ(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(Af+t);if(e=Ti(i)+1,r=i.d.length-1,n=r*Dr+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(Uo+"NaN")}for(t=Ti(l),Br=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=Bl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=nx((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(a=r,r=a.plus(au(l,a,o+2)).times(.5),Bl(a.d).slice(0,o)===(e=Bl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Sr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return Br=!0,Sr(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%Yi|0,e=l/Yi|0;a[i]=(a[i]+e)%Yi|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,Br?Sr(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:(ec(t,0,tx),e===void 0?e=r.rounding:ec(e,0,8),Sr(n,t+Ti(n)+1,e))};qt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Qf(r,!0):(ec(t,0,tx),e===void 0?e=i.rounding:ec(e,0,8),r=Sr(new i(r),t+1,e),n=Qf(r,!0,t+1)),n};qt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Qf(i):(ec(t,0,tx),e===void 0?e=a.rounding:ec(e,0,8),r=Sr(new a(i),t+Ti(i)+1,e),n=Qf(r.abs(),!1,t+Ti(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};qt.toInteger=qt.toint=function(){var t=this,e=t.constructor;return Sr(new e(t),Ti(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($s);if(l=new c(l),!l.s){if(t.s<1)throw Error(Uo+"Infinity");return l}if(l.eq($s))return l;if(r=c.precision,t.eq($s))return Sr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=uZ){for(i=new c($s),e=Math.ceil(r/Dr+4),Br=!1;n%2&&(i=i.times(l),p$(i.d,e)),n=nx(n/2),n!==0;)l=l.times(l),p$(l.d,e);return Br=!0,t.s<0?new c($s).div(i):Sr(i,r)}}else if(a<0)throw Error(Uo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,Br=!1,i=t.times(G0(l,r+u)),Br=!0,i=hZ(i),i.s=a,i};qt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Ti(i),r=Qf(i,n<=a.toExpNeg||n>=a.toExpPos)):(ec(t,1,tx),e===void 0?e=a.rounding:ec(e,0,8),i=Sr(new a(i),t,e),n=Ti(i),r=Qf(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):(ec(t,1,tx),e===void 0?e=r.rounding:ec(e,0,8)),Sr(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=Ti(t),n=t.constructor;return Qf(t,e<=n.toExpNeg||e>=n.toExpPos)};function dZ(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?Sr(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Dr),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)/Yi|0,c[a]%=Yi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,Br?Sr(e,f):e}function ec(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Af+t)}function Bl(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Dr-r.length,n&&(a+=xd(n)),a+=r;o=t[e],r=o+"",n=Dr-r.length,n&&(a+=xd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var au=(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%Yi|0,o=a/Yi|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*Yi+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,D,C=r.constructor,R=r.s==i.s?1:-1,U=r.d,O=i.d;if(!r.s)return new C(r);if(!i.s)throw Error(Uo+"Division by zero");for(c=r.e-i.e,E=O.length,T=U.length,p=new C(R),b=p.d=[],u=0;O[u]==(U[u]||0);)++u;if(O[u]>(U[u]||0)&&--c,a==null?S=a=C.precision:o?S=a+(Ti(r)-Ti(i))+1:S=a,S<0)return new C(0);if(S=S/Dr+2|0,u=0,E==1)for(d=0,O=O[0],S++;(u<T||d)&&S--;u++)M=d*Yi+(U[u]||0),b[u]=M/O|0,d=M%O|0;else{for(d=Yi/(O[0]+1)|0,d>1&&(O=t(O,d),U=t(U,d),E=O.length,T=U.length),A=E,y=U.slice(0,E),x=y.length;x<E;)y[x++]=0;D=O.slice(),D.unshift(0),k=O[0],O[1]>=Yi/2&&++k;do d=0,l=e(O,y,E,x),l<0?(v=y[0],E!=x&&(v=v*Yi+(y[1]||0)),d=v/k|0,d>1?(d>=Yi&&(d=Yi-1),f=t(O,d),m=f.length,x=y.length,l=e(f,y,m,x),l==1&&(d--,n(f,E<m?D:O,m))):(d==0&&(l=d=1),f=O.slice()),m=f.length,m<x&&f.unshift(0),n(y,f,x),l==-1&&(x=y.length,l=e(O,y,E,x),l<1&&(d++,n(y,E<x?D:O,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,Sr(p,o?a+Ti(p)+1:a)}})();function hZ(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Ti(t)>16)throw Error(GO+Ti(t));if(!t.s)return new d($s);for(Br=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(ef(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d($s),d.precision=l;;){if(i=Sr(i.times(t),l),n=n.times(++c),o=a.plus(au(i,n,l)),Bl(o.d).slice(0,l)===Bl(a.d).slice(0,l)){for(;u--;)a=Sr(a.times(a),l);return d.precision=f,e==null?(Br=!0,Sr(a,f)):a}a=o}}function Ti(t){for(var e=t.e*Dr,n=t.d[0];n>=10;n/=10)e++;return e}function MC(t,e,n){if(e>t.LN10.sd())throw Br=!0,n&&(t.precision=n),Error(Uo+"LN10 precision limit exceeded");return Sr(new t(t.LN10),e)}function xd(t){for(var e="";t--;)e+="0";return e}function G0(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(Uo+(p.s?"NaN":"-Infinity"));if(p.eq($s))return new y(0);if(e==null?(Br=!1,u=x):u=e,p.eq(10))return e==null&&(Br=!0),MC(y,u);if(u+=m,y.precision=u,n=Bl(b),r=n.charAt(0),a=Ti(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=Bl(p.d),r=n.charAt(0),f++;a=Ti(p),r>1?(p=new y("0."+n),a++):p=new y(r+"."+n.slice(1))}else return c=MC(y,u+2,x).times(a+""),p=G0(new y(r+"."+n.slice(1)),u-m).plus(c),y.precision=x,e==null?(Br=!0,Sr(p,x)):p;for(l=o=p=au(p.minus($s),p.plus($s),u),d=Sr(p.times(p),u),i=3;;){if(o=Sr(o.times(d),u),c=l.plus(au(o,new y(i),u)),Bl(c.d).slice(0,u)===Bl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(MC(y,u+2,x).times(a+""))),l=au(l,new y(f),u),y.precision=x,e==null?(Br=!0,Sr(l,x)):l;l=c,i+=2}}function m$(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=nx(n/Dr),t.d=[],r=(n+1)%Dr,n<0&&(r+=Dr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Dr;r<i;)t.d.push(+e.slice(r,r+=Dr));e=e.slice(r),r=Dr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),Br&&(t.e>_S||t.e<-_S))throw Error(GO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Sr(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=Dr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Dr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Dr,i=r-Dr+o}if(n!==void 0&&(a=ef(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/ef(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=Ti(t),f.length=1,e=e-a-1,f[0]=ef(10,(Dr-e%Dr)%Dr),t.e=nx(-e/Dr)||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=ef(10,Dr-r),f[d]=i>0?(u/ef(10,o-i)%ef(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Yi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Yi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(Br&&(t.e>_S||t.e<-_S))throw Error(GO+Ti(t));return t}function fZ(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?Sr(e,p):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(p/Dr),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]=Yi-1;--c[a],c[i]+=Yi}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?Sr(e,p):e):new m(0)}function Qf(t,e,n){var r,i=Ti(t),a=Bl(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+xd(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+xd(-i-1)+a,n&&(r=n-o)>0&&(a+=xd(r))):i>=o?(a+=xd(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+xd(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=xd(r))),t.s<0?"-"+a:a}function p$(t,e){if(t.length>e)return t.length=e,!0}function mZ(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(Af+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return m$(o,a.toString())}else if(typeof a!="string")throw Error(Af+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,Hwe.test(a))m$(o,a);else throw Error(Af+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=mZ,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(Uo+"Object expected");var e,n,r,i=["precision",1,tx,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<i.length;e+=3)if((r=t[n=i[e]])!==void 0)if(nx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Af+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Af+n+": "+r);return this}var WO=mZ($we);$s=new WO(1);const or=WO;function pZ(t){var e;return t===0?e=1:e=Math.floor(new or(t).abs().log(10).toNumber())+1,e}function gZ(t,e,n){for(var r=new or(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var xZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},bZ=(t,e,n)=>{if(t.lte(0))return new or(0);var r=pZ(t.toNumber()),i=new or(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new or(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new or(c.toNumber()):new or(Math.ceil(c.toNumber()))},Gwe=(t,e,n)=>{var r=new or(1),i=new or(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new or(10).pow(pZ(t)-1),i=new or(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new or(Math.floor(t)))}else t===0?i=new or(Math.floor((e-1)/2)):n||(i=new or(Math.floor(t)));for(var o=Math.floor((e-1)/2),l=[],c=0;c<e;c++)l.push(i.add(new or(c-o).mul(r)).toNumber());return l},yZ=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 or(0),tickMin:new or(0),tickMax:new or(0)};var o=bZ(new or(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new or(0):(l=new or(e).add(n).div(2),l=l.sub(new or(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new or(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?yZ(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 or(c).mul(o)),tickMax:l.add(new or(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]=xZ([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}=yZ(l,c,o,a,0),p=gZ(f,m.add(new or(.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]=xZ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=bZ(new or(l).sub(o).div(c-1),a,0),d=[...gZ(new or(o),new or(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?d.reverse():d},vZ=t=>t.rootProps.maxBarSize,Kwe=t=>t.rootProps.barGap,_Z=t=>t.rootProps.barCategoryGap,Xwe=t=>t.rootProps.barSize,Ly=t=>t.rootProps.stackOffset,wZ=t=>t.rootProps.reverseStackOrder,qO=t=>t.options.chartName,KO=t=>t.rootProps.syncId,SZ=t=>t.rootProps.syncMethod,XO=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},Fh={allowDecimals:!1,allowDataOverflow:!1,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"auto"},El={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,includeHidden:!1,radiusAxisId:0,reversed:!1,scale:"auto",tick:!0,tickCount:5,type:"auto"},$N=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e};function HN(t,e,n){if(n!=="auto")return n;if(t!=null)return xl(t,e)?"category":"number"}function g$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function wS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g$(Object(n),!0).forEach(function(r){Zwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 x$={allowDataOverflow:Fh.allowDataOverflow,allowDecimals:Fh.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Fh.angleAxisId,includeHidden:!1,name:void 0,reversed:Fh.reversed,scale:Fh.scale,tick:Fh.tick,tickCount:void 0,ticks:void 0,type:Fh.type,unit:void 0},b$={allowDataOverflow:El.allowDataOverflow,allowDecimals:El.allowDecimals,allowDuplicatedCategory:El.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:El.radiusAxisId,includeHidden:El.includeHidden,name:void 0,reversed:El.reversed,scale:El.scale,tick:El.tick,tickCount:El.tickCount,ticks:void 0,type:El.type,unit:void 0},e1e=(t,e)=>{if(e!=null)return t.polarAxis.angleAxis[e]},YO=tt([e1e,oY],(t,e)=>{var n;if(t!=null)return t;var r=(n=HN(e,"angleAxis",x$.type))!==null&&n!==void 0?n:"category";return wS(wS({},x$),{},{type:r})}),t1e=(t,e)=>t.polarAxis.radiusAxis[e],ZO=tt([t1e,oY],(t,e)=>{var n;if(t!=null)return t;var r=(n=HN(e,"radiusAxis",b$.type))!==null&&n!==void 0?n:"category";return wS(wS({},b$),{},{type:r})}),VN=t=>t.polarOptions,QO=tt([Nu,Eu,Ui],MY),MZ=tt([VN,QO],(t,e)=>{if(t!=null)return Ba(t.innerRadius,e,0)}),NZ=tt([VN,QO],(t,e)=>{if(t!=null)return Ba(t.outerRadius,e,e*.8)}),n1e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},EZ=tt([VN],n1e);tt([YO,EZ],$N);var AZ=tt([QO,MZ,NZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});tt([ZO,AZ],$N);var TZ=tt([Un,VN,MZ,NZ,Nu,Eu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:Ba(o,i,i/2),cy:Ba(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Xr=(t,e)=>e,Iy=(t,e,n)=>n;function GN(t){return t?.id}function CZ(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=GN(l);u.forEach((f,m)=>{var p=a==null||i?m:String(tr(f,a,null)),b=tr(f,l.dataKey,0),y;o.has(p)?y=o.get(p):y={},Object.assign(y,{[d]:b}),o.set(p,y)})}}),Array.from(o.values())}function WN(t){return"stackId"in t&&t.stackId!=null&&t.dataKey!=null}var qN=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function KN(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function 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 la=t=>{var e=Un(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},rx=t=>t.tooltip.settings.axisId;function i1e(t){if(t in Ub)return Ub[t]();var e="scale".concat(Sy(t));if(e in Ub)return Ub[e]()}function y$(t){var e=t.ticks,n=t.bandwidth,r=t.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>t.domain(),range:(function(a){function o(){return a.apply(this,arguments)}return o.toString=function(){return a.toString()},o})(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(a){var o=i[0],l=i[1];return o<=l?a>=o&&a<=l:a>=l&&a<=o},bandwidth:n?()=>n.call(t):void 0,ticks:e?a=>e.call(t,a):void 0,map:(a,o)=>{var l=t(a);if(l!=null){if(t.bandwidth&&o!==null&&o!==void 0&&o.position){var c=t.bandwidth();switch(o.position){case"middle":l+=c/2;break;case"end":l+=c;break}}return l}}}}function v$(t,e,n){if(typeof t=="function")return y$(t.copy().domain(e).range(n));if(t!=null){var r=i1e(t);if(r!=null)return r.domain(e).range(n),y$(r)}}var kZ=(t,e)=>{if(e!=null)switch(t){case"linear":{if(!bu(e)){for(var n,r,i=0;i<e.length;i++){var a=e[i];mn(a)&&((n===void 0||a<n)&&(n=a),(r===void 0||a>r)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return e}default:return e}};function _$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function SS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?_$(Object(n),!0).forEach(function(r){a1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):_$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 u3=[0,"auto"],Ki={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},jZ=(t,e)=>t.cartesianAxis.xAxis[e],cc=(t,e)=>{var n=jZ(t,e);return n??Ki},Xi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:u3,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:Ay},PZ=(t,e)=>t.cartesianAxis.yAxis[e],uc=(t,e)=>{var n=PZ(t,e);return n??Xi},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:""},JO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??l1e},ui=(t,e,n)=>{switch(e){case"xAxis":return cc(t,n);case"yAxis":return uc(t,n);case"zAxis":return JO(t,n);case"angleAxis":return YO(t,n);case"radiusAxis":return ZO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},c1e=(t,e,n)=>{switch(e){case"xAxis":return cc(t,n);case"yAxis":return uc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ix=(t,e,n)=>{switch(e){case"xAxis":return cc(t,n);case"yAxis":return uc(t,n);case"angleAxis":return YO(t,n);case"radiusAxis":return ZO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},RZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function e4(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 Fy=t=>t.graphicalItems.cartesianItems,u1e=tt([Xr,Iy],e4),t4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),Uy=tt([Fy,ui,u1e],t4,{memoizeOptions:{resultEqualityCheck:KN}}),DZ=tt([Uy],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(WN)),OZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),d1e=tt([Uy],OZ),n4=t=>t.map(e=>e.data).filter(Boolean).flat(1),h1e=tt([Uy],n4,{memoizeOptions:{resultEqualityCheck:KN}}),r4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},i4=tt([h1e,VO],r4),a4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:tr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:tr(i,r)}))):t.map(r=>({value:r})),XN=tt([i4,ui,Uy],a4);function LZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function o1(t){if(Io(t)||t instanceof Date){var e=Number(t);if(mn(e))return e}}function w$(t){if(Array.isArray(t)){var e=[o1(t[0]),o1(t[1])];return bu(e)?e:void 0}var n=o1(t);if(n!=null)return[n,n]}function yu(t){return t.map(o1).filter(vs)}function f1e(t,e,n){return!n||typeof e!="number"||ul(e)?[]:n.length?yu(n.flatMap(r=>{var i=tr(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!mn(a)||!mn(o)))return[e-a,e+o]})):[]}var $i=t=>{var e=la(t),n=rx(t);return ix(t,e,n)},zy=tt([$i],t=>t?.dataKey),m1e=tt([DZ,VO,$i],CZ),IZ=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>{if(l.stackId==null)return o;var c=o[l.stackId];return c==null&&(c=[]),c.push(l),o[l.stackId]=c,o},i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(GN);return[l,{stackedData:Obe(t,d,n),graphicalItems:u}]}))},MS=tt([m1e,DZ,Ly,wZ],IZ),FZ=(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=tt([ui],t=>t.allowDataOverflow),s4=t=>{var e;if(t==null||!("domain"in t))return u3;if(t.domain!=null)return t.domain;if("ticks"in t&&t.ticks!=null){if(t.type==="number"){var n=yu(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:u3},o4=tt([ui],s4),l4=tt([o4,p1e],cZ),g1e=tt([MS,Tu,Xr,l4],FZ,{memoizeOptions:{resultEqualityCheck:qN}}),YN=t=>t.errorBars,x1e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>LZ(n,r)),NS=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]}},c4=(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=>LZ(i,v)),m=tr(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=w$(m);x!=null&&(a=a==null?x[0]:Math.min(a,x[0]),o=o==null?x[1]:Math.max(o,x[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=w$(tr(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]))}),mn(a)&&mn(o))return[a,o]},b1e=tt([i4,ui,d1e,YN,Xr],c4,{memoizeOptions:{resultEqualityCheck:qN}});function y1e(t){var{value:e}=t;if(Io(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&&nX(r))?TY(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},UZ=t=>t.referenceElements.dots,ax=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),_1e=tt([UZ,Xr,Iy],ax),zZ=t=>t.referenceElements.areas,w1e=tt([zZ,Xr,Iy],ax),BZ=t=>t.referenceElements.lines,S1e=tt([BZ,Xr,Iy],ax),$Z=(t,e)=>{if(t!=null){var n=yu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},M1e=tt(_1e,Xr,$Z),HZ=(t,e)=>{if(t!=null){var n=yu(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=tt([w1e,Xr],HZ);function E1e(t){var e;if(t.x!=null)return yu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:yu(n)}function A1e(t){var e;if(t.y!=null)return yu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:yu(n)}var VZ=(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=tt([S1e,Xr],VZ),C1e=tt(M1e,T1e,N1e,(t,e,n)=>NS(t,n,e)),u4=(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?NS(r,a,i):NS(a,i);return Bwe(e,u,t.allowDataOverflow)},k1e=tt([ui,o4,l4,g1e,b1e,C1e,Un,Xr],u4,{memoizeOptions:{resultEqualityCheck:qN}}),j1e=[0,1],d4=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=xl(e,a);if(u&&l==null){var d;return TY(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?v1e(r,t,u):i==="expand"?j1e:o}},h4=tt([ui,Un,i4,XN,Ly,Xr,k1e],d4);function P1e(t){return t in Ub}var GZ=(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(Sy(r));return P1e(a)?a:"point"}}},xh=tt([ui,RZ,qO],GZ);function f4(t,e,n,r){if(!(n==null||r==null))return typeof t.scale=="function"?v$(t.scale,n,r):v$(e,n,r)}var m4=(t,e,n)=>{var r=s4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&bu(t))return Wwe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&bu(t))return qwe(t,e.tickCount,e.allowDecimals)}},p4=tt([h4,ix,xh],m4),g4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&bu(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=tt([ui,h4,p4,Xr],g4),D1e=tt(XN,ui,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(yu(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}}),WZ=tt(D1e,Un,_Z,Ui,(t,e,n,r,i)=>i,(t,e,n,r,i)=>{if(!mn(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=Ba(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),O1e=(t,e,n)=>{var r=cc(t,e);return r==null||typeof r.padding!="string"?0:WZ(t,"xAxis",e,n,r.padding)},L1e=(t,e,n)=>{var r=uc(t,e);return r==null||typeof r.padding!="string"?0:WZ(t,"yAxis",e,n,r.padding)},I1e=tt(cc,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=tt(uc,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=tt([Ui,I1e,jN,kN,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),z1e=tt([Ui,Un,F1e,jN,kN,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),By=(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=JO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return EZ(t);case"radiusAxis":return AZ(t,n);default:return}},qZ=tt([ui,By],$N),B1e=tt([xh,R1e],kZ),Eg=tt([ui,xh,B1e,qZ],f4);tt([Uy,YN,Xr],x1e);function KZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var ZN=(t,e)=>e,QN=(t,e,n)=>n,$1e=tt(TN,ZN,QN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(KZ)),H1e=tt(CN,ZN,QN,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(KZ)),XZ=(t,e)=>({width:t.width,height:e.height}),V1e=(t,e)=>{var n=typeof e.width=="number"?e.width:Ay;return{width:n,height:t.height}},YZ=tt(Ui,cc,XZ),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=tt(Eu,Ui,$1e,ZN,QN,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=XZ(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=tt(Nu,Ui,H1e,ZN,QN,(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=cc(t,e);if(n!=null)return q1e(t,n.orientation,n.mirror)},Y1e=tt([Ui,cc,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=uc(t,e);if(n!=null)return K1e(t,n.orientation,n.mirror)},Q1e=tt([Ui,uc,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}}}),ZZ=tt(Ui,uc,(t,e)=>{var n=typeof e.width=="number"?e.width:Ay;return{width:n,height:t.height}}),S$=(t,e,n)=>{switch(e){case"xAxis":return YZ(t,n).width;case"yAxis":return ZZ(t,n).height;default:return}},QZ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=xl(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&nX(c))return c}},x4=tt([Un,XN,ui,Xr],QZ),JZ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=xl(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},b4=tt([Un,XN,ix,Xr],JZ),M$=tt([Un,c1e,xh,Eg,x4,b4,By,p4,Xr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=xl(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),J1e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=xl(t,c),{type:d,ticks:f,tickCount:m}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=d==="category"&&r.bandwidth?r.bandwidth()/p:0;b=c==="angleAxis"&&a!=null&&a.length>=2?Ji(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 mn(M)?{index:v,coordinate:M+b,value:x,offset:b}:null}).filter(vs):u&&l?l.map((x,v)=>{var S=r.map(x);return mn(S)?{coordinate:S+b,value:x,index:v,offset:b}:null}).filter(vs):r.ticks?r.ticks(m).map((x,v)=>{var S=r.map(x);return mn(S)?{coordinate:S+b,value:x,index:v,offset:b}:null}).filter(vs):r.domain().map((x,v)=>{var S=r.map(x);return mn(S)?{coordinate:S+b,value:o?o[x]:x,index:v,offset:b}:null}).filter(vs)}},eQ=tt([Un,ix,xh,Eg,p4,By,x4,b4,Xr],J1e),eSe=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=xl(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Ji(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>{var m=n.map(d);return mn(m)?{coordinate:m+u,value:d,index:f,offset:u}:null}).filter(vs):n.ticks?n.ticks(c).map((d,f)=>{var m=n.map(d);return mn(m)?{coordinate:m+u,value:d,index:f,offset:u}:null}).filter(vs):n.domain().map((d,f)=>{var m=n.map(d);return mn(m)?{coordinate:m+u,value:i?i[d]:d,index:f,offset:u}:null}).filter(vs)}},tc=tt([Un,ix,Eg,By,x4,b4,Xr],eSe),nc=tt(ui,Eg,(t,e)=>{if(!(t==null||e==null))return SS(SS({},t),{},{scale:e})}),tSe=tt([ui,xh,h4,qZ],f4);tt((t,e,n)=>JO(t,n),tSe,(t,e)=>{if(!(t==null||e==null))return SS(SS({},t),{},{scale:e})});var nSe=tt([Un,TN,CN],(t,e,n)=>{switch(t){case"horizontal":return e.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),tQ=t=>t.options.defaultTooltipEventType,nQ=t=>t.options.validateTooltipEventTypes;function rQ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function y4(t,e){var n=tQ(t),r=nQ(t);return rQ(e,n,r)}function rSe(t){return Vt(e=>y4(e,t))}var iQ=(t,e)=>{var n,r=Number(e);if(!(ul(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},iSe=t=>t.tooltip.settings,Nd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},aSe={itemInteraction:{click:Nd,hover:Nd},axisInteraction:{click:Nd,hover:Nd},keyboardInteraction:Nd,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}},aQ=Es({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=sl(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Fr()},removeTooltipEntrySettings:{reducer(t,e){var n=sl(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:sQ,mouseLeaveItem:uSe,mouseLeaveChart:oQ,setActiveClickItemIndex:dSe,setMouseOverAxisIndex:lQ,setMouseClickAxisIndex:hSe,setSyncInteraction:d3,setKeyboardInteraction:h3}=aQ.actions,fSe=aQ.reducer;function N$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N$(Object(n),!0).forEach(function(r){mSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 cQ=(t,e,n,r)=>{if(e==null)return Nd;var i=xSe(t,e,n);if(i==null)return Nd;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 j_(j_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return j_(j_({},Nd),{},{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=tr(t,e);return r==null||!bu(n)?!0:vSe(r,n)}var v4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!mn(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},uQ=(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}}},dQ=(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})},hQ=t=>t.options.tooltipPayloadSearcher,sx=t=>t.tooltip;function E$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function A$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E$(Object(n),!0).forEach(function(r){wSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 fQ=(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)?YX(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=rX(S,r,i):T=a(S,e,c,A),Array.isArray(T))T.forEach(E=>{var D=A$(A$({},x),{},{name:E.name,unit:E.unit,color:void 0,fill:void 0});m.push(N8({tooltipEntrySettings:D,dataKey:E.dataKey,payload:E.payload,value:tr(E.payload,E.dataKey),name:E.name}))});else{var k;m.push(N8({tooltipEntrySettings:x,dataKey:M,payload:T,value:tr(T,M),name:(k=tr(T,A))!==null&&k!==void 0?k:x?.name}))}return m},f)}},_4=tt([$i,RZ,qO],GZ),ESe=tt([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),ASe=tt([la,rx],e4),ox=tt([ESe,$i,ASe],t4,{memoizeOptions:{resultEqualityCheck:KN}}),TSe=tt([ox],t=>t.filter(WN)),CSe=tt([ox],n4,{memoizeOptions:{resultEqualityCheck:KN}}),lx=tt([CSe,Tu],r4),kSe=tt([TSe,Tu,$i],CZ),w4=tt([lx,$i,ox],a4),mQ=tt([$i],s4),jSe=tt([$i],t=>t.allowDataOverflow),pQ=tt([mQ,jSe],cZ),PSe=tt([ox],t=>t.filter(WN)),RSe=tt([kSe,PSe,Ly,wZ],IZ),DSe=tt([RSe,Tu,la,pQ],FZ),OSe=tt([ox],OZ),LSe=tt([lx,$i,OSe,YN,la],c4,{memoizeOptions:{resultEqualityCheck:qN}}),ISe=tt([UZ,la,rx],ax),FSe=tt([ISe,la],$Z),USe=tt([zZ,la,rx],ax),zSe=tt([USe,la],HZ),BSe=tt([BZ,la,rx],ax),$Se=tt([BSe,la],VZ),HSe=tt([FSe,$Se,zSe],NS),VSe=tt([$i,mQ,pQ,DSe,LSe,HSe,Un,la],u4),$y=tt([$i,Un,lx,w4,Ly,la,VSe],d4),GSe=tt([$y,$i,_4],m4),WSe=tt([$i,$y,GSe,la],g4),gQ=t=>{var e=la(t),n=rx(t),r=!1;return By(t,e,n,r)},xQ=tt([$i,gQ],$N),bQ=tt([$i,_4,WSe,xQ],f4),qSe=tt([Un,w4,$i,la],QZ),KSe=tt([Un,w4,$i,la],JZ),XSe=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=xl(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?Ji(i[0]-i[1])*2*f:f,u&&o?o.map((m,p)=>{var b=r.map(m);return mn(b)?{coordinate:b+f,value:m,index:p,offset:f}:null}).filter(vs):r.domain().map((m,p)=>{var b=r.map(m);return mn(b)?{coordinate:b+f,value:a?a[m]:m,index:p,offset:f}:null}).filter(vs)}}},Cu=tt([Un,$i,_4,bQ,gQ,qSe,KSe,la],XSe),S4=tt([tQ,nQ,iSe],(t,e,n)=>rQ(n.shared,t,e)),yQ=t=>t.tooltip.settings.trigger,M4=t=>t.tooltip.settings.defaultIndex,Hy=tt([sx,S4,yQ,M4],cQ),eh=tt([Hy,lx,zy,$y],v4),vQ=tt([Cu,eh],iQ),N4=tt([Hy],t=>{if(t)return t.dataKey}),YSe=tt([Hy],t=>{if(t)return t.graphicalItemId}),_Q=tt([sx,S4,yQ,M4],dQ),ZSe=tt([Nu,Eu,Un,Ui,Cu,M4,_Q],uQ),QSe=tt([Hy,ZSe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),JSe=tt([Hy],t=>{var e;return(e=t?.active)!==null&&e!==void 0?e:!1}),eMe=tt([_Q,eh,Tu,zy,vQ,hQ,S4],fQ),tMe=tt([eMe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function T$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function C$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T$(Object(n),!0).forEach(function(r){nMe(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 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=()=>Vt($i),sMe=()=>{var t=aMe(),e=Vt(Cu),n=Vt(bQ);return Jd(!t||!n?void 0:C$(C$({},t),{},{scale:n}),e)};function k$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ep(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k$(Object(n),!0).forEach(function(r){oMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 ep(ep(ep({},r),Ei(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return ep(ep(ep({},r),Ei(r.cx,r.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function 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 wQ=(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(Ji(b-p)!==Ji(y-b)){var v=[];if(Ji(y-b)===Ji(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 D;return(D=n[l])===null||D===void 0?void 0:D.index}}}else if(e)for(var C=0;C<o;C++){var R=e[C];if(R!=null){var U=e[C+1],O=e[C-1];if(C===0&&U!=null&&t<=(R.coordinate+U.coordinate)/2||C===o-1&&O!=null&&t>(R.coordinate+O.coordinate)/2||C>0&&C<o-1&&O!=null&&U!=null&&t>(R.coordinate+O.coordinate)/2&&t<=(R.coordinate+U.coordinate)/2)return R.index}}return-1},SQ=()=>Vt(qO),E4=(t,e)=>e,MQ=(t,e,n)=>n,A4=(t,e,n,r)=>r,fMe=tt(Cu,t=>bN(t,e=>e.coordinate)),T4=tt([sx,E4,MQ,A4],cQ),C4=tt([T4,lx,zy,$y],v4),mMe=(t,e,n)=>{if(e!=null){var r=sx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},NQ=tt([sx,E4,MQ,A4],dQ),ES=tt([Nu,Eu,Un,Ui,Cu,A4,NQ],uQ),pMe=tt([T4,ES],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),EQ=tt([Cu,C4],iQ),gMe=tt([NQ,C4,Tu,zy,EQ,hQ,E4],fQ),xMe=tt([T4,C4],(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=wQ(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=wQ(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=tt(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElement:r.element}}),wMe=tt(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 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){SMe(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 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)=>P$(P$({},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 AQ=Es({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}=AQ.actions,DMe=AQ.reducer;function $a(t){var{zIndex:e,children:n}=t,r=b0e(),i=r&&e!==void 0&&e!==0,a=zi(),o=Mr();w.useLayoutEffect(()=>i?(o(kMe({zIndex:e})),()=>{o(jMe({zIndex:e}))}):hh,[o,e,i]);var l=Vt(c=>_Me(c,e,a));return i?l?Zc.createPortal(n,l):null:n}function f3(){return f3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f3.apply(null,arguments)}function 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 P_(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=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=SY,x=li.cursorRectangle;else if(l==="radial"&&aX(f)){var{cx:v,cy:S,radius:M,startAngle:A,endAngle:T}=NY(f);b={cx:v,cy:S,startAngle:A,endAngle:T,innerRadius:M,outerRadius:M},y=AY,x=li.cursorLine}else b={points:ove(l,f,a)},y=ig,x=li.cursorLine;var k=typeof c=="object"&&"className"in c?c.className:void 0,E=P_(P_(P_(P_({stroke:"#ccc",pointerEvents:"none"},a),b),Gf(c)),{},{payload:m,payloadIndex:p,className:Bn("recharts-tooltip-cursor",k)});return w.createElement($a,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:x},w.createElement(FMe,{cursor:c,cursorComp:y,cursorProps:E}))}function zMe(t){var e=sMe(),n=sY(),r=mh(),i=SQ();return e==null||n==null||r==null||i==null?null:w.createElement(UMe,f3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var TQ=w.createContext(null),BMe=()=>w.useContext(TQ),NC={exports:{}},D$;function $Me(){return D$||(D$=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,m),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],p]:c._events[b].push(p):(c._events[b]=p,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var m=0,p=f.length,b=new Array(p);m<p;m++)b[m]=f[m].fn;return b},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,m,p,b){var y=n?n+u:u;if(!this._events[y])return!1;var x=this._events[y],v=arguments.length,S,M;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),v){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,d),!0;case 3:return x.fn.call(x.context,d,f),!0;case 4:return x.fn.call(x.context,d,f,m),!0;case 5:return x.fn.call(x.context,d,f,m,p),!0;case 6:return x.fn.call(x.context,d,f,m,p,b),!0}for(M=1,S=new Array(v-1);M<v;M++)S[M-1]=arguments[M];x.fn.apply(x.context,S)}else{var 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})(NC)),NC.exports}var HMe=$Me();const VMe=ml(HMe);var W0=new VMe,m3="recharts.syncEvent.tooltip",O$="recharts.syncEvent.brush",JN=(t,e)=>{if(e&&Array.isArray(t)){var n=Number.parseInt(e,10);if(!ul(n))return t[n]}},GMe={chartName:"",tooltipPayloadSearcher:()=>{},eventEmitter:void 0,defaultTooltipEventType:"axis"},CQ=Es({name:"options",initialState:GMe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),WMe=CQ.reducer,{createEventEmitter:qMe}=CQ.actions;function KMe(t){return t.tooltip.syncInteraction}var XMe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},kQ=Es({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:L$,setDataStartEndIndexes:YMe,setComputedData:nQe}=kQ.actions,ZMe=kQ.reducer,QMe=["x","y"];function I$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I$(Object(n),!0).forEach(function(r){JMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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=Vt(KO),e=Vt(XO),n=Mr(),r=Vt(SZ),i=Vt(Cu),a=mh(),o=Ty(),l=Vt(c=>c.rootProps.className);w.useEffect(()=>{if(t==null)return hh;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=tp(tp({},x),{},{x:o.x+(M?(b-v)/M:0)*o.width,y:o.y+(A?(y-S)/A:0)*o.height});n(tp(tp({},d),{},{payload:tp(tp({},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},D=r(i,E);k=i[D]}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(d3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:U}=C,O=Math.min(R,o.x+o.width),q=Math.min(U,o.y+o.height),j={x:a==="horizontal"?k.coordinate:O,y:a==="horizontal"?q:k.coordinate},W=d3({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(k.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return W0.on(m3,c),()=>{W0.off(m3,c)}},[l,n,e,t,r,i,a,o])}function aNe(){var t=Vt(KO),e=Vt(XO),n=Mr();w.useEffect(()=>{if(t==null)return hh;var r=(i,a,o)=>{e!==o&&t===i&&n(YMe(a))};return W0.on(O$,r),()=>{W0.off(O$,r)}},[n,e,t])}function sNe(){var t=Mr();w.useEffect(()=>{t(qMe())},[t]),iNe(),aNe()}function oNe(t,e,n,r,i,a){var o=Vt(p=>mMe(p,t,e)),l=Vt(XO),c=Vt(KO),u=Vt(SZ),d=Vt(KMe),f=d?.active,m=Ty();w.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=d3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:m,graphicalItemId:void 0});W0.emit(m3,c,p,l)}},[f,n,o,i,r,l,c,u,a,m])}function F$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function U$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F$(Object(n),!0).forEach(function(r){lNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 z$=[],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 l1(t){var e,n,r=Kr(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=Mr(),D=typeof A=="number"?String(A):A;w.useEffect(()=>{E(cSe({shared:S,trigger:M,axisId:k,active:i,defaultIndex:D}))},[E,S,M,k,i,D]);var C=Ty(),R=bY(),U=rSe(S),{activeIndex:O,isActive:q}=(e=Vt(ie=>xMe(ie,U,M,D)))!==null&&e!==void 0?e:{},j=Vt(ie=>gMe(ie,U,M,D)),W=Vt(ie=>EQ(ie,U,M,D)),K=Vt(ie=>pMe(ie,U,M,D)),G=j,Q=BMe(),te=(n=i??q)!==null&&n!==void 0?n:!1,[J,z]=vX([G,te]),V=U==="axis"?W:void 0;oNe(U,M,K,V,O,te);var ne=T??Q;if(ne==null||C==null||U==null)return null;var ae=G??z$;te||(ae=z$),u&&ae.length&&(ae=mX(ae.filter(ie=>ie.value!=null&&(ie.hide!==!0||r.includeHidden)),m,dNe));var he=ae.length>0,pe=w.createElement(rye,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:te,coordinate:K,hasPayload:he,offset:f,position:p,reverseDirection:b,useTranslate3d:y,viewBox:C,wrapperStyle:x,lastBoundingBox:J,innerRef:z,hasPortalFromProps:!!T},hNe(c,U$(U$({},r),{},{payload:ae,label:V,active:te,activeIndex:O,coordinate:K,accessibilityLayer:R})));return w.createElement(w.Fragment,null,Zc.createPortal(pe,ne),te&&w.createElement(zMe,{cursor:v,tooltipEventType:U,coordinate:K,payload:ae,index:O}))}var Vy=t=>null;Vy.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 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 bNe(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){yNe(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 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},jQ=bNe({},wNe),$$=new xNe(jQ.cacheSize),SNe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},H$="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 V$=(t,e)=>{try{var n=document.getElementById(H$);n||(n=document.createElement("span"),n.setAttribute("id",H$),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,SNe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},r0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||jy.isSsr)return{width:0,height:0};if(!jQ.enableCache)return V$(e,n);var r=MNe(e,n),i=$$.get(r);if(i)return i;var a=V$(e,n);return $$.set(r,a),a},PQ;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 G$=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,W$=/(-?\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 Xp="NaN";function RNe(t,e){return t*kNe[e]}class ya{static parse(e){var n,[,r,i]=(n=CNe.exec(e))!==null&&n!==void 0?n:[];return r==null?ya.NaN:new ya(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,ul(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 ya(NaN,""):new ya(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ya(NaN,""):new ya(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ya(NaN,""):new ya(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ya(NaN,""):new ya(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return ul(this.num)}}PQ=ya;NNe(ya,"NaN",new PQ(NaN,""));function RQ(t){if(t==null||t.includes(Xp))return Xp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=G$.exec(e))!==null&&n!==void 0?n:[],o=ya.parse(r??""),l=ya.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return Xp;e=e.replace(G$,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,m]=(u=W$.exec(e))!==null&&u!==void 0?u:[],p=ya.parse(d??""),b=ya.parse(m??""),y=f==="+"?p.add(b):p.subtract(b);if(y.isNaN())return Xp;e=e.replace(W$,y.toString())}return e}var q$=/\(([^()]*)\)/;function DNe(t){for(var e=t,n;(n=q$.exec(e))!=null;){var[,r]=n;e=e.replace(q$,RQ(r))}return e}function ONe(t){var e=t.replace(/\s+/g,"");return e=DNe(e),e=RQ(e),e}function LNe(t){try{return ONe(t)}catch{return Xp}}function EC(t){var e=LNe(t.slice(5,-1));return e===Xp?"":e}var INe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],FNe=["dx","dy","angle","className","breakAll"];function p3(){return p3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p3.apply(null,arguments)}function K$(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 DQ=/[ \f\n\r\t\v\u2028\u2029]+/,OQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Vr(e)||(n?i=e.toString().split(""):i=e.toString().split(DQ));var a=i.map(l=>({word:l,width:r0(l,r).width})),o=n?0:r0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function zNe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var LQ=(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},[]),IQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),BNe="…",X$=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=OQ({breakAll:n,style:r,children:c+BNe});if(!u)return[!1,[]];var d=LQ(u.wordsWithComputedWidth,a,o,l),f=d.length>i||IQ(d).width>Number(a);return[f,d]},$Ne=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=zt(a),d=String(o),f=LQ(e,r,n,i);if(!u||i)return f;var m=f.length>a||IQ(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]=X$(d,S,c,l,a,r,n,i),[T]=X$(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},Y$=t=>{var e=Vr(t)?[]:t.toString().split(DQ);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)&&!jy.isSsr){var l,c,u=OQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return Y$(r);return $Ne({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return Y$(r)},FQ="#808080",VNe={angle:0,breakAll:!1,capHeight:"0.71em",fill:FQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},eE=w.forwardRef((t,e)=>{var n=Kr(t,VNe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=K$(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=K$(f,FNe);if(!Io(r)||!Io(i)||m.length===0)return null;var M=Number(r)+(zt(p)?p:0),A=Number(i)+(zt(b)?b:0);if(!mn(M)||!mn(A))return null;var T;switch(d){case"start":T=EC("calc(".concat(o,")"));break;case"middle":T=EC("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:T=EC("calc(".concat(m.length-1," * -").concat(a,")"));break}var k=[],E=m[0];if(c&&E!=null){var D=E.width,{width:C}=f;k.push("scale(".concat(zt(C)&&zt(D)?C/D:1,")"))}return y&&k.push("rotate(".concat(y,", ").concat(M,", ").concat(A,")")),k.length&&(S.transform=k.join(" ")),w.createElement("text",p3({},Ta(S),{ref:e,x:M,y:A,className:Bn("recharts-text",x),textAnchor:u,fill:l.includes("url")?FQ:l}),m.map((R,U)=>{var O=R.words.join(v?"":" ");return w.createElement("tspan",{x:M,dy:U===0?T:a,key:"".concat(O,"-").concat(U)},O)}))});eE.displayName="Text";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 Al(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){GNe(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 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}=mO(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 D={x:d+c/2,y:o-x,horizontalAnchor:"middle",verticalAnchor:v};return E&&(D.height=Math.max(o-E.y,0),D.width=c),D}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 R={x:m-A,y:o+l/2,horizontalAnchor:T,verticalAnchor:"middle"};return E&&(R.width=Math.max(R.x-E.x,0),R.height=l),R}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 O=E?{width:p,height:l}:{};return n==="insideLeft"?Al({x:m+A,y:o+l/2,horizontalAnchor:k,verticalAnchor:"middle"},O):n==="insideRight"?Al({x:m+p-A,y:o+l/2,horizontalAnchor:T,verticalAnchor:"middle"},O):n==="insideTop"?Al({x:d+c/2,y:o+x,horizontalAnchor:"middle",verticalAnchor:S},O):n==="insideBottom"?Al({x:f+u/2,y:o+l-x,horizontalAnchor:"middle",verticalAnchor:v},O):n==="insideTopLeft"?Al({x:d+A,y:o+x,horizontalAnchor:k,verticalAnchor:S},O):n==="insideTopRight"?Al({x:d+c-A,y:o+x,horizontalAnchor:T,verticalAnchor:S},O):n==="insideBottomLeft"?Al({x:f+A,y:o+l-x,horizontalAnchor:k,verticalAnchor:v},O):n==="insideBottomRight"?Al({x:f+u-A,y:o+l-x,horizontalAnchor:T,verticalAnchor:v},O):n&&typeof n=="object"&&(zt(n.x)||Kf(n.x))&&(zt(n.y)||Kf(n.y))?Al({x:a+Ba(n.x,p),y:o+Ba(n.y,l),horizontalAnchor:"end",verticalAnchor:"end"},O):Al({x:b,y:o+l/2,horizontalAnchor:"middle",verticalAnchor:"middle"},O)},XNe=["labelRef"],YNe=["content"];function Q$(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 J$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J$(Object(n),!0).forEach(function(r){QNe(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 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 Kc(){return Kc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Kc.apply(null,arguments)}var UQ=w.createContext(null),zQ=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(UQ.Provider,{value:c},l)},BQ=()=>{var t=w.useContext(UQ),e=Ty();return t||(e?mO(e):void 0)},tEe=w.createContext(null),nEe=()=>{var t=w.useContext(tEe),e=Vt(TZ);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},k4=t=>t!=null&&typeof t=="function",iEe=(t,e)=>{var n=Ji(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=Ei(l,c,b,v),A=Ei(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)?R0("recharts-radial-line-"):t.id;return w.createElement("text",Kc({},r,{dominantBaseline:"central",className:Bn("recharts-radial-bar-label",o)}),w.createElement("defs",null,w.createElement("path",{id:k,d: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}=Ei(r,i,o+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var m=(a+o)/2,{x:p,y:b}=Ei(r,i,m,u);return{x:p,y:b,textAnchor:"middle",verticalAnchor:"middle"}},c1=t=>t!=null&&"cx"in t&&zt(t.cx),oEe={angle:0,offset:5,zIndex:li.label,position:"middle",textBreakAll:!1};function lEe(t){if(!c1(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 bd(t){var e=Kr(t,oEe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:l,className:c="",textBreakAll:u,labelRef:d}=e,f=nEe(),m=BQ(),p=i==="center"?m:f??m,b,y,x;n==null?b=p:c1(n)?b=n:b=mO(n);var v=lEe(b);if(!b||Vr(a)&&Vr(o)&&!w.isValidElement(l)&&typeof l!="function")return null;var S=zb(zb({},e),{},{viewBox:b});if(w.isValidElement(l)){var{labelRef:M}=S,A=Q$(S,XNe);return w.cloneElement(l,A)}if(typeof l=="function"){var{content:T}=S,k=Q$(S,YNe);if(y=w.createElement(l,k),w.isValidElement(y))return y}else y=rEe(e);var E=Ta(e);if(c1(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 D=KNe({viewBox:v,position:i,offset:e.offset,parentViewBox:c1(r)?void 0:r});x=zb(zb({x:D.x,y:D.y,textAnchor:D.horizontalAnchor,verticalAnchor:D.verticalAnchor},D.width!==void 0?{width:D.width}:{}),D.height!==void 0?{height:D.height}:{})}return w.createElement($a,{zIndex:e.zIndex},w.createElement(eE,Kc({ref:d,className:Bn("recharts-label",c)},E,x,{textAnchor:zNe(E.textAnchor)?E.textAnchor:x.textAnchor,breakAll:u}),y))}bd.displayName="Label";var cEe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?w.createElement(bd,Kc({key:"label-implicit"},r)):Io(t)?w.createElement(bd,Kc({key:"label-implicit",value:t},r)):w.isValidElement(t)?t.type===bd?w.cloneElement(t,zb({key:"label-implicit"},r)):w.createElement(bd,Kc({key:"label-implicit",content:t},r)):k4(t)?w.createElement(bd,Kc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?w.createElement(bd,Kc({},t,{key:"label-implicit"},r)):null};function $Q(t){var{label:e,labelRef:n}=t,r=BQ();return cEe(e,r,n)||null}var AC={},TC={},eH;function uEe(){return eH||(eH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(TC)),TC}var CC={},tH;function dEe(){return tH||(tH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(CC)),CC}var nH;function hEe(){return nH||(nH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uEe(),n=dEe(),r=rO();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(AC)),AC}var kC,rH;function fEe(){return rH||(rH=1,kC=hEe().last),kC}var mEe=fEe();const pEe=ml(mEe);var gEe=["valueAccessor"],xEe=["dataKey","clockWise","id","textBreakAll","zIndex"];function AS(){return AS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},AS.apply(null,arguments)}function iH(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,HQ=w.createContext(void 0),j4=HQ.Provider,VQ=w.createContext(void 0),vEe=VQ.Provider;function _Ee(){return w.useContext(HQ)}function wEe(){return w.useContext(VQ)}function u1(t){var{valueAccessor:e=yEe}=t,n=iH(t,gEe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=iH(n,xEe),u=_Ee(),d=wEe(),f=u||d;return!f||!f.length?null:w.createElement($a,{zIndex:l??li.label},w.createElement(qr,{className:"recharts-label-list"},f.map((m,p)=>{var b,y=Vr(r)?e(m,p):tr(m.payload,r),x=Vr(a)?{}:{id:"".concat(a,"-").concat(p)};return w.createElement(bd,AS({key:"label-".concat(p)},Ta(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}))})))}u1.displayName="LabelList";function tE(t){var{label:e}=t;return e?e===!0?w.createElement(u1,{key:"labelList-implicit"}):w.isValidElement(e)||k4(e)?w.createElement(u1,{key:"labelList-implicit",content:e}):typeof e=="object"?w.createElement(u1,AS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}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)}var GQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=Bn("recharts-dot",i);return zt(e)&&zt(n)&&zt(r)?w.createElement("circle",g3({},ns(t),nO(t),{className:a,cx:e,cy:n,r})):null},WQ=t=>t.graphicalItems.polarItems,SEe=tt([Xr,Iy],e4),nE=tt([WQ,ui,SEe],t4),MEe=tt([nE],n4),rE=tt([MEe,BN],r4),NEe=tt([rE,ui,nE],a4);tt([rE,ui,nE],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=tr(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:tr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var aH=()=>{},EEe=tt([rE,ui,nE,YN,Xr],c4),AEe=tt([ui,o4,l4,aH,EEe,aH,Un,Xr],u4),qQ=tt([ui,Un,rE,NEe,Ly,Xr,AEe],d4),TEe=tt([qQ,ix,xh],m4),CEe=tt([ui,qQ,TEe,Xr],g4);tt([xh,CEe],kZ);var kEe={radiusAxis:{},angleAxis:{}},KQ=Es({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}=KQ.actions,jEe=KQ.reducer;function XQ(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}function sH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function oH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sH(Object(n),!0).forEach(function(r){PEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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,P4=tt([WQ,OEe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),LEe=[],R4=(t,e,n)=>n?.length===0?LEe:n,YQ=tt([BN,P4,R4],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>oH(oH({},e.presentationProps),a.props))),i!=null)return i}}),IEe=tt([YQ,P4,R4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=tr(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:fh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),FEe=tt([YQ,P4,R4,Ui],(t,e,n,r)=>{if(!(e==null||t==null))return U2e({offset:r,pieSettings:e,displayedData:t,cells:n})}),jC={exports:{}},hr={};var lH;function UEe(){if(lH)return hr;lH=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function b(y){if(typeof y=="object"&&y!==null){var x=y.$$typeof;switch(x){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case m:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case f:case d:return y;case a:return y;default:return x}}case e:return x}}}return 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 cH;function zEe(){return cH||(cH=1,jC.exports=UEe()),jC.exports}var BEe=zEe(),uH=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",dH=null,PC=null,ZQ=t=>{if(t===dH&&Array.isArray(PC))return PC;var e=[];return w.Children.forEach(t,n=>{Vr(n)||(BEe.isFragment(n)?e=e.concat(ZQ(n.props.children)):e.push(n))}),PC=e,dH=t,e};function D4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>uH(i)):r=[uH(e)],ZQ(t).forEach(i=>{var a=qf(i,"type.displayName")||qf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var O4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,RC={},hH;function $Ee(){return hH||(hH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(RC)),RC}var DC,fH;function HEe(){return fH||(fH=1,DC=$Ee().isPlainObject),DC}var VEe=HEe();const GEe=ml(VEe);var mH,pH,gH,xH,bH;function yH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yH(Object(n),!0).forEach(function(r){WEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 TS(){return TS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},TS.apply(null,arguments)}function gb(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}var _H=(t,e,n,r,i)=>{var a=n-r,o;return o=ri(mH||(mH=gb(["M ",",",""])),t,e),o+=ri(pH||(pH=gb(["L ",",",""])),t+n,e),o+=ri(gH||(gH=gb(["L ",",",""])),t+n-a/2,e+i),o+=ri(xH||(xH=gb(["L ",",",""])),t+n-a/2-r,e+i),o+=ri(bH||(bH=gb(["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=Kr(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=Jg(t,"trapezoid-");if(w.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var j=m.current.getTotalLength();j&&b(j)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var T=Bn("recharts-trapezoid",l);if(!f)return w.createElement("g",null,w.createElement("path",TS({},Ta(e),{className:T,d:_H(n,r,i,a,o)})));var k=y.current,E=x.current,D=v.current,C=S.current,R=M.current,U="0px ".concat(p===-1?1:p,"px"),O="".concat(p,"px 0px"),q=yY(["strokeDasharray"],u,c);return w.createElement(Qg,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},j=>{var W=Jn(k,i,j),K=Jn(E,a,j),G=Jn(D,o,j),Q=Jn(C,n,j),te=Jn(R,r,j);m.current&&(y.current=W,x.current=K,v.current=G,S.current=Q,M.current=te);var J=j>0?{transition:q,strokeDasharray:O}:{strokeDasharray:U};return w.createElement("path",TS({},Ta(e),{className:T,d:_H(Q,te,W,K,G),ref:m,style:vH(vH({},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 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 CS(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){e2e(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 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 CS(CS({},e),t)}function i2e(t,e){return t==="symbols"}function SH(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return w.createElement(SY,n);case"trapezoid":return w.createElement(YEe,n);case"sector":return w.createElement(AY,n);case"symbols":if(i2e(e))return w.createElement(tO,n);break;case"curve":return w.createElement(ig,n);default:return null}}function a2e(t){return w.isValidElement(t)?t.props:t}function L4(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,CS(CS({},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(SH,{shapeType:n,elementProps:o})}else{var l=i;a=w.createElement(SH,{shapeType:n,elementProps:l})}return i.isActive?w.createElement(qr,{className:r},a):a}var I4=(t,e,n)=>{var r=Mr();return(i,a)=>o=>{t?.(i,a,o),r(sQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},F4=t=>{var e=Mr();return(n,r)=>i=>{t?.(n,r,i),e(uSe())}},U4=(t,e,n)=>{var r=Mr();return(i,a)=>o=>{t?.(i,a,o),r(dSe({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function iE(t){var{tooltipEntrySettings:e}=t,n=Mr(),r=zi(),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 z4(t){var{legendPayload:e}=t,n=Mr(),r=zi(),i=w.useRef(null);return w.useLayoutEffect(()=>{r||(i.current===null?n(pY(e)):i.current!==e&&n(gY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(xY(i.current)),i.current=null)},[n]),null}function s2e(t){var{legendPayload:e}=t,n=Mr(),r=Vt(Un),i=w.useRef(null);return w.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(pY(e)):i.current!==e&&n(gY({prev:i.current,next:e})),i.current=e)},[n,r,e]),w.useLayoutEffect(()=>()=>{i.current&&(n(xY(i.current)),i.current=null)},[n]),null}var OC,o2e=()=>{var[t]=w.useState(()=>R0("uid-"));return t},l2e=(OC=roe.useId)!==null&&OC!==void 0?OC:o2e;function c2e(t,e){var n=l2e();return e||(t?"".concat(t,"-").concat(n):n)}var u2e=w.createContext(void 0),aE=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:[]},QQ=Es({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=sl(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Fr()},removeCartesianGraphicalItem:{reducer(t,e){var n=sl(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=sl(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Fr()}}}),{addCartesianGraphicalItem:h2e,replaceCartesianGraphicalItem:f2e,removeCartesianGraphicalItem:m2e,addPolarGraphicalItem:p2e,removePolarGraphicalItem:g2e}=QQ.actions,x2e=QQ.reducer,b2e=t=>{var e=Mr(),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},B4=w.memo(b2e);function y2e(t){var e=Mr();return w.useLayoutEffect(()=>(e(p2e(t)),()=>{e(g2e(t))}),[e,t]),null}var v2e=["key"],_2e=["onMouseEnter","onClick","onMouseLeave"],w2e=["id"],S2e=["id"];function MH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ii(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?MH(Object(n),!0).forEach(function(r){M2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):MH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 th(){return th=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},th.apply(null,arguments)}function sE(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(()=>D4(t.children,Vy),[t.children]),n=Vt(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:fh(l,e),hide:c,type:u,color:o,unit:"",graphicalItemId:d}};return w.createElement(iE,{tooltipEntrySettings:f})}),k2e=(t,e)=>t>e?"start":t<e?"end":"middle",j2e=(t,e,n)=>Ba(typeof e=="function"?e(t):e,n,n*.8),P2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=MY(a,o),c=i+Ba(t.cx,a,a/2),u=r+Ba(t.cy,o,o/2),d=Ba(t.innerRadius,l,0),f=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=Ji(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=Bn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=sE(e,v2e);return w.createElement(ig,th({},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=Bn("recharts-pie-label-text",XQ(t));return w.createElement(eE,th({},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=ns(n),c=Gf(i),u=Gf(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=Ei(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:[Ei(m.cx,m.cy,m.outerRadius,b),y],key:"line"});return w.createElement($a,{zIndex:li.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(p)},w.createElement(qr,null,a&&D2e(a,v),O2e(i,x,tr(m,o))))});return w.createElement(qr,{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(tE,{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=Vt(eh),c=Vt(N4),u=Vt(YSe),{onMouseEnter:d,onClick:f,onMouseLeave:m}=i,p=sE(i,_2e),b=I4(d,i.dataKey,o),y=F4(m),x=U4(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,[tY]:S,[nY]:o});return w.createElement(qr,th({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},My(p,v,S),{onMouseEnter:b(v,S),onMouseLeave:y(v,S),onClick:x(v,S)}),w.createElement(L4,th({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=>tr(k,u,0)!==0).length,v=(b>=360?x:x-1)*y,S=b-x*m-v,M=r.reduce((k,E)=>{var D=tr(E,u,0);return k+(zt(D)?D:0)},0),A;if(M>0){var T;A=r.map((k,E)=>{var D=tr(k,u,0),C=tr(k,d,E),R=P2e(n,a,k),U=(zt(D)?D:0)/M,O,q=ii(ii({},k),i&&i[E]&&i[E].props);E?O=T.endAngle+Ji(p)*y*(D!==0?1:0):O=l;var j=O+Ji(p)*((D!==0?m:0)+U*S),W=(O+j)/2,K=(R.innerRadius+R.outerRadius)/2,G=[{name:C,value:D,payload:q,dataKey:u,type:f,graphicalItemId:n.id}],Q=Ei(R.cx,R.cy,K,W);return T=ii(ii(ii(ii({},n.presentationProps),{},{percent:U,cornerRadius:typeof o=="string"?parseFloat(o):o,name:C,tooltipPayload:G,midAngle:W,middleRadius:K,tooltipPosition:Q},q),R),{},{value:D,dataKey:u,startAngle:O,endAngle:j,payload:q,paddingAngle:Ji(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=Jg(e,"recharts-pie-"),b=n.current,[y,x]=w.useState(!1),v=w.useCallback(()=>{typeof m=="function"&&m(),x(!1)},[m]),S=w.useCallback(()=>{typeof f=="function"&&f(),x(!0)},[f]);return w.createElement(z2e,{showLabels:!y,sectors:i},w.createElement(Qg,{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((D,C)=>{var R=b&&b[C],U=C>0?qf(D,"paddingAngle",0):0;if(R){var O=Jn(R.endAngle-R.startAngle,D.endAngle-D.startAngle,M),q=ii(ii({},D),{},{startAngle:E+U,endAngle:E+O+U});T.push(q),E=q.endAngle}else{var{endAngle:j,startAngle:W}=D,K=Jn(0,j-W,M),G=ii(ii({},D),{},{startAngle:E+U,endAngle:E+K+U});T.push(G),E=G.endAngle}}),n.current=T,w.createElement(qr,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=sE(t,w2e),{hide:r,className:i,rootTabIndex:a}=t,o=w.useMemo(()=>D4(t.children,Vy),[t.children]),l=Vt(d=>FEe(d,e,o)),c=w.useRef(null),u=Bn("recharts-pie",i);return r||l==null?(c.current=null,w.createElement(qr,{tabIndex:a,className:u})):w.createElement($a,{zIndex:t.zIndex},w.createElement(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(qr,{tabIndex:a,className:u},w.createElement(B2e,{props:ii(ii({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function JQ(t){var e=Kr(t,$2e),{id:n}=e,r=sE(e,S2e),i=ns(r);return w.createElement(aE,{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,th({},r,{id:a})),w.createElement(H2e,th({},r,{id:a}))))}JQ.displayName="Pie";var V2e=["points"];function NH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NH(Object(n),!0).forEach(function(r){G2e(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 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 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 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=Bn(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=K2e(a,V2e);return w.createElement(GQ,kS({},l,{className:i}))}function Z2e(t,e){return t==null?!1:e?!0:t.length===1}function eJ(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=O4(n),f=ype(n),m=e.map((b,y)=>{var x,v,S=LC(LC(LC({r:3},o),f),{},{index:y,cx:(x=b.x)!==null&&x!==void 0?x:void 0,cy:(v=b.y)!==null&&v!==void 0?v:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return w.createElement(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($a,{zIndex:u},w.createElement(qr,kS({className:r},p),m))}function EH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function AH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?EH(Object(n),!0).forEach(function(r){Q2e(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 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 tJ=0,tAe={xAxis:{},yAxis:{},zAxis:{}},nJ=Es({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]=AH(AH({},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}=nJ.actions,cAe=nJ.reducer,uAe=tt([Ui],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),dAe=tt([uAe,Nu,Eu],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),oE=()=>Vt(dAe),hAe=()=>Vt(tMe);function TH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function IC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TH(Object(n),!0).forEach(function(r){fAe(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 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=IC(IC(IC({},l),Gf(i)),nO(i)),u;return w.isValidElement(i)?u=w.cloneElement(i,c):typeof i=="function"?u=i(c):u=w.createElement(GQ,c),w.createElement(qr,{className:"recharts-active-dot",clipPath:o},u)};function x3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=li.activeDot}=t,l=Vt(eh),c=hAe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Vr(u)?null:w.createElement($a,{zIndex:o},w.createElement(gAe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var CH=(t,e,n)=>{var r=n??t;if(!Vr(r))return Ba(r,e,0)},xAe=(t,e,n)=>{var r={},i=t.filter(WN),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>{var f=u[d.stackId];return f==null&&(f=[]),f.push(d),u[d.stackId]=f,u},r),l=Object.entries(o).map(u=>{var d,[f,m]=u,p=m.map(y=>y.dataKey),b=CH(e,n,(d=m[0])===null||d===void 0?void 0:d.barSize);return{stackId:f,dataKeys:p,barSize:b}}),c=a.map(u=>{var d=[u.dataKey].filter(m=>m!=null),f=CH(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]};function kH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function R_(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){bAe(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 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=Ba(t,n,0,!0),c,u=[];if(mn((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=Ba(e,n,0,!0);n-2*y-(o-1)*l<=0&&(l=0);var x=(n-2*y-(o-1)*l)/o;x>1&&(x>>=0);var v=mn(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=>R_(R_({},u),{},{position:R_(R_({},u.position),{},{offset:u.position.offset-i/2})}))),c},SAe=(t,e)=>{var n=GN(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},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"&&mn(t.zIndex)?t.zIndex:e}var rJ=t=>{var{chartData:e}=t,n=Mr(),r=zi();return w.useEffect(()=>r?()=>{}:(n(L$(e)),()=>{n(L$(void 0))}),[e,n,r]),null},jH={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},iJ=Es({name:"brush",initialState:jH,reducers:{setBrushSettings(t,e){return e.payload==null?jH:e.payload}}}),{setBrushSettings:uQe}=iJ.actions,EAe=iJ.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:[]},aJ=Es({name:"referenceElements",initialState:jAe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=sl(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=sl(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=sl(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}=aJ.actions,DAe=aJ.reducer,sJ=w.createContext(void 0),OAe=t=>{var{children:e}=t,[n]=w.useState("".concat(R0("recharts"),"-clip")),r=oE();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return w.createElement(sJ.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(sJ);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 PH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PH(Object(n),!0).forEach(function(r){FAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 jS(){return jS=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},jS.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(!mn(e.x1)||!mn(e.y1)||!mn(e.x2)||!mn(e.y2))return null;n=w.createElement("line",jS({},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(!mn(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(!mn(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=Io(l),m=Io(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=Mr();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=zi(),l=LAe(),c=Vt(E=>cc(E,e)),u=Vt(E=>uc(E,n)),d=Vt(E=>Eg(E,"xAxis",e,o)),f=Vt(E=>Eg(E,"yAxis",n,o)),m=Ty();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=RH(RH({clipPath:A},Ta(t)),{},{x1:x,y1:v,x2:S,y2:M}),k=TAe({x1:x,y1:v,x2:S,y2:M});return w.createElement($a,{zIndex:t.zIndex},w.createElement(qr,{className:Bn("recharts-reference-line",i)},BAe(r,T),w.createElement(zQ,jS({},k,{lowerWidth:k.width,upperWidth:k.width}),w.createElement($Q,{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 Bb(t){var e=Kr(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))}Bb.displayName="ReferenceLine";function oJ(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 q0(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 oJ(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:oJ(r,u)};var y=c,x,v=()=>(x===void 0&&(x=n(b,y)),x),S=b.coordinate,M=c===0||q0(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),D=A.coordinate,C=y===d||q0(t,D,E,f,c);if(!C)return m=!1,1;C&&(f=D+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 DH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function La(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DH(Object(n),!0).forEach(function(r){eTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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=La(La({},b),{},{tickCoord:v>0?b.coordinate-v*t:b.coordinate})}else a[m]=b=La(La({},b),{},{tickCoord:b.coordinate});if(b.tickCoord!=null){var S=q0(t,b.tickCoord,x,l,c);S&&(c=b.tickCoord-t*(x()/2+i),a[m]=La(La({},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=La(La({},d),{},{tickCoord:m>0?d.coordinate-m*t:d.coordinate}),d.tickCoord!=null){var p=q0(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=La(La({},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=La(La({},A),{},{tickCoord:E<0?A.coordinate-E*t:A.coordinate})}else o[S]=A=La(La({},A),{},{tickCoord:A.coordinate});if(A.tickCoord!=null){var D=q0(t,A.tickCoord,k,c,u);D&&(c=A.tickCoord+t*(k()/2+i),o[S]=La(La({},A),{},{isShow:!0}))}},x=0;x<b;x++)y(x);return o}function $4(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(zt(c)||jy.isSsr){var m;return(m=ZAe(i,zt(c)?c:0))!==null&&m!==void 0?m:[]}var p=[],b=l==="top"||l==="bottom"?"width":"height",y=d&&b==="width"?r0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(T,k)=>{var E=typeof u=="function"?u(T.value,k):T.value;return b==="width"?XAe(r0(E,{fontSize:e,letterSpacing:n}),y,f):r0(E,{fontSize:e,letterSpacing:n})[b]},v=i[0],S=i[1],M=i.length>=2&&v!=null&&S!=null?Ji(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 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 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 ni(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){cTe(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 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 su={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),ns(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",Jf({},u,{className:Bn("recharts-cartesian-axis-line",qf(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=zt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,m=n+ +!l*i,f=m-y*x,b=f-y*c,p=v;break;case"left":f=m=t.coordinate,d=e+ +!l*r,u=d-y*x,p=u-y*c,b=v;break;case"right":f=m=t.coordinate,d=e+ +l*r,u=d+y*x,p=u+y*c,b=v;break;default:u=d=t.coordinate,m=n+ +l*i,f=m+y*x,b=f+y*c,p=v;break}return{line:{x1:u,y1:f,x2:d,y2:m},tick:{x:p,y:b}}}function 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=Bn(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=Bn(o,XQ(e))),i=w.createElement(eE,Jf({},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=$4(ni(ni({},A),{},{ticks:n}),S,M),D=mTe(d,f),C=pTe(d,f),R=ns(A),U=Gf(r),O={};typeof i=="object"&&(O=i);var q=ni(ni({},R),{},{fill:"none"},O),j=E.map(G=>ni({entry:G},fTe(G,m,p,b,y,d,x,f,v))),W=j.map(G=>{var{entry:Q,line:te}=G;return w.createElement(qr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},i&&w.createElement("line",Jf({},q,te,{className:Bn("recharts-cartesian-axis-tick-line",qf(i,"className"))})))}),K=j.map((G,Q)=>{var te,J,{entry:z,tick:V}=G,ne=ni(ni(ni(ni({verticalAnchor:C},R),{},{textAnchor:D,stroke:"none",fill:a},V),{},{index:Q,payload:z,visibleTicksCount:E.length,tickFormatter:o,padding:c},u),{},{angle:(te=(J=u?.angle)!==null&&J!==void 0?J:R.angle)!==null&&te!==void 0?te:0}),ae=ni(ni({},ne),U);return w.createElement(qr,Jf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(z.value,"-").concat(z.coordinate,"-").concat(z.tickCoord)},My(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($a,{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($a,{zIndex:t.zIndex},w.createElement(qr,{className:Bn("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:ns(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(zQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},w.createElement($Q,{label:t.label,labelRef:t.labelRef}),t.children)))}),H4=w.forwardRef((t,e)=>{var n=Kr(t,su);return w.createElement(bTe,Jf({},n,{ref:e}))});H4.displayName="CartesianAxis";var yTe=["x1","y1","x2","y2","key"],vTe=["offset"],_Te=["xAxisId","yAxisId"],wTe=["xAxisId","yAxisId"];function LH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ua(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LH(Object(n),!0).forEach(function(r){STe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 gf(){return gf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},gf.apply(null,arguments)}function PS(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 lJ(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=PS(n,yTe),f=(i=ns(d))!==null&&i!==void 0?i:{},{offset:m}=f,p=PS(f,vTe);r=w.createElement("line",gf({},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=PS(t,_Te),c=i.map((u,d)=>{var f=Ua(Ua({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return w.createElement(lJ,{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=PS(t,wTe),c=i.map((u,d)=>{var f=Ua(Ua({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return w.createElement(lJ,{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 ZX($4(Ua(Ua(Ua({},su),n),{},{ticks:QX(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 ZX($4(Ua(Ua(Ua({},su),n),{},{ticks:QX(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 RS(t){var e=pO(),n=gO(),r=sY(),i=Ua(Ua({},Kr(t,DTe)),{},{x:zt(t.x)?t.x:r.left,y:zt(t.y)?t.y:r.top,width:zt(t.width)?t.width:r.width,height:zt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:m,verticalValues:p}=i,b=zi(),y=Vt(C=>M$(C,"xAxis",a,b)),x=Vt(C=>M$(C,"yAxis",o,b));if(!Jl(u)||!Jl(d)||!zt(l)||!zt(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?Ua(Ua({},x),{},{ticks:T?m:x.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);nS(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,D=v({xAxis:y?Ua(Ua({},y),{},{ticks:E?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);nS(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(A=D)}return w.createElement($a,{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,gf({},i,{horizontalPoints:M})),w.createElement(jTe,gf({},i,{verticalPoints:A})),w.createElement(TTe,gf({},i,{offset:r,horizontalPoints:M,xAxis:y,yAxis:x})),w.createElement(CTe,gf({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:x}))))}RS.displayName="CartesianGrid";var OTe={},cJ=Es({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}=cJ.actions,LTe=cJ.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 uJ(t){var{children:e}=t,n=FTe(t,ITe);return w.createElement(BTe.Provider,{value:n},e)}function lE(t,e){var n,r,i=Vt(u=>cc(u,t)),a=Vt(u=>uc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Ki.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Xi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function V4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=oE(),{needClipX:a,needClipY:o,needClip:l}=lE(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return w.createElement("clipPath",{id:"clipPath-".concat(r)},w.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}var dJ=(t,e,n,r)=>nc(t,"xAxis",e,r),hJ=(t,e,n,r)=>tc(t,"xAxis",e,r),fJ=(t,e,n,r)=>nc(t,"yAxis",n,r),mJ=(t,e,n,r)=>tc(t,"yAxis",n,r),$Te=tt([Un,dJ,fJ,hJ,mJ],(t,e,n,r,i)=>xl(t,"xAxis")?Jd(e,r,!1):Jd(n,i,!1)),HTe=(t,e,n,r,i)=>i;function VTe(t){return t.type==="line"}var GTe=tt([Fy,HTe],(t,e)=>t.filter(VTe).find(n=>n.id===e)),WTe=tt([Un,dJ,fJ,hJ,mJ,GTe,$Te,VO],(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 pJ(t){var e=Gf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,o=Number(i),l=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var FC={exports:{}},UC={};var IH;function qTe(){if(IH)return UC;IH=1;var t=Gg();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return UC.useSyncExternalStoreWithSelector=function(c,u,d,f,m){var p=i(null);if(p.current===null){var b={hasValue:!1,value:null};p.current=b}else b=p.current;p=o(function(){function x(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},UC}var FH;function KTe(){return FH||(FH=1,FC.exports=qTe()),FC.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 UH={notify(){},get:()=>[]};function ZTe(t,e){let n,r=UH,i=0,a=!1;function o(y){d();const x=r.subscribe(y);let v=!1;return()=>{v||(v=!0,x(),f())}}function l(){r.notify()}function c(){b.onStateChange&&b.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=YTe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=UH)}function m(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const b={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:m,tryUnsubscribe:p,getListeners:()=>r};return b}var 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 zH(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function iCe(t,e){if(zH(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(!Object.prototype.hasOwnProperty.call(e,n[i])||!zH(t[n[i]],e[n[i]]))return!1;return!0}var 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 Gy(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 K0(){return K0=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},K0.apply(null,arguments)}function BH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ol(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BH(Object(n),!0).forEach(function(r){gCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 G4(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:fh(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:hh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:fh(o,e),hide:l,type:u,color:r,unit:c,graphicalItemId:d}};return w.createElement(iE,{tooltipEntrySettings:f})}),gJ=(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 gJ(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=G4(r,fCe),u=ns(c);return w.createElement(eJ,{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 Ol(Ol({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return w.createElement(j4,{value:e?i:void 0},n)}function $H(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=G4(a,mCe),m=Ol(Ol({},Ta(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(L4,K0({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=Jg(o,"recharts-line-"),M=w.useRef(S),[A,T]=w.useState(!1),k=!A,E=w.useCallback(()=>{typeof y=="function"&&y(),T(!1)},[y]),D=w.useCallback(()=>{typeof x=="function"&&x(),T(!0)},[x]),C=ECe(r.current),R=w.useRef(0);M.current!==S&&(R.current=a.current,M.current=S);var U=R.current;return w.createElement(NCe,{points:o,showLabels:k},n.children,w.createElement(Qg,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:E,onAnimationStart:D,key:S},O=>{var q=Jn(U,C+U,O),j=Math.min(q,C),W;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(te=>parseFloat(te));W=SCe(j,C,K)}else W=gJ(C,j);else W=l==null?void 0:String(l);if(O>0&&C>0&&(i.current=o,a.current=Math.max(a.current,j)),v){var G=v.length/o.length,Q=O===1?o:o.map((te,J)=>{var z=Math.floor(J*G);if(v[z]){var V=v[z];return Ol(Ol({},te),{},{x:Jn(V.x,te.x,O),y:Jn(V.y,te.y,O)})}return m?Ol(Ol({},te),{},{x:Jn(p*2,te.x,O),y:Jn(b/2,te.y,O)}):Ol(Ol({},te),{},{x:te.x,y:te.y})});return i.current=Q,w.createElement($H,{props:n,points:Q,clipPathId:e,pathRef:r,strokeDasharray:W})}return w.createElement($H,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:W})}),w.createElement(tE,{label:n.label}))}function 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:tr(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=Bn("recharts-line",i),y=f,{r:x,strokeWidth:v}=pJ(n),S=O4(n),M=x*2+v,A=m?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return w.createElement($a,{zIndex:p},w.createElement(qr,{className:b},m&&w.createElement("defs",null,w.createElement(V4,{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(uJ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:CCe,errorBarOffset:0},w.createElement(TCe,{props:this.props,clipPathId:y}))),w.createElement(x3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var xJ={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=Kr(t,xJ),{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=G4(e,pCe),{needClip:v}=lE(p,b),S=oE(),M=mh(),A=zi(),T=Vt(R=>WTe(R,p,b,A,y));if(M!=="horizontal"&&M!=="vertical"||T==null||S==null)return null;var{height:k,width:E,x:D,y:C}=S;return w.createElement(kCe,K0({},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:D,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=tr(u,o);if(e==="horizontal"){var m=tS({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=tS({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=Kr(t,xJ),n=zi();return w.createElement(aE,{id:e.id,type:"line"},r=>w.createElement(w.Fragment,null,w.createElement(z4,{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(B4,{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,K0({},e,{id:r}))))}var bJ=w.memo(RCe,Gy);bJ.displayName="Line";function dc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.xAxisId)!==null&&n!==void 0?n:tJ}function hc(t,e){var n,r;return(n=(r=t.graphicalItems.cartesianItems.find(i=>i.id===e))===null||r===void 0?void 0:r.yAxisId)!==null&&n!==void 0?n:tJ}var yJ=(t,e,n)=>nc(t,"xAxis",dc(t,e),n),vJ=(t,e,n)=>tc(t,"xAxis",dc(t,e),n),_J=(t,e,n)=>nc(t,"yAxis",hc(t,e),n),wJ=(t,e,n)=>tc(t,"yAxis",hc(t,e),n),DCe=tt([Un,yJ,_J,vJ,wJ],(t,e,n,r,i)=>xl(t,"xAxis")?Jd(e,r,!1):Jd(n,i,!1)),OCe=(t,e)=>e,SJ=tt([Fy,OCe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),MJ=t=>{var e=Un(t),n=xl(e,"xAxis");return n?"yAxis":"xAxis"},LCe=(t,e)=>{var n=MJ(t);return n==="yAxis"?hc(t,e):dc(t,e)},ICe=(t,e,n)=>MS(t,MJ(t),LCe(t,e),n),FCe=tt([SJ,ICe],(t,e)=>{var n;if(!(t==null||e==null)){var{stackId:r}=t,i=GN(t);if(!(r==null||i==null)){var a=(n=e[r])===null||n===void 0?void 0:n.stackedData,o=a?.find(l=>l.key===i);if(o!=null)return o.map(l=>[l[0],l[1]])}}}),UCe=tt([Un,yJ,_J,vJ,wJ,FCe,lZ,DCe,SJ,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 Tf(){return Tf=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},Tf.apply(null,arguments)}function NJ(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 HH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Yp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HH(Object(n),!0).forEach(function(r){HCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 DS(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:DS(r,i),value:fh(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:hh,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:fh(o,e),hide:l,type:u,color:DS(r,a),unit:c,graphicalItemId:d}};return w.createElement(iE,{tooltipEntrySettings:f})});function KCe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=ns(r);return w.createElement(eJ,{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 Yp(Yp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return w.createElement(j4,{value:e?i:void 0},n)}function VH(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,m=NJ(a,zCe),p=ns(m),b=Ta(m);return w.createElement(w.Fragment,null,e?.length>1&&w.createElement(qr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},w.createElement(ig,Tf({},b,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&w.createElement(ig,Tf({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&w.createElement(ig,Tf({},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(!mn(l)||!mn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...a.map(f=>f.x||0));return zt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.x||0),d)),zt(d)?w.createElement("rect",{x:0,y:l<c?l:l-u,width:d+(o?parseInt("".concat(o),10):1),height:Math.floor(u)}):null}function 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(!mn(l)||!mn(c))return null;var u=r*Math.abs(l-c),d=Math.max(...a.map(f=>f.y||0));return zt(i)?d=Math.max(i,d):i&&Array.isArray(i)&&i.length&&(d=Math.max(...i.map(f=>f.y||0),d)),zt(d)?w.createElement("rect",{x:l<c?l:l-u,y:0,width:u,height:Math.floor(d+(o?parseInt("".concat(o),10):1))}):null}function 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=Jg(b,"recharts-area-"),x=xO(),[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(Qg,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:T,key:y},D=>{if(k){var C=k.length/o.length,R=D===1?o:o.map((O,q)=>{var j=Math.floor(q*C);if(k[j]){var W=k[j];return Yp(Yp({},O),{},{x:Jn(W.x,O.x,D),y:Jn(W.y,O.y,D)})}return O}),U;return zt(l)?U=Jn(E,l,D):Vr(l)||ul(l)?U=Jn(E,0,D):U=l.map((O,q)=>{var j=Math.floor(q*C);if(Array.isArray(E)&&E[j]){var W=E[j];return Yp(Yp({},O),{},{x:Jn(W.x,O.x,D),y:Jn(W.y,O.y,D)})}return O}),D>0&&(i.current=R,a.current=U),w.createElement(VH,{points:R,baseLine:U,needClip:e,clipPathId:n,props:r})}return D>0&&(i.current=o,a.current=l),w.createElement(qr,null,c&&w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},w.createElement(QCe,{alpha:D,points:o,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),w.createElement(qr,{clipPath:"url(#animationClipPath-".concat(n,")")},w.createElement(VH,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),w.createElement(tE,{label:r.label}))}function 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=Bn("recharts-area",i),x=m,{r:v,strokeWidth:S}=pJ(n),M=O4(n),A=v*2+S,T=l?"url(#clipPath-".concat(M?"":"dots-").concat(x,")"):void 0;return w.createElement($a,{zIndex:b},w.createElement(qr,{className:y},l&&w.createElement("defs",null,w.createElement(V4,{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(x3,{points:r,mainColor:DS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(p)&&w.createElement(x3,{points:p,mainColor:DS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var EJ={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=Kr(t,EJ),{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=NJ(n,BCe),S=mh(),M=SQ(),{needClip:A}=lE(y,x),T=zi(),{points:k,isRange:E,baseLine:D}=(e=Vt(j=>UCe(j,t.id,T)))!==null&&e!==void 0?e:{},C=oE();if(S!=="horizontal"&&S!=="vertical"||C==null||M!=="AreaChart"&&M!=="ComposedChart")return null;var{height:R,width:U,x:O,y:q}=C;return!k||!k.length?null:w.createElement(tke,Tf({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:D,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:S,isAnimationActive:m==="auto"?!jy.isSsr:m,isRange:E,legendType:p,needClip:A,points:k,stroke:b,width:U,left:O,top:q,xAxisId:y,yAxisId:x}))}var rke=(t,e,n,r,i)=>{var a=n??e;if(zt(a))return a;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function 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,D,C;if(b)C=i[d+T];else{var R=tr(A,r);Array.isArray(R)?(C=R,v=!0):C=[y,R]}var U=(k=(E=C)===null||E===void 0?void 0:E[1])!==null&&k!==void 0?k:null,O=U==null||b&&!e&&tr(A,r)==null;if(x){var q;return{x:tS({axis:l,ticks:f,bandSize:p,entry:A,index:T}),y:O?null:(q=c.scale.map(U))!==null&&q!==void 0?q:null,value:C,payload:A}}return{x:O?null:(D=l.scale.map(U))!==null&&D!==void 0?D:null,y:tS({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=Kr(t,EJ),n=zi();return w.createElement(aE,{id:e.id,type:"area"},r=>w.createElement(w.Fragment,null,w.createElement(z4,{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(B4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:JX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),w.createElement(nke,Tf({},e,{id:r}))))}var AJ=w.memo(ake,Gy);AJ.displayName="Area";var ske="Invariant failed";function oke(t,e){throw new Error(ske)}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 OS(t){return w.createElement(L4,b3({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(zt(e))return e;var a=zt(r)||Vr(r);return a?e(r,i):(a||oke(),n)}},cke=(t,e,n)=>n,uke=(t,e)=>e,Wy=tt([Fy,uke],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),dke=tt([Wy],t=>t?.maxBarSize),hke=(t,e,n,r)=>r,fke=tt([Un,Fy,dc,hc,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=Un(t),i=dc(t,e),a=hc(t,e);if(!(i==null||a==null))return r==="horizontal"?MS(t,"yAxis",a,n):MS(t,"xAxis",i,n)},pke=(t,e)=>{var n=Un(t),r=dc(t,e),i=hc(t,e);if(!(r==null||i==null))return n==="horizontal"?S$(t,"xAxis",r):S$(t,"yAxis",i)},gke=tt([fke,Xwe,pke],xAe),xke=(t,e,n)=>{var r,i,a=Wy(t,e);if(a==null)return 0;var o=dc(t,e),l=hc(t,e);if(o==null||l==null)return 0;var c=Un(t),u=vZ(t),{maxBarSize:d}=a,f=Vr(d)?u:d,m,p;return c==="horizontal"?(m=nc(t,"xAxis",o,n),p=tc(t,"xAxis",o,n)):(m=nc(t,"yAxis",l,n),p=tc(t,"yAxis",l,n)),(r=(i=Jd(m,p,!0))!==null&&i!==void 0?i:f)!==null&&r!==void 0?r:0},TJ=(t,e,n)=>{var r=Un(t),i=dc(t,e),a=hc(t,e);if(!(i==null||a==null)){var o,l;return r==="horizontal"?(o=nc(t,"xAxis",i,n),l=tc(t,"xAxis",i,n)):(o=nc(t,"yAxis",a,n),l=tc(t,"yAxis",a,n)),Jd(o,l)}},bke=tt([gke,vZ,Kwe,_Z,xke,TJ,dke],wAe),yke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return nc(t,"xAxis",r,n)},vke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return nc(t,"yAxis",r,n)},_ke=(t,e,n)=>{var r=dc(t,e);if(r!=null)return tc(t,"xAxis",r,n)},wke=(t,e,n)=>{var r=hc(t,e);if(r!=null)return tc(t,"yAxis",r,n)},Ske=tt([bke,Wy],MAe),Mke=tt([mke,Wy],SAe),Nke=tt([Ui,hO,yke,vke,_ke,wke,Ske,Un,lZ,TJ,Mke,Wy,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 y3(){return y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y3.apply(null,arguments)}function 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 CJ=w.createContext(void 0),Cke=t=>{var e=w.useContext(CJ);if(e!=null)return e.stackId;if(t!=null)return JX(t)},kke=(t,e)=>"recharts-bar-stack-clip-path-".concat(t,"-").concat(e),jke=t=>{var e=w.useContext(CJ);if(e!=null){var{stackId:n}=e;return"url(#".concat(kke(n,t),")")}},kJ=t=>{var{index:e}=t,n=Ake(t,Eke),r=jke(e);return w.createElement(qr,y3({className:"recharts-bar-stack-layer",clipPath:r},n))},Pke=["onMouseEnter","onMouseLeave","onClick"],Rke=["value","background","tooltipPosition"],Dke=["id"],Oke=["onMouseEnter","onClick","onMouseLeave"];function vu(){return vu=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},vu.apply(null,arguments)}function GH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GH(Object(n),!0).forEach(function(r){Lke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 LS(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:fh(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:hh,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:fh(a,e),hide:o,type:c,color:i,unit:l,graphicalItemId:u}};return w.createElement(iE,{tooltipEntrySettings:d})});function $ke(t){var e=Vt(eh),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=LS(a,Pke),d=I4(o,r,a.id),f=F4(l),m=U4(c,r,a.id);if(!i||n==null)return null;var p=Gf(i);return w.createElement($a,{zIndex:NAe(i,li.barBackground)},n.map((b,y)=>{var{value:x,background:v,tooltipPosition:S}=b,M=LS(b,Rke);if(!v)return null;var A=d(b,y),T=f(b,y),k=m(b,y),E=Xa(Xa(Xa(Xa(Xa({option:i,isActive:String(y)===e},M),{},{fill:"#eee"},v),p),My(u,b,y)),{},{onMouseEnter:A,onMouseLeave:T,onClick:k,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return w.createElement(OS,vu({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 Xa(Xa({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return w.createElement(j4,{value:e?i:void 0},n)}function Vke(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Vt(eh),c=Vt(N4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?w.createElement($a,{zIndex:li.activeBar},w.createElement(kJ,{index:a},w.createElement(OS,vu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o})))):w.createElement(OS,vu({},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(OS,vu({},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=ns(r))!==null&&e!==void 0?e:{},{id:a}=i,o=LS(i,Dke),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:m}=r,p=LS(r,Oke),b=I4(d,c,a),y=F4(m),x=U4(f,c,a);return n?w.createElement(w.Fragment,null,n.map((v,S)=>w.createElement(kJ,vu({index:S,key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(S),className:"recharts-bar-rectangle"},My(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=Jg(e,"recharts-bar-"),[p,b]=w.useState(!1),y=!p,x=w.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),v=w.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return w.createElement(Hke,{showLabels:y,rects:r},w.createElement(Qg,{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 Xa(Xa({},A),{},{x:Jn(k.x,A.x,S),y:Jn(k.y,A.y,S),width:Jn(k.width,A.width,S),height:Jn(k.height,A.height,S)});if(i==="horizontal"){var E=Jn(0,A.height,S),D=Jn(A.stackedBarStart,A.y,S);return Xa(Xa({},A),{},{y:D,height:E})}var C=Jn(0,A.width,S),R=Jn(A.stackedBarStart,A.x,S);return Xa(Xa({},A),{},{width:C,x:R})});return S>0&&(n.current=M??null),M==null?null:w.createElement(qr,null,w.createElement(Wke,{props:e,data:M}))}),w.createElement(tE,{label:e.label}),e.children)}function Kke(t){var e=w.useRef(null);return w.createElement(qke,{previousRectanglesRef:e,props:t})}var jJ=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:tr(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=Bn("recharts-bar",i),f=u;return w.createElement(qr,{className:d,id:u},l&&w.createElement("defs",null,w.createElement(V4,{clipPathId:f,xAxisId:a,yAxisId:o})),w.createElement(qr,{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:jJ,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}=lE(e,n),m=mh(),p=zi(),b=D4(t.children,Vy),y=Vt(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(uJ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:Xke,errorBarOffset:x},w.createElement(Yke,vu({},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,D,C,R,U;if(d){var O=d[T+y];if(O==null)return null;k=jbe(O,v)}else k=tr(A,n),Array.isArray(k)||(k=[S,k]);var q=lke(r,jJ)(k[1],T);if(e==="horizontal"){var j,W=l.scale.map(k[0]),K=l.scale.map(k[1]);if(W==null||K==null)return null;E=w8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:A,index:T}),D=(j=K??W)!==null&&j!==void 0?j:void 0,C=i.size;var G=W-K;if(R=ul(G)?0:G,U={x:E,y:m.top,width:C,height:m.height},Math.abs(q)>0&&Math.abs(R)<Math.abs(q)){var Q=Ji(R||q)*(Math.abs(q)-Math.abs(R));D-=Q,R+=Q}}else{var te=o.scale.map(k[0]),J=o.scale.map(k[1]);if(te==null||J==null)return null;if(E=te,D=w8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:T}),C=J-te,R=i.size,U={x:m.left,y:D,width:m.width,height:R},Math.abs(q)>0&&Math.abs(C)<Math.abs(q)){var z=Ji(C||q)*(Math.abs(q)-Math.abs(C));C+=z}}if(E==null||D==null||C==null||R==null)return null;var V=Xa(Xa({},A),{},{stackedBarStart:M,x:E,y:D,width:C,height:R,value:d?k:k[1],payload:A,background:U,tooltipPosition:{x:E+C/2,y:D+R/2},parentViewBox:b},p&&p[T]&&p[T].props);return V}).filter(Boolean)}function eje(t){var e=Kr(t,Zke),n=Cke(e.stackId),r=zi();return w.createElement(aE,{id:e.id,type:"bar"},i=>w.createElement(w.Fragment,null,w.createElement(z4,{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(B4,{type:"bar",id:i,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:n,hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:r}),w.createElement($a,{zIndex:e.zIndex},w.createElement(Qke,vu({},e,{id:i})))))}var PJ=w.memo(eje,Gy);PJ.displayName="Bar";var tje=["domain","range"],nje=["domain","range"];function WH(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 qH(t,e){return t===e?!0:Array.isArray(t)&&t.length===2&&Array.isArray(e)&&e.length===2?t[0]===e[0]&&t[1]===e[1]:!1}function RJ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=WH(t,tje),{domain:a,range:o}=e,l=WH(e,nje);return!qH(n,a)||!qH(r,o)?!1:Gy(i,l)}var ije=["type"],aje=["dangerouslySetInnerHTML","ticks","scale"],sje=["id","scale"];function v3(){return v3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},v3.apply(null,arguments)}function KH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KH(Object(n),!0).forEach(function(r){oje(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 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 _3(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=Mr(),n=w.useRef(null),r=xO(),{type:i}=t,a=_3(t,ije),o=HN(r,"xAxis",i),l=w.useMemo(()=>{if(o!=null)return XH(XH({},a),{},{type:o})},[a,o]);return w.useLayoutEffect(()=>{l!=null&&(n.current===null?e(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=Vt(hO),i=zi(),a="xAxis",o=Vt(v=>eQ(v,a,e,i)),l=Vt(v=>YZ(v,e)),c=Vt(v=>Y1e(v,e)),u=Vt(v=>jZ(v,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:d,ticks:f,scale:m}=t,p=_3(t,aje),{id:b,scale:y}=u,x=_3(u,sje);return w.createElement(H4,v3({},p,x,{x:c.x,y:c.y,width:l.width,height:l.height,className:Bn("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:o,axisType:a}))},fje={allowDataOverflow:Ki.allowDataOverflow,allowDecimals:Ki.allowDecimals,allowDuplicatedCategory:Ki.allowDuplicatedCategory,angle:Ki.angle,axisLine:su.axisLine,height:Ki.height,hide:!1,includeHidden:Ki.includeHidden,interval:Ki.interval,label:!1,minTickGap:Ki.minTickGap,mirror:Ki.mirror,orientation:Ki.orientation,padding:Ki.padding,reversed:Ki.reversed,scale:Ki.scale,tick:Ki.tick,tickCount:Ki.tickCount,tickLine:su.tickLine,tickSize:su.tickSize,type:Ki.type,xAxisId:0},mje=t=>{var e=Kr(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))},IS=w.memo(mje,RJ);IS.displayName="XAxis";var pje=["type"],gje=["dangerouslySetInnerHTML","ticks","scale"],xje=["id","scale"];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 YH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ZH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YH(Object(n),!0).forEach(function(r){bje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 S3(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=Mr(),n=w.useRef(null),r=xO(),{type:i}=t,a=S3(t,pje),o=HN(r,"yAxis",i),l=w.useMemo(()=>{if(o!=null)return ZH(ZH({},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=Vt(hO),c=zi(),u=Mr(),d="yAxis",f=Vt(k=>ZZ(k,e)),m=Vt(k=>Q1e(k,e)),p=Vt(k=>eQ(k,d,e,c)),b=Vt(k=>PZ(k,e));if(w.useLayoutEffect(()=>{if(!(r!=="auto"||!f||k4(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=S3(t,gje),{id:M,scale:A}=b,T=S3(b,xje);return w.createElement(H4,w3({},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:Bn("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:p,axisType:d}))}var Mje={allowDataOverflow:Xi.allowDataOverflow,allowDecimals:Xi.allowDecimals,allowDuplicatedCategory:Xi.allowDuplicatedCategory,angle:Xi.angle,axisLine:su.axisLine,hide:!1,includeHidden:Xi.includeHidden,interval:Xi.interval,label:!1,minTickGap:Xi.minTickGap,mirror:Xi.mirror,orientation:Xi.orientation,padding:Xi.padding,reversed:Xi.reversed,scale:Xi.scale,tick:Xi.tick,tickCount:Xi.tickCount,tickLine:su.tickLine,tickSize:su.tickSize,type:Xi.type,width:Xi.width,yAxisId:0},Nje=t=>{var e=Kr(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))},FS=w.memo(Nje,RJ);FS.displayName="YAxis";var Eje=(t,e)=>e,W4=tt([Eje,Un,TZ,la,xQ,Cu,fMe,Ui],vMe),q4=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)}},DJ=Fo("mouseClick"),OJ=Ey();OJ.startListening({actionCreator:DJ,effect:(t,e)=>{var n=t.payload,r=W4(e.getState(),q4(n));r?.activeIndex!=null&&e.dispatch(hSe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var M3=Fo("mouseMove"),LJ=Ey(),D_=null;LJ.startListening({actionCreator:M3,effect:(t,e)=>{var n=t.payload;D_!==null&&cancelAnimationFrame(D_);var r=q4(n);D_=requestAnimationFrame(()=>{var i=e.getState(),a=y4(i,i.tooltip.settings.shared);if(a==="axis"){var o=W4(i,r);o?.activeIndex!=null?e.dispatch(lQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(oQ())}D_=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 QH={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},IJ=Es({name:"rootProps",initialState:QH,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:QH.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=IJ.reducer,{updateOptions:Cje}=IJ.actions,kje=null,jje={updatePolarOptions:(t,e)=>e.payload},FJ=Es({name:"polarOptions",initialState:kje,reducers:jje}),{updatePolarOptions:Pje}=FJ.actions,Rje=FJ.reducer,UJ=Fo("keyDown"),zJ=Fo("focus"),K4=Ey();K4.startListening({actionCreator:UJ,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=v4(i,lx(n),zy(n),$y(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Cu(n);if(a==="Enter"){var u=ES(n,"axis","hover",String(i.index));e.dispatch(h3({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=ES(n,"axis","hover",String(p));e.dispatch(h3({active:!0,activeIndex:p.toString(),activeCoordinate:b}))}}}}}});K4.startListening({actionCreator:zJ,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=ES(n,"axis","hover",String(a));e.dispatch(h3({active:!0,activeIndex:a,activeCoordinate:o}))}}}});var go=Fo("externalEvent"),BJ=Ey(),zC=new Map;BJ.startListening({actionCreator:go,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=zC.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:QSe(l),activeDataKey:N4(l),activeIndex:eh(l),activeLabel:vQ(l),activeTooltipIndex:eh(l),isTooltipActive:JSe(l)};n(c,r)}finally{zC.delete(i)}});zC.set(i,o)}}});var Dje=tt([sx],t=>t.tooltipItemPayloads),Oje=tt([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)}}}),$J=Fo("touchMove"),HJ=Ey();HJ.startListening({actionCreator:$J,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=y4(r,r.tooltip.settings.shared);if(i==="axis"){var a=n.touches[0];if(a==null)return;var o=W4(r,q4({clientX:a.clientX,clientY:a.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&e.dispatch(lQ({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(tY),f=(l=u.getAttribute(nY))!==null&&l!==void 0?l:void 0,m=ox(r).find(y=>y.id===f);if(d==null||m==null||f==null)return;var{dataKey:p}=m,b=Oje(r,d,f);e.dispatch(sQ({activeDataKey:p,activeIndex:d,activeCoordinate:b,activeGraphicalItemId:f}))}}}});var Lje=wX({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([OJ.middleware,LJ.middleware,K4.middleware,BJ.middleware,HJ.middleware])},enhancers:r=>{var i=r;return typeof r=="function"&&(i=r()),i.concat(IX({type:"raf"}))},devTools:{serialize:{replacer:Aje},name:"recharts-".concat(n)}})};function VJ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=zi(),a=w.useRef(null);if(i)return n;a.current==null&&(a.current=Ije(e,r));var o=aO;return w.createElement(uCe,{context:o,store:a.current},n)}function Fje(t){var{layout:e,margin:n}=t,r=Mr(),i=zi();return w.useEffect(()=>{i||(r(Sbe(e)),r(wbe(n)))},[r,i,e,n]),null}var GJ=w.memo(Fje,Gy);function WJ(t){var e=Mr();return w.useEffect(()=>{e(Cje(t))},[e,t]),null}function JH(t){var{zIndex:e,isPanorama:n}=t,r=w.useRef(null),i=Mr();return w.useLayoutEffect(()=>(r.current&&i(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 eV(t){var{children:e,isPanorama:n}=t,r=Vt(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(JH,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>w.createElement(JH,{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 US(){return US=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},US.apply(null,arguments)}var $je={width:"100%",height:"100%",display:"block"},Hje=w.forwardRef((t,e)=>{var n=pO(),r=gO(),i=bY();if(!Jl(n)||!Jl(r))return null;var{children:a,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),w.createElement(KD,US({},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=Vt(jN);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return w.createElement(KD,{width:r,height:i,x:o,y:a},e)},tV=w.forwardRef((t,e)=>{var{children:n}=t,r=zje(t,Uje),i=zi();return i?w.createElement(Vje,null,w.createElement(eV,{isPanorama:!0},n)):w.createElement(Hje,US({ref:e},r),w.createElement(eV,{isPanorama:!1},n))});function Gje(){var t=Mr(),[e,n]=w.useState(null),r=Vt($be);return w.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;mn(a)&&a!==r&&t(Nbe(a))}},[e,t,r]),n}function nV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wje(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nV(Object(n),!0).forEach(function(r){qje(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 $d(){return $d=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},$d.apply(null,arguments)}var Yje=()=>(sNe(),null);function zS(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:zS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:zS((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(Cy,{width:a.containerWidth,height:a.containerHeight}),w.createElement("div",$d({ref:c},t)))}),Qje=w.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=w.useState({containerWidth:zS(n),containerHeight:zS(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(Cy,{width:i.containerWidth,height:i.containerHeight}),w.createElement("div",$d({ref:l},t)))}),Jje=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return w.createElement(w.Fragment,null,w.createElement(Cy,{width:n,height:r}),w.createElement("div",$d({ref:e},t)))}),ePe=w.forwardRef((t,e)=>{var{width:n,height:r}=t;return typeof n=="string"||typeof r=="string"?w.createElement(Qje,$d({},t,{ref:e})):typeof n=="number"&&typeof r=="number"?w.createElement(Jje,$d({},t,{width:n,height:r,ref:e})):w.createElement(w.Fragment,null,w.createElement(Cy,{width:n,height:r}),w.createElement("div",$d({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=Mr(),[k,E]=w.useState(null),[D,C]=w.useState(null),R=Gje(),U=fO(),O=U?.width>0?U.width:v,q=U?.height>0?U.height:i,j=w.useCallback(xe=>{R(xe),typeof e=="function"&&e(xe),E(xe),C(xe),xe!=null&&(A.current=xe)},[R,e,E,C]),W=w.useCallback(xe=>{T(DJ(xe)),T(go({handler:a,reactEvent:xe}))},[T,a]),K=w.useCallback(xe=>{T(M3(xe)),T(go({handler:u,reactEvent:xe}))},[T,u]),G=w.useCallback(xe=>{T(oQ()),T(go({handler:d,reactEvent:xe}))},[T,d]),Q=w.useCallback(xe=>{T(M3(xe)),T(go({handler:f,reactEvent:xe}))},[T,f]),te=w.useCallback(()=>{T(zJ())},[T]),J=w.useCallback(xe=>{T(UJ(xe.key))},[T]),z=w.useCallback(xe=>{T(go({handler:o,reactEvent:xe}))},[T,o]),V=w.useCallback(xe=>{T(go({handler:l,reactEvent:xe}))},[T,l]),ne=w.useCallback(xe=>{T(go({handler:c,reactEvent:xe}))},[T,c]),ae=w.useCallback(xe=>{T(go({handler:m,reactEvent:xe}))},[T,m]),he=w.useCallback(xe=>{T(go({handler:y,reactEvent:xe}))},[T,y]),pe=w.useCallback(xe=>{M&&T($J(xe)),T(go({handler:b,reactEvent:xe}))},[T,M,b]),ie=w.useCallback(xe=>{T(go({handler:p,reactEvent:xe}))},[T,p]),Ee=tPe(S);return w.createElement(TQ.Provider,{value:k},w.createElement(FK.Provider,{value:D},w.createElement(Ee,{width:O??x?.width,height:q??x?.height,className:Bn("recharts-wrapper",r),style:Wje({position:"relative",cursor:"default",width:O,height:q},x),onClick:W,onContextMenu:z,onDoubleClick:V,onFocus:te,onKeyDown:J,onMouseDown:ne,onMouseEnter:K,onMouseLeave:G,onMouseMove:Q,onMouseUp:ae,onTouchEnd:ie,onTouchMove:pe,onTouchStart:he,ref:j},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 qJ=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=ns(f);return c?w.createElement(w.Fragment,null,w.createElement(Cy,{width:n,height:r}),w.createElement(tV,{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(tV,{otherAttributes:m,title:u,desc:d,ref:e},w.createElement(OAe,null,a)))});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)}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"},X4=w.forwardRef(function(e,n){var r,i=Kr(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(VJ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},w.createElement(rJ,{chartData:u.data}),w.createElement(GJ,{layout:i.layout,margin:i.margin}),w.createElement(WJ,{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(qJ,N3({},i,{ref:n})))}),lPe=["axis"],cPe=w.forwardRef((t,e)=>w.createElement(X4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:lPe,tooltipPayloadSearcher:JN,categoricalChartProps:t,ref:e})),uPe=["axis","item"],dPe=w.forwardRef((t,e)=>w.createElement(X4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:uPe,tooltipPayloadSearcher:JN,categoricalChartProps:t,ref:e}));function hPe(t){var e=Mr();return w.useEffect(()=>{e(Pje(t))},[e,t]),null}var fPe=["layout"];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 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},KJ={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=Kr(e.categoricalChartProps,KJ),{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(VJ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},w.createElement(rJ,{chartData:i.data}),w.createElement(GJ,{layout:a,margin:i.margin}),w.createElement(WJ,{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(qJ,E3({},o,{ref:n})))});function rV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function iV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rV(Object(n),!0).forEach(function(r){bPe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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=iV(iV({},KJ),{},{layout:"centric",startAngle:0,endAngle:360}),SPe=w.forwardRef((t,e)=>{var n=Kr(t,wPe);return w.createElement(xPe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:_Pe,tooltipPayloadSearcher:JN,categoricalChartProps:n,ref:e})}),MPe=["axis"],NPe=w.forwardRef((t,e)=>w.createElement(X4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:MPe,tooltipPayloadSearcher:JN,categoricalChartProps:t,ref:e}));const aV=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function EPe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Wg(),{mode:u}=uh(),[d,f]=w.useState("24h"),[m,p]=w.useState(o),b=u==="dark",{data:y}=ut({queryKey:["settings"],queryFn:fe.getSettings}),x=y?.time_format||"system";w.useEffect(()=>{if(!t)return;const ae=he=>{he.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[t,e]);const v=aV.find(ae=>ae.value===d)?.hours||24,{data:S,isLoading:M,error:A}=ut({queryKey:["ams-history",n,i,v],queryFn:()=>fe.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const T=S?.data.map(ae=>{const he=Mi(ae.recorded_at)||new Date,pe={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:he.getTime(),humidity:ae.humidity,temperature:ae.temperature,timeLabel:he.toLocaleTimeString([],n0(pe,x))}})||[],k=l?.humidityGood||40,E=l?.humidityFair||60,D=l?.tempGood||30,C=l?.tempFair||35,R=T[T.length-1],U=R?.humidity,O=R?.temperature,q=ae=>{const he=ae.filter(_e=>_e!=null);if(he.length<4)return"stable";const pe=he.slice(0,Math.floor(he.length/4)),ie=he.slice(-Math.floor(he.length/4)),Ee=pe.reduce((_e,le)=>_e+le,0)/pe.length,Ne=ie.reduce((_e,le)=>_e+le,0)/ie.length-Ee;return Math.abs(Ne)<2?"stable":Ne>0?"up":"down"},j=q(T.map(ae=>ae.humidity)),W=q(T.map(ae=>ae.temperature)),K=({trend:ae})=>ae==="up"?s.jsx(AK,{className:"w-4 h-4 text-red-400"}):ae==="down"?s.jsx(EK,{className:"w-4 h-4 text-green-400"}):s.jsx(vP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),G=ae=>ae==null?"#9ca3af":ae<=k?"#22a352":ae<=E?"#d4a017":"#c62828",Q=ae=>ae==null?"#9ca3af":ae<=D?"#22a352":ae<=C?"#d4a017":"#c62828",te=b?"#2d2d2d":"#ffffff",J=b?"#1d1d1d":"#f3f4f6",z=b?"#3d3d3d":"#e5e7eb",V=b?"#ffffff":"#111827",ne=b?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:te},onClick: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:V},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ne},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ne},children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor: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(UD,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m==="temperature"?"bg-orange-600 text-white":""}`,style:m!=="temperature"?{color:ne}:void 0,children:[s.jsx(fN,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:J},children:aV.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:G(U)},children:U!=null?`${U}%`:"—"}),s.jsx(K,{trend:j})]})]}),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:V},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(O)},children:O!=null?`${O}°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:V},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(s1,{width:"100%",height:300,children:s.jsxs(cPe,{data:T,children:[s.jsx(RS,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),s.jsx(IS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ae=>{const he=new Date(ae);return v>24?he.toLocaleDateString([],{day:"numeric",month:"short"}):he.toLocaleTimeString([],n0({hour:"2-digit",minute:"2-digit"},x))},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(FS,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:m==="humidity"?[0,100]:["auto","auto"],tickFormatter:ae=>m==="humidity"?`${ae}%`:`${ae}°C`}),s.jsx(l1,{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,n0({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(vO,{}),m==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(Bb,{y:k,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Bb,{y:E,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(Bb,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(Bb,{y:C,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(bJ,{type:"monotone",dataKey:m,name:m==="humidity"?"Humidity":"Temperature",stroke:m==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:ne},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function BC({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const[o,l]=w.useState(!1),[c,u]=w.useState("top"),[d,f]=w.useState(!1),m=w.useRef(null),p=w.useRef(null),b=w.useRef(null),y=()=>{const k=t.trayUuid;k&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(k).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{x(k)}):x(k))},x=k=>{const 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,D=k.top,C=window.innerHeight-k.bottom;D<E+12&&C>D?u("bottom"):u("top")}},[o]);const v=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!0),80))},S=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!1),100)};w.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const M=k=>k<=15?"#ef4444":k<=30?"#f97316":k<=50?"#eab308":"#22c55e",A=k=>{if(!k)return!1;const E=k.replace("#",""),D=parseInt(E.slice(0,2),16),C=parseInt(E.slice(2,4),16),R=parseInt(E.slice(4,6),16);return(.299*D+.587*C+.114*R)/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(UD,{className:"w-3 h-3"}),"Fill"]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:M(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),s.jsxs("button",{onClick:k=>{k.stopPropagation(),y()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),d?s.jsx(ts,{className:"w-3 h-3 text-bambu-green"}):s.jsx(ol,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:k=>{k.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[s.jsx(Gl,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]}),a?.enabled&&s.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("button",{onClick:k=>{k.stopPropagation(),a.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Zd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function sV({children:t,className:e="",configureSlot:n}){const[r,i]=w.useState(!1),a=w.useRef(null),o=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!0),80)},l=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),100)};return w.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&s.jsxs("div",{className:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[s.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"Empty slot"}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.jsxs("button",{onClick:c=>{c.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Zd,{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:fe.getUnlinkedSpools,enabled:t}),u=mt({mutationFn:f=>fe.linkSpool(f,n),onSuccess:()=>{i.invalidateQueries({queryKey:["unlinked-spools"]}),i.invalidateQueries({queryKey:["spoolman-status"]}),e()}});if(!t)return null;const d=()=>{a&&u.mutate(a)};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[r&&s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),s.jsx("span",{className:"text-white font-medium",children:r.type}),s.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(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(ts,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx("p",{children:"No unlinked spools found in Spoolman."}),s.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Gl,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.isError&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:u.error.message})]})]})}function 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 oV(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const CPe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function lV(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of 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 $C(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:()=>fe.getCloudSettings(),enabled:t}),{data:k,isLoading:E}=ut({queryKey:["kprofiles",n,i],queryFn:()=>fe.getKProfiles(n,i),enabled:t&&!!n}),D=mt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Q=A?.filament.find(xe=>xe.setting_id===o);if(!Q)throw new Error("Selected preset not found");const te=lV(Q.name),J=c?.slot_id??-1,z=d||r.trayColor?.slice(0,6)||"FFFFFF",V=Q.name.replace(/@.+$/,"").trim();let ne=oV(o);if(!o.startsWith("GFS"))try{const xe=await fe.getCloudSettingDetail(o);xe.filament_id?ne=xe.filament_id:xe.base_id&&(ne=oV(xe.base_id),console.log(`Derived tray_info_idx from base_id: ${xe.base_id} -> ${ne}`))}catch(xe){console.warn("Failed to fetch preset detail for filament_id:",xe)}let ae=190,he=230;const pe=te.material.toUpperCase();pe.includes("PLA")?(ae=190,he=230):pe.includes("PETG")?(ae=220,he=260):pe.includes("ABS")||pe.includes("ASA")?(ae=240,he=280):pe.includes("TPU")?(ae=200,he=240):pe.includes("PC")?(ae=260,he=300):(pe.includes("PA")||pe.includes("NYLON"))&&(ae=250,he=290);const ie=c?.k_value?parseFloat(c.k_value):0,Ee=await fe.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:te.material||"PLA",tray_sub_brands:V,tray_color:z+"FF",nozzle_temp_min:ae,nozzle_temp_max:he,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 fe.saveSlotPreset(n,r.amsId,r.trayId,o,V)}catch(xe){console.warn("Failed to save slot preset mapping:",xe)}return Ee},onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),C=mt({mutationFn:async()=>fe.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{v(!0),a?.(),setTimeout(()=>{v(!1),e()},1500)}}),R=w.useMemo(()=>{if(!A?.filament)return[];const Q=b.toLowerCase();return A.filament.filter(te=>Q?te.name.toLowerCase().includes(Q):!0).sort((te,J)=>{const z=$C(te.setting_id),V=$C(J.setting_id);return z&&!V?-1:!z&&V?1:te.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 te=Q.name.replace(/@.+$/,"").trim();te.startsWith("# ")&&(te=te.slice(2).trim());const J=lV(te);return{fullName:te,material:J.material,brand:J.brand}},[o,A?.filament]),O=U?.fullName||"",q=w.useMemo(()=>{if(!k?.profiles||!U)return[];const{fullName:Q,material:te,brand:J}=U,z=Q.toUpperCase(),V=te.toUpperCase(),ne=J.toUpperCase();if(!V||V.length<2)return[];const ae=k.profiles.filter(pe=>{const ie=pe.name.toUpperCase();if(ne)return!(!ie.includes(ne)||!ie.includes(V));if(ie.includes(z)||ie.includes(V))return!0;const xe={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[V]||[];for(const Ne of xe)if(ie.includes(Ne))return!0;return!1}),he=new Map;for(const pe of ae){const ie=`${pe.name}|${pe.k_value}`,Ee=he.get(ie);Ee?pe.extruder_id===1&&Ee.extruder_id===0&&he.set(ie,pe):he.set(ie,pe)}return Array.from(he.values())},[k?.profiles,U]);w.useEffect(()=>{if(t&&A?.filament){if(r.trayInfoIdx){const Q=A.filament.find(te=>te.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 j=w.useCallback(Q=>{Q.key==="Escape"&&e()},[e]);if(w.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const W=T||E,K=o&&!D.isPending,G=d||r.trayColor?.slice(0,6)||"FFFFFF";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zd,{className:"w-5 h-5 text-bambu-blue"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[x&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx(tN,{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:R.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."}):R.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}),$C(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)",O&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",O]})]}),q.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Q=>{const te=q.find(J=>J.name===Q.target.value);u(te||null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10",children:[s.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),q.map(Q=>s.jsxs("option",{value:Q.name,children:[Q.name," (K=",Q.k_value,")"]},`${Q.name}-${Q.extruder_id}`))]}),s.jsx(Di,{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:`#${G}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:m,onChange:Q=>{const te=Q.target.value;p(te);const J=RPe(te);if(J)f(J);else{const z=te.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();z.length===6?f(z):z.length===3&&f(z.split("").map(V=>V+V).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&s.jsx("button",{onClick:()=>{f(""),p("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),s.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:()=>C.mutate(),disabled:C.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:C.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(dm,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:()=>D.mutate(),disabled:!K,children:D.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Zd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||C.isError)&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:D.error?.message||C.error?.message})]})]})}function 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 cV=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),uV={"A00-W1":"Jade White","A00-P0":"Beige","A00-D2":"Light Gray","A00-Y0":"Yellow","A00-Y2":"Sunflower Yellow","A00-A1":"Pumpkin Orange","A00-A0":"Orange","A00-Y4":"Gold","A00-G3":"Bright Green","A00-G1":"Bambu Green","A00-G2":"Mistletoe Green","A00-R3":"Hot Pink","A00-P6":"Magenta","A00-R0":"Red","A00-R2":"Maroon Red","A00-P5":"Purple","A00-P2":"Indigo Purple","A00-B5":"Turquoise","A00-B8":"Cyan","A00-B3":"Cobalt Blue","A00-N0":"Brown","A00-N1":"Cocoa Brown","A00-Y3":"Bronze","A00-D0":"Gray","A00-D1":"Silver","A00-B1":"Blue Grey","A00-D3":"Dark Gray","A00-K0":"Black","A00-M3":"Pink Citrus","A00-M6":"Dusk Glare","A00-M0":"Arctic Whisper","A00-M1":"Solar Breeze","A00-M5":"Blueberry Bubblegum","A00-M4":"Mint Lime","A00-M2":"Ocean to Meadow","A00-M7":"Cotton Candy Cloud","A18-K0":"Black","A18-D0":"Gray","A18-W0":"White","A18-R0":"Red","A18-Y0":"Yellow","A18-B0":"Cyan","A18-B1":"Blue","A18-P0":"Matte Beige","A01-W2":"Ivory White","A01-W3":"Bone White","A01-Y2":"Lemon Yellow","A01-A2":"Mandarin Orange","A01-P3":"Sakura Pink","A01-P4":"Lilac Purple","A01-R3":"Plum","A01-R1":"Scarlet Red","A01-R4":"Dark Red","A01-G0":"Apple Green","A01-G1":"Grass Green","A01-G7":"Dark Green","A01-B4":"Ice Blue","A01-B0":"Sky Blue","A01-B3":"Marine Blue","A01-B6":"Dark Blue","A01-Y3":"Desert Tan","A01-N1":"Latte Brown","A01-N3":"Caramel","A01-R2":"Terracotta","A01-N2":"Dark Brown","A01-N0":"Dark Chocolate","A01-D3":"Ash Gray","A01-D0":"Nardo Gray","A01-K1":"Charcoal","A12-G0":"Green","A12-R0":"Pink","A12-A0":"Orange","A12-Y0":"Yellow","A12-B0":"Blue","A07-R5":"Red Granite","A07-D4":"White Marble","A11-W0":"White","A11-K0":"Black","A08-G3":"Alpine Green Sparkle","A08-D5":"Slate Gray Sparkle","A08-B7":"Royal Purple Sparkle","A08-R2":"Crimson Red Sparkle","A08-K2":"Onyx Black Sparkle","A08-Y1":"Classic Gold Sparkle","A02-B2":"Cobalt Blue Metallic","A02-G2":"Oxide Green Metallic","A02-Y1":"Iridium Gold Metallic","A02-D2":"Iron Gray Metallic","A17-B1":"Blue","A17-A0":"Orange","A17-P0":"Purple","A06-Y1":"Gold","A06-D0":"Titan Gray","A06-D1":"Silver","A06-W0":"White","A06-R0":"Candy Red","A06-G0":"Candy Green","A06-G1":"Mint","A06-B1":"Blue","A06-B0":"Baby Blue","A06-P0":"Purple","A06-R1":"Rose Gold","A06-R2":"Pink","A06-Y0":"Champagne","A05-M8":"Dawn Radiance","A05-M4":"Aurora Purple","A05-M1":"South Beach","A05-T3":"Neon City","A05-T2":"Midnight Blaze","A05-T1":"Gilded Rose","A05-T4":"Blue Hawaii","A05-T5":"Velvet Eclipse","A15-B0":"Purple","A15-G0":"Green","A15-G1":"Nebulae","A15-R0":"Brown","A16-K0":"Black Walnut","A16-R0":"Rosewood","A16-N0":"Clay Brown","A16-G0":"Classic Birch","A16-W0":"White Oak","A16-Y0":"Ochre Yellow","A50-D6":"Lava Gray","A50-K0":"Black","A50-B6":"Royal Blue","A10-W0":"White","A10-D0":"Gray","A09-B5":"Lavender Blue","A09-B4":"Light Blue","A09-A0":"Orange","A09-D1":"Silver","A09-R3":"Vermilion Red","A09-Y0":"Yellow","G02-K0":"Black","G02-W0":"White","G02-R0":"Red","G02-D0":"Gray","G02-D1":"Dark Gray","G02-Y1":"Cream","G02-Y0":"Yellow","G02-A0":"Orange","G02-N1":"Peanut Brown","G02-G1":"Lime Green","G02-G0":"Green","G02-G2":"Forest Green","G02-B1":"Lake Blue","G02-B0":"Blue","G01-G1":"Translucent Teal","G01-B0":"Translucent Light Blue","G01-C0":"Clear","G01-D0":"Translucent Gray","G01-G0":"Translucent Olive","G01-N0":"Translucent Brown","G01-A0":"Translucent Orange","G01-P1":"Translucent Pink","G01-P0":"Translucent Purple","G50-P7":"Violet Purple","G50-K0":"Black","B00-D1":"Silver","B00-K0":"Black","B00-W0":"White","B00-G6":"Bambu Green","B00-G7":"Olive","B00-Y1":"Tangerine Yellow","B00-A0":"Orange","B00-R0":"Red","B00-B4":"Azure","B00-B0":"Blue","B00-B6":"Navy Blue","B50-A0":"Orange","B50-K0":"Black","B01-W0":"White","B01-K0":"Black","B01-D0":"Gray","B02-W0":"White","C00-C1":"Transparent","C00-C0":"Clear Black","C00-K0":"Black","C00-W0":"White","C01-K0":"Black","U02-B0":"Blue","U02-D0":"Gray","U02-K0":"Black","N04-K0":"Black","N08-K0":"Black","S02-W0":"Nature","S02-W1":"White","S05-C0":"Black","S06-W0":"White","S03-G1":"Green","S04-Y0":"Clear"},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 HC(t){if(!t)return null;if(uV[t])return uV[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return LPe[n]||null}function VC(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,m=r/255;i===d?l=((f-m)/u+(f<m?6:0))/6:i===f?l=((m-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function GC(t){return(t??.02).toFixed(3)}function dV({side:t}){const{mode:e}=uh(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function hV({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function 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 WC({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function fV({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=hV:a<=l?d=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 mV({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=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 ed(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function pV(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function $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 qC(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function 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(Bs,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(Bs,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function 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 gV(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function xV({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system",cameraViewMode:u="window",onOpenEmbeddedCamera:d}){const f=on(),m=pl(),{showToast:p}=Gn(),[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),[D,C]=w.useState(!1),[R,U]=w.useState(!1),[O,q]=w.useState(!1),[j,W]=w.useState(!1),[K,G]=w.useState(!1),[Q,te]=w.useState(!1),[J,z]=w.useState(!1),[V,ne]=w.useState(!1),[ae,he]=w.useState(null),[pe,ie]=w.useState(null),[Ee,xe]=w.useState(null),[Ne,_e]=w.useState(!1),[le,Ve]=w.useState(null),[H,ee]=w.useState(!1),[X,B]=w.useState(!1),[I,ue]=w.useState(null),[Ae,Ie]=w.useState(!1),{data:ce}=ut({queryKey:["printerStatus",t.id],queryFn:()=>fe.getPrinterStatus(t.id),refetchInterval:3e4}),{data:$}=ut({queryKey:["firmwareUpdate",t.id],queryFn:()=>n1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),L=w.useMemo(()=>{const Le=new Set;if(ce?.ams)for(const pt of ce.ams)for(const me of pt.tray||[])me.tray_info_idx&&Le.add(me.tray_info_idx);return ce?.vt_tray?.tray_info_idx&&Le.add(ce.vt_tray.tray_info_idx),Array.from(Le)},[ce?.ams,ce?.vt_tray]),{data:Y}=ut({queryKey:["filamentInfo",L],queryFn:()=>fe.getFilamentInfo(L),enabled:L.length>0,staleTime:300*1e3}),{data:be}=ut({queryKey:["slotPresets",t.id],queryFn:()=>fe.getSlotPresets(t.id),staleTime:120*1e3}),[Se,se]=w.useState(null);w.useEffect(()=>{ce?.wifi_signal!=null&&se(ce.wifi_signal)},[ce?.wifi_signal]);const Pe=ce?.wifi_signal??Se,Re=w.useRef(void 0);w.useEffect(()=>{ce?.connected!==void 0&&(Re.current=ce.connected)},[ce?.connected]);const Xe=ce?.connected??Re.current,et=w.useRef({});w.useEffect(()=>{ce?.ams_extruder_map&&Object.keys(ce.ams_extruder_map).length>0&&(et.current=ce.ams_extruder_map)},[ce?.ams_extruder_map]);const Je=ce?.ams_extruder_map&&Object.keys(ce.ams_extruder_map).length>0?ce.ams_extruder_map:et.current,oe=w.useRef([]);w.useEffect(()=>{ce?.ams&&ce.ams.length>0&&(oe.current=ce.ams)},[ce?.ams]);const ye=ce?.ams&&ce.ams.length>0?ce.ams:oe.current,je=w.useRef(255),$e=ce?.tray_now;$e!==void 0&&$e!==255&&(je.current=$e);const ft=$e===void 0||$e===255?je.current:$e,{data:re}=ut({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>fe.getSmartPlugByPrinter(t.id)}),{data:ke}=ut({queryKey:["smartPlugStatus",re?.id],queryFn:()=>re?fe.getSmartPlugStatus(re.id):null,enabled:!!re,refetchInterval:1e4}),{data:ve}=ut({queryKey:["queue",t.id,"pending"],queryFn:()=>fe.getQueue(t.id,"pending")}),Fe=ve?.length||0,{data:Ue}=ut({queryKey:["archives",t.id,"last"],queryFn:()=>fe.getArchives(t.id,1,0),enabled:ce?.connected&&ce?.state!=="RUNNING"}),Te=Ue?.[0],qe=e&&Xe===!1,bt=mt({mutationFn:Le=>fe.deletePrinter(t.id,Le.deleteArchives),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),f.invalidateQueries({queryKey:["archives"]}),f.invalidateQueries({queryKey:["maintenanceOverview"]})}}),Pt=mt({mutationFn:()=>fe.connectPrinter(t.id),onSuccess:()=>{f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Ot=mt({mutationFn:Le=>re?fe.controlSmartPlug(re.id,Le):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugStatus",re?.id]})}}),ln=mt({mutationFn:Le=>re?fe.updateSmartPlug(re.id,{auto_off:Le}):Promise.reject("No plug"),onSuccess:()=>{f.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),f.invalidateQueries({queryKey:["smart-plugs"]})}}),Gt=mt({mutationFn:()=>fe.stopPrint(t.id),onSuccess:()=>{p("Print stopped"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Le=>p(Le.message||"Failed to stop print","error")}),vn=mt({mutationFn:()=>fe.pausePrint(t.id),onSuccess:()=>{p("Print paused"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Le=>p(Le.message||"Failed to pause print","error")}),gt=mt({mutationFn:()=>fe.resumePrint(t.id),onSuccess:()=>{p("Print resumed"),f.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:Le=>p(Le.message||"Failed to resume print","error")}),Kt=mt({mutationFn:Le=>fe.setChamberLight(t.id,Le),onMutate:async Le=>{await f.cancelQueries({queryKey:["printerStatus",t.id]});const pt=f.getQueryData(["printerStatus",t.id]);return f.setQueryData(["printerStatus",t.id],me=>({...me,chamber_light:Le})),{previousStatus:pt}},onSuccess:(Le,pt)=>{p(`Chamber light ${pt?"on":"off"}`)},onError:(Le,pt,me)=>{me?.previousStatus&&f.setQueryData(["printerStatus",t.id],me.previousStatus),p(Le.message||"Failed to control chamber light","error")}}),pn=mt({mutationFn:Le=>fe.updatePrinter(t.id,{plate_detection_enabled:Le}),onSuccess:()=>{f.invalidateQueries({queryKey:["printers"]}),p(pn.variables?"Plate check enabled":"Plate check disabled")},onError:Le=>p(Le.message||"Failed to update setting","error")}),Et=(ce?.state==="RUNNING"||ce?.state==="PAUSE"||ce?.state==="PAUSED")&&(ce?.printable_objects_count??0)>=2,{data:Ln,refetch:Nr}=ut({queryKey:["printableObjects",t.id],queryFn:()=>fe.getPrintableObjects(t.id),enabled:V||Et,refetchInterval:V?5e3:Et?3e4:!1}),Or=mt({mutationFn:Le=>fe.skipObjects(t.id,Le),onSuccess:Le=>{p(Le.message||"Objects skipped"),Nr()},onError:Le=>p(Le.message||"Failed to skip objects","error")}),[tn,yr]=w.useState(null),xi=w.useRef(!1),lr=w.useRef(null),we=w.useRef(!1),Ye=mt({mutationFn:({amsId:Le,slotId:pt})=>fe.refreshAmsSlot(t.id,Le,pt),onMutate:({amsId:Le,slotId:pt})=>{lr.current&&clearTimeout(lr.current),xi.current=!1,we.current=!1,yr({amsId:Le,slotId:pt}),setTimeout(()=>{we.current=!0},2e3),lr.current=setTimeout(()=>{yr(null)},3e4)},onSuccess:Le=>{p(Le.message||"RFID re-read initiated")},onError:Le=>{p(Le.message||"Failed to re-read RFID","error"),lr.current&&clearTimeout(lr.current),yr(null)}}),[at,ct]=w.useState(null),[st,Ct]=w.useState(null),Ft=async()=>{try{const Le=await fe.getPlateReferences(t.id);ct(Le)}catch{}},Yt=()=>{pn.mutate(!t.plate_detection_enabled)},Zt=async()=>{ee(!0),Ve(null);try{const Le=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});Ve(Le),Ft()}catch(Le){p(Le instanceof Error?Le.message:"Failed to check plate","error")}finally{ee(!1)}},de=async Le=>{B(!0);try{const pt=await fe.calibratePlateDetection(t.id,{label:Le});if(pt.success){p(pt.message||"Calibration saved!","success"),Ft();const me=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});Ve(me)}else p(pt.message||"Calibration failed","error")}catch(pt){p(pt instanceof Error?pt.message:"Calibration failed","error")}finally{B(!1)}},De=async(Le,pt)=>{try{await fe.updatePlateReferenceLabel(t.id,Le,pt),Ct(null),Ft()}catch(me){p(me instanceof Error?me.message:"Failed to update label","error")}},We=async Le=>{try{await fe.deletePlateReference(t.id,Le),p("Reference deleted","success"),Ft();const pt=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});Ve(pt)}catch(pt){p(pt instanceof Error?pt.message:"Failed to delete reference","error")}},Ze=async()=>{if(I){Ie(!0);try{await fe.updatePrinter(t.id,{plate_detection_roi:I}),p("Detection area saved","success"),ue(null);const Le=await fe.checkPlateEmpty(t.id,{includeDebugImage:!0});Ve(Le)}catch(Le){p(Le instanceof Error?Le.message:"Failed to save detection area","error")}finally{Ie(!1)}}};w.useEffect(()=>{const Le=pt=>{pt.key==="Escape"&&le&&Ve(null)};return window.addEventListener("keydown",Le),()=>window.removeEventListener("keydown",Le)},[le]);const Ge=w.useRef(null);w.useEffect(()=>{if(!tn)return;const Le=ce?.ams_status_main??0;return Le!==0&&(xi.current=!0,Ge.current&&(clearTimeout(Ge.current),Ge.current=null)),xi.current&&Le===0&&(we.current?(lr.current&&clearTimeout(lr.current),yr(null)):Ge.current||(Ge.current=setTimeout(()=>{lr.current&&clearTimeout(lr.current),yr(null)},2e3))),()=>{Ge.current&&clearTimeout(Ge.current)}},[ce?.ams_status_main,tn]);const[lt,kt]=w.useState(null);if(qe)return null;const wt=()=>{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"}},_t=()=>{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"}},Ut=()=>{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(Mt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:Ut(),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 ${wt()}`}),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 ${_t()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ce?.connected?"bg-status-ok":"bg-status-error"}`,title:ce?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ce?.nozzles&&ce.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ce.nozzles[0].nozzle_type||"Nozzle",children:["• ",ce.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(Xn,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>y(!b),children:s.jsx(Fd,{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(sa,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Pt.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(NK,{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(un,{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 ${ce?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[ce?.connected?s.jsx(Yg,{className:"w-3 h-3"}):s.jsx(HD,{className:"w-3 h-3"}),ce?.connected?"Connected":"Offline"]}),ce?.connected&&Pe!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Pe>=-50||Pe>=-60?"bg-status-ok/20 text-status-ok":Pe>=-70?"bg-status-warning/20 text-status-warning":Pe>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Pe} dBm - ${GPe(Pe).label}`,children:[s.jsx(Gfe,{className:"w-3 h-3"}),Pe,"dBm"]}),ce?.connected&&(()=>{const Le=ce.hms_errors?dpe(ce.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 ${Le.length>0?Le.some(pt=>pt.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(An,{className:"w-3 h-3"}),Le.length>0?Le.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(Qd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Fe>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:`${Fe} print${Fe>1?"s":""} in queue`,children:[s.jsx(cl,{className:"w-3 h-3"}),Fe]}),$?.update_available&&s.jsxs("button",{onClick:()=>_e(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:`Firmware update available: ${$.current_version} → ${$.latest_version}`,children:[s.jsx(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(Mt,{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(An,{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:Le=>M(Le.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:S?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:()=>{v(!1),M(!0)},children:"Cancel"}),s.jsx(Me,{variant:"danger",onClick:()=>{bt.mutate({deleteArchives:S}),v(!1),M(!0)},children:"Delete"})]})]})})}),ce?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:ce.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:`${ce.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(ce.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:gV(ce.state,ce.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:!(ce.state==="RUNNING"||ce.state==="PAUSE"||ce.state==="PAUSED")||(ce.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ce.state==="RUNNING"||ce.state==="PAUSE"||ce.state==="PAUSED")&&(ce.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:ce.state==="RUNNING"||ce.state==="PAUSE"||ce.state==="PAUSED"?(ce.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(cV,{className:"w-4 h-4"}),Ln&&Ln.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:Ln.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(WPe,{url:ce.state==="RUNNING"?ce.cover_url:null,printName:ce.state==="RUNNING"&&(ce.subtask_name||ce.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:ce.current_print&&ce.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ce.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ce.subtask_name||ce.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:`${ce.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(ce.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ce.remaining_time!=null&&ce.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Xn,{className:"w-3 h-3"}),$Pe(ce.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",HPe(ce.remaining_time,c)]})]}),ce.layer_num!=null&&ce.total_layers!=null&&ce.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(cl,{className:"w-3 h-3"}),ce.layer_num,"/",ce.total_layers]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("p",{className:"text-white text-sm mb-2",children:gV(ce.state,ce.stg_cur_name)}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),s.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Te?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Te.print_name||Te.filename,children:["Last: ",Te.print_name||Te.filename,Te.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",bg(Te.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),ce.state!=="RUNNING"&&s.jsx(ppe,{printerId:t.id})]}),ce.temperatures&&r==="expanded"&&(()=>{const Le=ce.temperatures.nozzle_heating||ce.temperatures.nozzle_2_heating||!1,pt=ce.temperatures.bed_heating||!1,me=ce.temperatures.chamber_heating||!1,He=t.nozzle_count===2||ce.temperatures.nozzle_2!==void 0,Lt=ce.active_extruder===1?"L":"R";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(WC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:Le}),ce.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(ce.temperatures.nozzle||0),"° / ",Math.round(ce.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(ce.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(WC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:pt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ce.temperatures.bed||0),"°C"]})]}),ce.temperatures.chamber!==void 0&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(WC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:me}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ce.temperatures.chamber||0),"°C"]})]}),He&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${Lt==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${Lt==="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 ${Lt==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const Le=ce.state==="RUNNING",pt=ce.state==="PAUSED"||ce.state==="PAUSE",me=Le||pt,He=Gt.isPending||vn.isPending||gt.isPending,Lt=ce.cooling_fan_speed,jt=ce.big_fan1_speed,Wt=ce.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 ${Lt&&Lt>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(mK,{className:`w-3.5 h-3.5 ${Lt&&Lt>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Lt&&Lt>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[Lt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${jt&&jt>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(TK,{className:`w-3.5 h-3.5 ${jt&&jt>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${jt&&jt>0?"text-blue-400":"text-bambu-gray/50"}`,children:[jt??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Wt&&Wt>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(Aue,{className:`w-3.5 h-3.5 ${Wt&&Wt>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Wt&&Wt>0?"text-green-400":"text-bambu-gray/50"}`,children:[Wt??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>G(!0),disabled:!me||He,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${me?"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(Lo,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>pt?z(!0):te(!0),disabled:!me||He,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${me?pt?"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:pt?"Resume print":"Pause print",children:[pt?s.jsx(Do,{className:"w-3 h-3"}):s.jsx(BD,{className:"w-3 h-3"}),pt?"Resume":"Pause"]})]})]})]})})(),ye&&ye.length>0&&r==="expanded"&&(()=>{const Le=ye.filter(He=>He.tray.length>1),pt=ye.filter(He=>He.tray.length===1),me=t.nozzle_count===2||ce?.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:[Le.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:Le.map(He=>{const Lt=Je[String(He.id)],jt=He.id>=128?He.id-128:He.id,Wt=Lt!==void 0?Lt:jt,Rt=Wt===1,Bt=Wt===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:ed(He.id,He.tray.length)}),me&&(Rt||Bt)&&s.jsx(dV,{side:Rt?"L":"R"})]}),(He.humidity!=null||He.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[He.humidity!=null&&s.jsx(fV,{humidity:He.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:He.id,amsLabel:ed(He.id,He.tray.length),mode:"humidity"}),compact:!0}),He.temp!=null&&s.jsx(mV,{temp:He.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:He.id,amsLabel:ed(He.id,He.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(At=>{const nn=He.tray[At]||He.tray.find(Cr=>Cr.id===At),Zr=nn?.tray_type&&nn.remain>=0,Lr=!nn?.tray_type,ca=He.id*4+At,$n=ft===ca,di=nn?.tray_info_idx?Y?.[nn.tray_info_idx]:null,vr=be?.[ca],Zn=nn?.tray_type?{vendor:qC(nn)?"Bambu Lab":"Generic",profile:di?.name||vr?.preset_name||nn.tray_sub_brands||nn.tray_type,colorName:HC(nn.tray_id_name)||VC(nn.tray_color),colorHex:nn.tray_color||null,kFactor:GC(nn.k),fillLevel:Zr?nn.remain:null,trayUuid:nn.tray_uuid||null}:null,Tr=tn?.amsId===He.id&&tn?.slotId===At,to=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Lr?"opacity-50":""} ${$n?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:nn?.tray_color?`#${nn.tray_color}`:nn?.tray_type?"#333":"transparent",borderColor:Lr?"#666":"rgba(255,255,255,0.1)",borderStyle:Lr?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:nn?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Zr&&nn?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${nn.remain}%`,backgroundColor:pV(nn.remain)}}):nn?.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:[Tr&&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"})}),ce?.state!=="RUNNING"&&s.jsx("button",{onClick:Cr=>{Cr.stopPropagation(),kt(lt?.amsId===He.id&<?.slotId===At?null:{amsId:He.id,slotId:At})},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(Fd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ce?.state!=="RUNNING"&<?.amsId===He.id&<?.slotId===At&&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:Cr=>{Cr.stopPropagation(),Ye.mutate({amsId:He.id,slotId:At}),kt(null)},disabled:Tr,children:[s.jsx(xr,{className:`w-3 h-3 ${Tr?"animate-spin":""}`}),"Re-read RFID"]})}),Zn?s.jsx(BC,{data:Zn,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Zn.trayUuid?Cr=>{ie({trayUuid:Cr,trayInfo:{type:Zn.profile,color:Zn.colorHex||"",location:`${ed(He.id,He.tray.length)} Slot ${At+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>xe({amsId:He.id,trayId:At,trayCount:He.tray.length,trayType:nn?.tray_type||void 0,trayColor:nn?.tray_color||void 0,traySubBrands:nn?.tray_sub_brands||void 0,trayInfoIdx:nn?.tray_info_idx||void 0})},children:to}):s.jsx(sV,{configureSlot:{enabled:!0,onConfigure:()=>xe({amsId:He.id,trayId:At,trayCount:He.tray.length})},children:to})]},At)})})]},He.id)})}),(pt.length>0||ce.vt_tray&&ce.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[pt.map(He=>{const Lt=Je[String(He.id)],jt=He.id>=128?He.id-128:He.id,Wt=Lt!==void 0?Lt:jt,Rt=Wt===1,Bt=Wt===0,At=He.tray[0],nn=At?.tray_type&&At.remain>=0,Zr=!At?.tray_type,Lr=He.id*4+(At?.id??0),ca=ft===Lr,$n=At?.tray_info_idx?Y?.[At.tray_info_idx]:null,di=be?.[Lr],vr=At?.tray_type?{vendor:qC(At)?"Bambu Lab":"Generic",profile:$n?.name||di?.preset_name||At.tray_sub_brands||At.tray_type,colorName:HC(At.tray_id_name)||VC(At.tray_color),colorHex:At.tray_color||null,kFactor:GC(At.k),fillLevel:nn?At.remain:null,trayUuid:At.tray_uuid||null}:null,Zn=At?.id??0,Tr=tn?.amsId===He.id&&tn?.slotId===Zn,to=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Zr?"opacity-50":""} ${ca?"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:At?.tray_color?`#${At.tray_color}`:At?.tray_type?"#333":"transparent",borderColor:Zr?"#666":"rgba(255,255,255,0.1)",borderStyle:Zr?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:At?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:nn?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${At.remain}%`,backgroundColor:pV(At.remain)}}):At?.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:ed(He.id,He.tray.length)}),me&&(Rt||Bt)&&s.jsx(dV,{side:Rt?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[Tr&&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"})}),ce?.state!=="RUNNING"&&s.jsx("button",{onClick:Cr=>{Cr.stopPropagation(),kt(lt?.amsId===He.id&<?.slotId===Zn?null:{amsId:He.id,slotId:Zn})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:s.jsx(Fd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ce?.state!=="RUNNING"&<?.amsId===He.id&<?.slotId===Zn&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:Cr=>{Cr.stopPropagation(),Ye.mutate({amsId:He.id,slotId:Zn}),kt(null)},disabled:Tr,children:[s.jsx(xr,{className:`w-3 h-3 ${Tr?"animate-spin":""}`}),"Re-read RFID"]})}),vr?s.jsx(BC,{data:vr,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&vr.trayUuid?Cr=>{ie({trayUuid:Cr,trayInfo:{type:vr.profile,color:vr.colorHex||"",location:ed(He.id,He.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>xe({amsId:He.id,trayId:Zn,trayCount:He.tray.length,trayType:At?.tray_type||void 0,trayColor:At?.tray_color||void 0,traySubBrands:At?.tray_sub_brands||void 0,trayInfoIdx:At?.tray_info_idx||void 0})},children:to}):s.jsx(sV,{configureSlot:{enabled:!0,onConfigure:()=>xe({amsId:He.id,trayId:Zn,trayCount:He.tray.length})},children:to})]}),(He.humidity!=null||He.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[He.temp!=null&&s.jsx(mV,{temp:He.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>he({amsId:He.id,amsLabel:ed(He.id,He.tray.length),mode:"temperature"}),compact:!0}),He.humidity!=null&&s.jsx(fV,{humidity:He.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>he({amsId:He.id,amsLabel:ed(He.id,He.tray.length),mode:"humidity"}),compact:!0})]})]})]},He.id)}),ce.vt_tray&&ce.vt_tray.tray_type&&(()=>{const He=ce.vt_tray,Lt=ft===254,jt=He.tray_info_idx?Y?.[He.tray_info_idx]:null,Wt=be?.[1020],Rt={vendor:qC(He)?"Bambu Lab":"Generic",profile:jt?.name||Wt?.preset_name||He.tray_sub_brands||He.tray_type||"Unknown",colorName:HC(He.tray_id_name)||VC(He.tray_color),colorHex:He.tray_color||null,kFactor:GC(He.k),fillLevel:null,trayUuid:He.tray_uuid||null},Bt=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${Lt?"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:He.tray_color?`#${He.tray_color}`:"#333",borderColor:Lt?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:He.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),s.jsx(BC,{data:Rt,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Rt.trayUuid?At=>{ie({trayUuid:At,trayInfo:{type:Rt.profile,color:Rt.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>xe({amsId:255,trayId:0,trayCount:1,trayType:He.tray_type||void 0,trayColor:He.tray_color||void 0,traySubBrands:He.tray_sub_brands||void 0,trayInfoIdx:He.tray_info_idx||void 0})},children:Bt})]})})()]})]})]})})()]}),re&&r==="expanded"&&s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Vf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:re.name}),ke&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${ke.state==="ON"?"bg-bambu-green/20 text-bambu-green":ke.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[ke.state||"?",ke.state==="ON"&&ke.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",ke.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:Ot.isPending||ke?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${ke?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(Mu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>q(!0),disabled:Ot.isPending||ke?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${ke?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(dN,{className:"w-3 h-3"}),"Off"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:`text-xs hidden sm:inline ${re.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:re.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>ln.mutate(!re.auto_off),disabled:ln.isPending||re.auto_off_executed,title:re.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${re.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":re.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${re.auto_off||re.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"text-xs text-bambu-gray",children:[s.jsx("p",{children:t.ip_address}),s.jsx("p",{className:"truncate",children:t.serial_number})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>Kt.mutate(!ce?.chamber_light),disabled:!ce?.connected||Kt.isPending,title:ce?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:ce?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(OPe,{on:ce?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{if(u==="embedded"&&d)d(t.id,t.name);else{const Le=localStorage.getItem("cameraWindowState"),pt=Le?JSON.parse(Le):{width:640,height:400},me=[`width=${pt.width}`,`height=${pt.height}`,pt.left!==void 0?`left=${pt.left}`:"",pt.top!==void 0?`top=${pt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,me)}},disabled:!ce?.connected,title:u==="embedded"?"Open camera overlay":"Open camera in new window",children:s.jsx(VD,{className:"w-4 h-4"})}),s.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:Yt,disabled:!ce?.connected||pn.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:pn.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(I1,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Zt,disabled:!ce?.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(Di,{className:"w-3 h-3"})})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>E(!0),title:"Browse printer files",children:[s.jsx(sN,{className:"w-4 h-4"}),"Files"]})]})]})]}),k&&s.jsx(rpe,{printerId:t.id,printerName:t.name,onClose:()=>E(!1)}),D&&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:()=>Ve(null),children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:Le=>Le.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(I1,{className:"w-5 h-5 text-blue-500"}):le.is_empty?s.jsx(On,{className:"w-5 h-5 text-green-500"}):s.jsx(na,{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:()=>Ve(null),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[le.light_warning&&s.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/20 border border-yellow-500/50",children:[s.jsxs("p",{className:"font-medium text-yellow-400 flex items-center gap-2",children:[s.jsx(An,{className:"w-4 h-4"}),"Chamber light is OFF"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"For reliable detection, please turn ON the chamber light before checking or calibrating."})]}),le.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[s.jsx("p",{className:"font-medium text-blue-400",children:"Calibration Required"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Please ensure the build plate is ",s.jsx("strong",{children:"completely empty"})," and chamber light is ",s.jsx("strong",{children:"ON"}),", then click Calibrate."]})]}),s.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[s.jsx("p",{children:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects."}),s.jsxs("p",{children:[s.jsx("strong",{children:"Tip:"})," You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking."]})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`p-3 rounded-lg ${le.is_empty?"bg-green-500/20 border border-green-500/50":"bg-yellow-500/20 border border-yellow-500/50"}`,children:[s.jsx("p",{className:`font-medium ${le.is_empty?"text-green-400":"text-yellow-400"}`,children:le.is_empty?"Plate appears empty":"Objects detected on plate"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:["Confidence: ",Math.round(le.confidence*100),"% | Difference: ",le.difference_percent.toFixed(1),"%"]})]}),le.debug_image_url&&s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Analysis preview:"}),s.jsx("img",{src:le.debug_image_url,alt:"Plate detection analysis",className:"w-full rounded-lg border border-bambu-dark-tertiary"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Green box = detection area, Red overlay = differences from calibration"})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:le.message})]}),at&&at.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 (",at.references.length,"/",at.max_references,")"]}),s.jsx("div",{className:"grid grid-cols-5 gap-2",children:at.references.map(Le=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:fe.getPlateReferenceThumbnailUrl(t.id,Le.index),alt:Le.label||`Reference ${Le.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),s.jsx("button",{onClick:()=>We(Le.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:"Delete reference",children:s.jsx(Ht,{className:"w-3 h-3 text-white"})}),st?.index===Le.index?s.jsx("input",{type:"text",value:st.label,onChange:pt=>Ct({...st,label:pt.target.value}),onBlur:()=>De(Le.index,st.label),onKeyDown:pt=>{pt.key==="Enter"&&De(Le.index,st.label),pt.key==="Escape"&&Ct(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:()=>Ct({index:Le.index,label:Le.label}),title:Le.label?`${Le.label} - Click to edit`:"Click to add label",children:Le.label||s.jsx("span",{className:"italic opacity-50",children:"No label"})}),s.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:Le.timestamp?new Date(Le.timestamp).toLocaleDateString():""})]},Le.index))})]}),!le.needs_calibration&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Detection Area (ROI)"}),I?s.jsxs("div",{className:"flex gap-1",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>ue(null),disabled:Ae,children:"Cancel"}),s.jsx(Me,{size:"sm",onClick:Ze,disabled:Ae,children:Ae?s.jsx(dt,{className:"w-3 h-3 animate-spin"}):"Save"})]}):s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ue(le.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(sa,{className:"w-3 h-3 mr-1"}),"Edit"]})]}),I?s.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:"X Start"}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:I.x,onChange:Le=>ue({...I,x:parseFloat(Le.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:Le=>ue({...I,y:parseFloat(Le.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:Le=>ue({...I,w:parseFloat(Le.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:Le=>ue({...I,h:parseFloat(Le.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(I.h*100),"%"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."})]}):s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((le.roi?.x||.15)*100),"%, Y=",Math.round((le.roi?.y||.35)*100),"%, W=",Math.round((le.roi?.w||.7)*100),"%, H=",Math.round((le.roi?.h||.55)*100),"%"]})]})]}),s.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:le.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",onClick:()=>Ve(null),children:"Cancel"}),s.jsx(Me,{onClick:()=>de(),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(Me,{variant:"ghost",onClick:()=>de(),disabled:X,children:X?"Adding...":`Add Reference (${at?.references.length||0}/${at?.max_references||5})`}),s.jsx(Me,{onClick:()=>Ve(null),children:"Close"})]})})]})}),R&&re&&s.jsx(zn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{Ot.mutate("on"),U(!1)},onCancel:()=>U(!1)}),O&&re&&s.jsx(zn,{title:"Power Off Printer",message:ce?.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:()=>{Ot.mutate("off"),q(!1)},onCancel:()=>q(!1)}),K&&s.jsx(zn,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{Gt.mutate(),G(!1)},onCancel:()=>G(!1)}),Q&&s.jsx(zn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{vn.mutate(),te(!1)},onCancel:()=>te(!1)}),J&&s.jsx(zn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{gt.mutate(),z(!1)},onCancel:()=>z(!1)}),V&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>ne(!1),onKeyDown:Le=>Le.key==="Escape"&&ne(!1),tabIndex:-1,ref:Le=>Le?.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:Le=>Le.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(cV,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),s.jsx("button",{onClick:()=>ne(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(Ht,{className:"w-4 h-4"})})]}),Ln?Ln.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:[Ln.skipped_count,"/",Ln.total," skipped"]})]}),(ce?.layer_num??0)<=1&&s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx(aa,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",ce?.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:[ce?.cover_url?s.jsx("img",{src:`${ce.cover_url}?view=top`,alt:"Print preview",className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):s.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:s.jsx(Bs,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Ln.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Ln.objects.map((Le,pt)=>{let me,He;if(Le.x!=null&&Le.y!=null&&Ln.bbox_all){const[Lt,jt,Wt,Rt]=Ln.bbox_all,Bt=Wt-Lt,At=Rt-jt,nn=8,Zr=100-nn*2;me=nn+(Le.x-Lt)/Bt*Zr,He=nn+(Rt-Le.y)/At*Zr,me=Math.max(5,Math.min(95,me)),He=Math.max(5,Math.min(95,He))}else if(Le.x!=null&&Le.y!=null)me=Le.x/256*100,He=100-Le.y/256*100,me=Math.max(5,Math.min(95,me)),He=Math.max(5,Math.min(95,He));else{const Lt=Math.ceil(Math.sqrt(Ln.objects.length)),jt=Math.floor(pt/Lt),Wt=pt%Lt,Rt=Math.ceil(Ln.objects.length/Lt);me=15+Wt*(70/Lt)+35/Lt,He=15+jt*(70/Rt)+35/Rt}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${Le.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${me}%`,top:`${He}%`,transform:"translate(-50%, -50%)"},title:Le.name,children:Le.id},Le.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:[Ln.objects.filter(Le=>!Le.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Ln.objects.map(Le=>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
- ${Le.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
- ${Le.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 ${Le.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:Le.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${Le.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 ${Le.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:Le.name}),Le.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),Le.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:()=>Or.mutate([Le.id]),disabled:Or.isPending||(ce?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(ce?.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:(ce?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},Le.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"})})]})]}),j&&s.jsx(fpe,{printerName:t.name,errors:ce?.hms_errors||[],onClose:()=>W(!1)}),ae&&s.jsx(EPe,{isOpen:!!ae,onClose:()=>he(null),printerId:t.id,printerName:t.name,amsId:ae.amsId,amsLabel:ae.amsLabel,initialMode:ae.mode,thresholds:a}),pe&&s.jsx(APe,{isOpen:!!pe,onClose:()=>ie(null),trayUuid:pe.trayUuid,trayInfo:pe.trayInfo}),Ee&&s.jsx(DPe,{isOpen:!!Ee,onClose:()=>xe(null),printerId:t.id,slotInfo:Ee,onSuccess:()=>{f.invalidateQueries({queryKey:["slotPresets",t.id]}),f.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&s.jsx(YPe,{printer:t,onClose:()=>T(!1)}),Ne&&$&&s.jsx(XPe,{printer:t,firmwareInfo:$,onClose:()=>_e(!1)}),lt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>kt(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(()=>{Ml.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 Ml.startSubnetScan(y);const E=setInterval(async()=>{try{const D=await Ml.getScanStatus();S({scanned:D.scanned,total:D.total});const C=await Ml.getDiscoveredPrinters();c(C),D.running||(clearInterval(E),o(!1),m(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await Ml.startDiscovery(10);const E=setInterval(async()=>{try{const D=await Ml.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(E);try{await Ml.stopDiscovery()}catch{}o(!1),m(!0);try{const D=await Ml.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get final discovered printers:",D)}},1e4)}}catch(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 D=E.serial.startsWith("unknown-")?"":E.serial;i({...r,name:E.name||"",serial_number:D,ip_address:E.ip_address,model:T(E.model)}),c([])};return w.useEffect(()=>()=>{Ml.stopDiscovery().catch(()=>{}),Ml.stopSubnetScan().catch(()=>{})},[]),w.useEffect(()=>{const E=D=>{D.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(Mt,{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(Me,{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(Na,{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(Di,{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(Me,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function XPe({printer:t,firmwareInfo:e,onClose:n}){const r=on(),{showToast:i}=Gn(),[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:()=>n1.prepareUpload(t.id),staleTime:3e4}),p=mt({mutationFn:()=>n1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const x=await n1.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(Mt,{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(Bs,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((y,x)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(aa,{className:"w-4 h-4 flex-shrink-0"}),y]},x))})}):null,(l||a)&&a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:a.status}),s.jsxs("span",{className:"text-white",children:[a.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:`h-2 rounded-full transition-all ${a.status==="error"?"bg-status-error":a.status==="complete"?"bg-status-ok":"bg-orange-500"} ${a.status==="uploading"?"animate-pulse":""}`,style:{width:`${a.progress}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.message}),a.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:a.error})]}),a?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["On the printer's touchscreen, go to ",s.jsx("strong",{className:"text-white",children:"Settings"})]}),s.jsxs("li",{children:["Navigate to ",s.jsx("strong",{className:"text-white",children:"Firmware"})]}),s.jsxs("li",{children:["Select ",s.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),s.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Me,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Me,{onClick:b,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(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=>fe.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});w.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const o=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(St,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(Mt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),s.jsxs("form",{onSubmit:o,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:l=>i({...r,name:l.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:l=>i({...r,ip_address:l.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.jsx("input",{type:"password",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:l=>i({...r,access_code:l.target.value}),placeholder:"Leave empty to keep current"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model,onChange:l=>i({...r,model:l.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),s.jsx("input",{type:"text",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.location,onChange:l=>i({...r,location:l.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:l=>i({...r,auto_archive:l.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Me,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function ZPe(t){const{data:e}=ut({queryKey:["printerStatus",t],queryFn:()=>fe.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:()=>fe.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),s.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[s.jsx(Mu,{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 V=localStorage.getItem("printerCardSize");return V?parseInt(V,10):2}),b=m===1?"compact":"expanded",y=on(),[x,v]=w.useState(()=>{const V=localStorage.getItem("openEmbeddedCameras");if(V)try{const ne=JSON.parse(V);return new Map(ne.map(ae=>[ae.id,ae]))}catch{return new Map}return new Map});w.useEffect(()=>{const V=Array.from(x.values());V.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(V)):localStorage.removeItem("openEmbeddedCameras")},[x]);const{data:S,isLoading:M}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:A}=ut({queryKey:["settings"],queryFn:fe.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:fe.getSmartPlugs}),{data:k}=ut({queryKey:["maintenanceOverview"],queryFn:fe.getMaintenanceOverview,staleTime:60*1e3}),{data:E}=ut({queryKey:["spoolman-status"],queryFn:fe.getSpoolmanStatus,staleTime:60*1e3}),D=E?.enabled&&E?.connected,{data:C}=ut({queryKey:["unlinked-spools"],queryFn:fe.getUnlinkedSpools,enabled:!!D,staleTime:30*1e3}),R=C&&C.length>0,U=k?.reduce((V,ne)=>(V[ne.printer_id]={due_count:ne.due_count,warning_count:ne.warning_count,total_print_hours:ne.total_print_hours},V),{})||{},O=T?.reduce((V,ne)=>(ne.printer_id&&(V[ne.printer_id]=ne),V),{})||{},q=mt({mutationFn:fe.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),j=mt({mutationFn:V=>fe.controlSmartPlug(V,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),W=()=>{const V=!n;r(V),localStorage.setItem("hideDisconnectedPrinters",String(V))},K=V=>{u(V),localStorage.setItem("printerSortBy",V)},G=()=>{const V=!d;f(V),localStorage.setItem("printerSortAsc",String(V))},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"}},te=["S","M","L","XL"],J=w.useMemo(()=>{if(!S)return[];const V=[...S];switch(c){case"name":V.sort((ne,ae)=>ne.name.localeCompare(ae.name));break;case"model":V.sort((ne,ae)=>(ne.model||"").localeCompare(ae.model||""));break;case"location":V.sort((ne,ae)=>{const he=ne.location||"",pe=ae.location||"";return!he&&pe?1:he&&!pe?-1:he.localeCompare(pe)||ne.name.localeCompare(ae.name)});break;case"status":V.sort((ne,ae)=>{const he=y.getQueryData(["printerStatus",ne.id]),pe=y.getQueryData(["printerStatus",ae.id]),ie=Ee=>Ee?.connected?Ee.state==="RUNNING"?0:1:2;return ie(he)-ie(pe)});break}return d||V.reverse(),V},[S,c,d,y]),z=w.useMemo(()=>{if(c!=="location")return null;const V={};return J.forEach(ne=>{const ae=ne.location||"Ungrouped";V[ae]||(V[ae]=[]),V[ae].push(ne)}),V},[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:V=>K(V.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"model",children:"Model"}),s.jsx("option",{value:"location",children:"Location"})]}),s.jsx("button",{onClick:G,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(pg,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(T0,{className:"w-4 h-4 text-bambu-gray"})})]}),s.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:te.map((V,ne)=>{const ae=ne+1,he=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===te.length-1?"rounded-r-lg":""} ${he?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${V==="S"?"Small":V==="M"?"Medium":V==="L"?"Large":"Extra large"} cards`,children:V},V)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:n,onChange:W,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(O).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[s.jsx(Mu,{className:"w-4 h-4"}),"Power On",s.jsx(Di,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[s.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),S?.filter(V=>O[V.id]).map(V=>s.jsx(QPe,{printer:V,plug:O[V.id],onPowerOn:ne=>{l(ne),j.mutate(ne)},isPowering:o===O[V.id]?.id},V.id)),S?.filter(V=>O[V.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(er,{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(Mt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(Me,{onClick:()=>e(!0),children:[s.jsx(er,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):z?s.jsx("div",{className:"space-y-6",children:Object.entries(z).map(([V,ne])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),V,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",ne.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Q()}`,children:ne.map(ae=>s.jsx(xV,{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:D,hasUnlinkedSpools:R,timeFormat:A?.time_format||"system",cameraViewMode:A?.camera_view_mode||"window",onOpenEmbeddedCamera:(he,pe)=>v(ie=>new Map(ie).set(he,{id:he,name:pe}))},ae.id))})]},V))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${Q()}`,children:J.map(V=>s.jsx(xV,{printer:V,hideIfDisconnected:n,maintenanceInfo:U[V.id],viewMode:b,cardSize:m,spoolmanEnabled:D,hasUnlinkedSpools:R,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(he=>new Map(he).set(ne,{id:ne,name:ae}))},V.id))}),t&&s.jsx(KPe,{onClose:()=>e(!1),onAdd:V=>q.mutate(V),existingSerials:S?.map(V=>V.serial_number)||[]}),Array.from(x.values()).map((V,ne)=>s.jsx(lpe,{printerId:V.id,printerName:V.name,viewerIndex:ne,onClose:()=>v(ae=>{const he=new Map(ae);return he.delete(V.id),he})},V.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 Xc(t){const e=t3e();window.location.href=`${e}${encodeURIComponent(t)}`}const Y4="182",sg={ROTATE:0,DOLLY:1,PAN:2},Zp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},n3e=0,bV=1,r3e=2,d1=1,i3e=2,$b=3,nh=0,ws=1,Il=2,ou=0,og=1,yV=2,vV=3,_V=4,a3e=5,nf=100,s3e=101,o3e=102,l3e=103,c3e=104,u3e=200,d3e=201,h3e=202,f3e=203,A3=204,T3=205,m3e=206,p3e=207,g3e=208,x3e=209,b3e=210,y3e=211,v3e=212,_3e=213,w3e=214,C3=0,k3=1,j3=2,Ag=3,P3=4,R3=5,D3=6,O3=7,Z4=0,S3e=1,M3e=2,ql=0,XJ=1,YJ=2,ZJ=3,QJ=4,JJ=5,eee=6,tee=7,nee=300,em=301,Tg=302,L3=303,I3=304,cE=306,F3=1e3,eu=1001,U3=1002,Ea=1003,N3e=1004,O_=1005,za=1006,KC=1007,xf=1008,Hs=1009,ree=1010,iee=1011,X0=1012,Q4=1013,rc=1014,$l=1015,_u=1016,J4=1017,eL=1018,Y0=1020,aee=35902,see=35899,oee=1021,lee=1022,rl=1023,wu=1026,bf=1027,cee=1028,tL=1029,Cg=1030,nL=1031,rL=1033,h1=33776,f1=33777,m1=33778,p1=33779,z3=35840,B3=35841,$3=35842,H3=35843,V3=36196,G3=37492,W3=37496,q3=37488,K3=37489,X3=37490,Y3=37491,Z3=37808,Q3=37809,J3=37810,eR=37811,tR=37812,nR=37813,rR=37814,iR=37815,aR=37816,sR=37817,oR=37818,lR=37819,cR=37820,uR=37821,dR=36492,hR=36494,fR=36495,mR=36283,pR=36284,gR=36285,xR=36286,E3e=3200,uee=0,A3e=1,Ed="",vo="srgb",kg="srgb-linear",BS="linear",sr="srgb",np=7680,wV=519,T3e=512,C3e=513,k3e=514,iL=515,j3e=516,P3e=517,aL=518,R3e=519,SV=35044,MV="300 es",Hl=2e3,$S=2001;function dee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function HS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function D3e(){const t=HS("canvas");return t.style.display="block",t}const NV={};function EV(...t){const e="THREE."+t.shift();console.log(e,...t)}function cn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Kn(...t){const e="THREE."+t.shift();console.error(e,...t)}function Z0(...t){const e=t.join(" ");e in NV||(NV[e]=!0,cn(...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 mm=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 ja=["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"],g1=Math.PI/180,bR=180/Math.PI;function qy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ja[t&255]+ja[t>>8&255]+ja[t>>16&255]+ja[t>>24&255]+"-"+ja[e&255]+ja[e>>8&255]+"-"+ja[e>>16&15|64]+ja[e>>24&255]+"-"+ja[n&63|128]+ja[n>>8&255]+"-"+ja[n>>16&255]+ja[n>>24&255]+ja[r&255]+ja[r>>8&255]+ja[r>>16&255]+ja[r>>24&255]).toLowerCase()}function jn(t,e,n){return Math.max(e,Math.min(n,t))}function L3e(t,e){return(t%e+e)%e}function XC(t,e,n){return(1-n)*t+n*e}function xb(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function ms(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const I3e={DEG2RAD:g1};let Mn=class hee{constructor(e=0,n=0){hee.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=jn(this.x,e.x,n.x),this.y=jn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=jn(this.x,e,n),this.y=jn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(jn(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(jn(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}},tm=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:cn("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(jn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},nt=class fee{constructor(e=0,n=0,r=0){fee.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(AV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(AV.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=jn(this.x,e.x,n.x),this.y=jn(this.y,e.y,n.y),this.z=jn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=jn(this.x,e,n),this.y=jn(this.y,e,n),this.z=jn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(jn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return YC.copy(this).projectOnVector(e),this.sub(YC)}reflect(e){return this.sub(YC.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(jn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const YC=new nt,AV=new tm;let En=class mee{constructor(e,n,r,i,a,o,l,c,u){mee.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(ZC.makeScale(e,n)),this}rotate(e){return this.premultiply(ZC.makeRotation(-e)),this}translate(e,n){return this.premultiply(ZC.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 ZC=new En,TV=new En().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),CV=new En().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F3e(){const t={enabled:!0,workingColorSpace:kg,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===sr&&(i.r=lu(i.r),i.g=lu(i.g),i.b=lu(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===sr&&(i.r=lg(i.r),i.g=lg(i.g),i.b=lg(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===Ed?BS: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 Z0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return Z0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[kg]:{primaries:e,whitePoint:r,transfer:BS,toXYZ:TV,fromXYZ:CV,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:vo},outputColorSpaceConfig:{drawingBufferColorSpace:vo}},[vo]:{primaries:e,whitePoint:r,transfer:sr,toXYZ:TV,fromXYZ:CV,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:vo}}}),t}const Vn=F3e();function lu(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function lg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let rp,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{rp===void 0&&(rp=HS("canvas")),rp.width=e.width,rp.height=e.height;const i=rp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=rp}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=HS("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]=lu(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(lu(n[r]/255)*255):n[r]=lu(n[r]);return{data:n,width:e.width,height:e.height}}else return cn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},z3e=0,sL=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:z3e++}),this.uuid=qy(),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(QC(i[o].image)):a.push(QC(i[o]))}else a=QC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function QC(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}:(cn("Texture: Unable to serialize Texture."),{})}let B3e=0;const JC=new nt;let bl=class x1 extends mm{constructor(e=x1.DEFAULT_IMAGE,n=x1.DEFAULT_MAPPING,r=eu,i=eu,a=za,o=xf,l=rl,c=Hs,u=x1.DEFAULT_ANISOTROPY,d=Ed){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:B3e++}),this.uuid=qy(),this.name="",this.source=new sL(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new Mn(0,0),this.repeat=new Mn(1,1),this.center=new Mn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new En,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(JC).x}get height(){return this.source.getSize(JC).y}get depth(){return this.source.getSize(JC).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const r=e[n];if(r===void 0){cn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){cn(`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!==nee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case F3:e.x=e.x-Math.floor(e.x);break;case eu:e.x=e.x<0?0:1;break;case U3: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 F3:e.y=e.y-Math.floor(e.y);break;case eu:e.y=e.y<0?0:1;break;case U3:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};bl.DEFAULT_IMAGE=null;bl.DEFAULT_MAPPING=nee;bl.DEFAULT_ANISOTROPY=1;let Ni=class pee{constructor(e=0,n=0,r=0,i=1){pee.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,D=(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=D/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=E/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-y)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=jn(this.x,e.x,n.x),this.y=jn(this.y,e.y,n.y),this.z=jn(this.z,e.z,n.z),this.w=jn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=jn(this.x,e,n),this.y=jn(this.y,e,n),this.z=jn(this.z,e,n),this.w=jn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(jn(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 mm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:za,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 Ni(0,0,e,n),this.scissorTest=!1,this.viewport=new Ni(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new bl(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:za,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 sL(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Kl=class extends $3e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},gee=class extends bl{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Ea,this.minFilter=Ea,this.wrapR=eu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},H3e=class extends bl{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Ea,this.minFilter=Ea,this.wrapR=eu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},nm=class{constructor(e=new nt(1/0,1/0,1/0),n=new nt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Go.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Go.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Go.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Go):Go.fromBufferAttribute(a,o),Go.applyMatrix4(e.matrixWorld),this.expandByPoint(Go);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),L_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),L_.copy(r.boundingBox)),L_.applyMatrix4(e.matrixWorld),this.union(L_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Go),Go.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(bb),I_.subVectors(this.max,bb),ip.subVectors(e.a,bb),ap.subVectors(e.b,bb),sp.subVectors(e.c,bb),td.subVectors(ap,ip),nd.subVectors(sp,ap),Uh.subVectors(ip,sp);let n=[0,-td.z,td.y,0,-nd.z,nd.y,0,-Uh.z,Uh.y,td.z,0,-td.x,nd.z,0,-nd.x,Uh.z,0,-Uh.x,-td.y,td.x,0,-nd.y,nd.x,0,-Uh.y,Uh.x,0];return!ek(n,ip,ap,sp,I_)||(n=[1,0,0,0,1,0,0,0,1],!ek(n,ip,ap,sp,I_))?!1:(F_.crossVectors(td,nd),n=[F_.x,F_.y,F_.z],ek(n,ip,ap,sp,I_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Go).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Go).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(kc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const kc=[new nt,new nt,new nt,new nt,new nt,new nt,new nt,new nt],Go=new nt,L_=new nm,ip=new nt,ap=new nt,sp=new nt,td=new nt,nd=new nt,Uh=new nt,bb=new nt,I_=new nt,F_=new nt,zh=new nt;function ek(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){zh.fromArray(t,a);const l=i.x*Math.abs(zh.x)+i.y*Math.abs(zh.y)+i.z*Math.abs(zh.z),c=e.dot(zh),u=n.dot(zh),d=r.dot(zh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const V3e=new nm,yb=new nt,tk=new nt;let uE=class{constructor(e=new nt,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):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;yb.subVectors(e,this.center);const n=yb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(yb,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(tk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yb.copy(e.center).add(tk)),this.expandByPoint(yb.copy(e.center).sub(tk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const jc=new nt,nk=new nt,U_=new nt,rd=new nt,rk=new nt,z_=new nt,ik=new nt;let oL=class{constructor(e=new nt,n=new nt(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,jc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=jc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(jc.copy(this.origin).addScaledVector(this.direction,n),jc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){nk.copy(e).add(n).multiplyScalar(.5),U_.copy(n).sub(e).normalize(),rd.copy(this.origin).sub(nk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(U_),l=rd.dot(this.direction),c=-rd.dot(U_),u=rd.lengthSq(),d=Math.abs(1-o*o);let f,m,p,b;if(d>0)if(f=o*c-l,m=o*l-c,b=a*d,f>=0)if(m>=-b)if(m<=b){const y=1/d;f*=y,m*=y,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-b?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=b?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(nk).addScaledVector(U_,m),p}intersectSphere(e,n){jc.subVectors(e.center,this.origin);const r=jc.dot(this.direction),i=jc.dot(jc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,jc)!==null}intersectTriangle(e,n,r,i,a){rk.subVectors(n,e),z_.subVectors(r,e),ik.crossVectors(rk,z_);let o=this.direction.dot(ik),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;rd.subVectors(this.origin,e);const c=l*this.direction.dot(z_.crossVectors(rd,z_));if(c<0)return null;const u=l*this.direction.dot(rk.cross(rd));if(u<0||c+u>o)return null;const d=-l*rd.dot(ik);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},pi=class yR{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){yR.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,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 yR().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return 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/op.setFromMatrixColumn(e,0).length(),a=1/op.setFromMatrixColumn(e,1).length(),o=1/op.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 Ls.subVectors(e,n),Ls.lengthSq()===0&&(Ls.z=1),Ls.normalize(),id.crossVectors(r,Ls),id.lengthSq()===0&&(Math.abs(r.z)===1?Ls.x+=1e-4:Ls.z+=1e-4,Ls.normalize(),id.crossVectors(r,Ls)),id.normalize(),B_.crossVectors(Ls,id),i[0]=id.x,i[4]=B_.x,i[8]=Ls.x,i[1]=id.y,i[5]=B_.y,i[9]=Ls.y,i[2]=id.z,i[6]=B_.z,i[10]=Ls.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],m=r[9],p=r[13],b=r[2],y=r[6],x=r[10],v=r[14],S=r[3],M=r[7],A=r[11],T=r[15],k=i[0],E=i[4],D=i[8],C=i[12],R=i[1],U=i[5],O=i[9],q=i[13],j=i[2],W=i[6],K=i[10],G=i[14],Q=i[3],te=i[7],J=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*Q,a[4]=o*E+l*U+c*W+u*te,a[8]=o*D+l*O+c*K+u*J,a[12]=o*C+l*q+c*G+u*z,a[1]=d*k+f*R+m*j+p*Q,a[5]=d*E+f*U+m*W+p*te,a[9]=d*D+f*O+m*K+p*J,a[13]=d*C+f*q+m*G+p*z,a[2]=b*k+y*R+x*j+v*Q,a[6]=b*E+y*U+x*W+v*te,a[10]=b*D+y*O+x*K+v*J,a[14]=b*C+y*q+x*G+v*z,a[3]=S*k+M*R+A*j+T*Q,a[7]=S*E+M*U+A*W+T*te,a[11]=S*D+M*O+A*K+T*J,a[15]=S*C+M*q+A*G+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=op.set(i[0],i[1],i[2]).length();const o=op.set(i[4],i[5],i[6]).length(),l=op.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),Wo.copy(this);const u=1/a,d=1/o,f=1/l;return Wo.elements[0]*=u,Wo.elements[1]*=u,Wo.elements[2]*=u,Wo.elements[4]*=d,Wo.elements[5]*=d,Wo.elements[6]*=d,Wo.elements[8]*=f,Wo.elements[9]*=f,Wo.elements[10]*=f,n.setFromRotationMatrix(Wo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Hl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),m=(n+e)/(n-e),p=(r+i)/(r-i);let b,y;if(c)b=a/(o-a),y=o*a/(o-a);else if(l===Hl)b=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===$S)b=-o/(o-a),y=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=m,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=b,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Hl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),m=-(n+e)/(n-e),p=-(r+i)/(r-i);let b,y;if(c)b=1/(o-a),y=o/(o-a);else if(l===Hl)b=-2/(o-a),y=-(o+a)/(o-a);else if(l===$S)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 op=new nt,Wo=new pi,G3e=new nt(0,0,0),W3e=new nt(1,1,1),id=new nt,B_=new nt,Ls=new nt,kV=new pi,jV=new tm;let rh=class xee{constructor(e=0,n=0,r=0,i=xee.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(jn(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(-jn(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(jn(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(-jn(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(jn(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(-jn(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:cn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return kV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(kV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return jV.setFromEuler(this),this.setFromQuaternion(jV,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};rh.DEFAULT_ORDER="XYZ";let bee=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 PV=new nt,lp=new tm,Pc=new pi,$_=new nt,vb=new nt,K3e=new nt,X3e=new tm,RV=new nt(1,0,0),DV=new nt(0,1,0),OV=new nt(0,0,1),LV={type:"added"},Y3e={type:"removed"},cp={type:"childadded",child:null},ak={type:"childremoved",child:null};let Js=class b1 extends mm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q3e++}),this.uuid=qy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=b1.DEFAULT_UP.clone();const e=new nt,n=new rh,r=new tm,i=new nt(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new pi},normalMatrix:{value:new En}}),this.matrix=new pi,this.matrixWorld=new pi,this.matrixAutoUpdate=b1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=b1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new bee,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 lp.setFromAxisAngle(e,n),this.quaternion.multiply(lp),this}rotateOnWorldAxis(e,n){return lp.setFromAxisAngle(e,n),this.quaternion.premultiply(lp),this}rotateX(e){return this.rotateOnAxis(RV,e)}rotateY(e){return this.rotateOnAxis(DV,e)}rotateZ(e){return this.rotateOnAxis(OV,e)}translateOnAxis(e,n){return PV.copy(e).applyQuaternion(this.quaternion),this.position.add(PV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(RV,e)}translateY(e){return this.translateOnAxis(DV,e)}translateZ(e){return this.translateOnAxis(OV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Pc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?$_.copy(e):$_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),vb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Pc.lookAt(vb,$_,this.up):Pc.lookAt($_,vb,this.up),this.quaternion.setFromRotationMatrix(Pc),i&&(Pc.extractRotation(i.matrixWorld),lp.setFromRotationMatrix(Pc),this.quaternion.premultiply(lp.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Kn("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(LV),cp.child=e,this.dispatchEvent(cp),cp.child=null):Kn("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(Y3e),ak.child=e,this.dispatchEvent(ak),ak.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Pc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Pc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Pc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(LV),cp.child=e,this.dispatchEvent(cp),cp.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vb,e,K3e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vb,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}};Js.DEFAULT_UP=new nt(0,1,0);Js.DEFAULT_MATRIX_AUTO_UPDATE=!0;Js.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const qo=new nt,Rc=new nt,sk=new nt,Dc=new nt,up=new nt,dp=new nt,IV=new nt,ok=new nt,lk=new nt,ck=new nt,uk=new Ni,dk=new Ni,hk=new Ni;let _b=class Hp{constructor(e=new nt,n=new nt,r=new nt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),qo.subVectors(e,n),i.cross(qo);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){qo.subVectors(i,n),Rc.subVectors(r,n),sk.subVectors(e,n);const o=qo.dot(qo),l=qo.dot(Rc),c=qo.dot(sk),u=Rc.dot(Rc),d=Rc.dot(sk),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const m=1/f,p=(u*c-l*d)*m,b=(o*d-l*c)*m;return a.set(1-p-b,b,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Dc)===null?!1:Dc.x>=0&&Dc.y>=0&&Dc.x+Dc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Dc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,Dc.x),c.addScaledVector(o,Dc.y),c.addScaledVector(l,Dc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return uk.setScalar(0),dk.setScalar(0),hk.setScalar(0),uk.fromBufferAttribute(e,n),dk.fromBufferAttribute(e,r),hk.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(uk,a.x),o.addScaledVector(dk,a.y),o.addScaledVector(hk,a.z),o}static isFrontFacing(e,n,r,i){return qo.subVectors(r,n),Rc.subVectors(e,n),qo.cross(Rc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qo.subVectors(this.c,this.b),Rc.subVectors(this.a,this.b),qo.cross(Rc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Hp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Hp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return Hp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Hp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Hp.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;up.subVectors(i,r),dp.subVectors(a,r),ok.subVectors(e,r);const c=up.dot(ok),u=dp.dot(ok);if(c<=0&&u<=0)return n.copy(r);lk.subVectors(e,i);const d=up.dot(lk),f=dp.dot(lk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(up,o);ck.subVectors(e,a);const p=up.dot(ck),b=dp.dot(ck);if(b>=0&&p<=b)return n.copy(a);const y=p*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(dp,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return IV.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(IV,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(up,o).addScaledVector(dp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const yee={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ad={h:0,s:0,l:0},H_={h:0,s:0,l:0};function fk(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Pn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=vo){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Vn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Vn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Vn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Vn.workingColorSpace){if(e=L3e(e,1),n=jn(n,0,1),r=jn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=fk(o,a,e+1/3),this.g=fk(o,a,e),this.b=fk(o,a,e-1/3)}return Vn.colorSpaceToWorking(this,i),this}setStyle(e,n=vo){function r(a){a!==void 0&&parseFloat(a)<1&&cn("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:cn("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);cn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=vo){const r=yee[e.toLowerCase()];return r!==void 0?this.setHex(r,n):cn("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=lu(e.r),this.g=lu(e.g),this.b=lu(e.b),this}copyLinearToSRGB(e){return this.r=lg(e.r),this.g=lg(e.g),this.b=lg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=vo){return Vn.workingToColorSpace(Pa.copy(this),e),Math.round(jn(Pa.r*255,0,255))*65536+Math.round(jn(Pa.g*255,0,255))*256+Math.round(jn(Pa.b*255,0,255))}getHexString(e=vo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Vn.workingColorSpace){Vn.workingToColorSpace(Pa.copy(this),n);const r=Pa.r,i=Pa.g,a=Pa.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Vn.workingColorSpace){return Vn.workingToColorSpace(Pa.copy(this),n),e.r=Pa.r,e.g=Pa.g,e.b=Pa.b,e}getStyle(e=vo){Vn.workingToColorSpace(Pa.copy(this),e);const n=Pa.r,r=Pa.g,i=Pa.b;return e!==vo?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(ad),this.setHSL(ad.h+e,ad.s+n,ad.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(ad),e.getHSL(H_);const r=XC(ad.h,H_.h,n),i=XC(ad.s,H_.s,n),a=XC(ad.l,H_.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 Pa=new Pn;Pn.NAMES=yee;let Z3e=0,cx=class extends mm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Z3e++}),this.uuid=qy(),this.name="",this.type="Material",this.blending=og,this.side=nh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=A3,this.blendDst=T3,this.blendEquation=nf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Pn(0,0,0),this.blendAlpha=0,this.depthFunc=Ag,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=wV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=np,this.stencilZFail=np,this.stencilZPass=np,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){cn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){cn(`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!==og&&(r.blending=this.blending),this.side!==nh&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==A3&&(r.blendSrc=this.blendSrc),this.blendDst!==T3&&(r.blendDst=this.blendDst),this.blendEquation!==nf&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Ag&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==wV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==np&&(r.stencilFail=this.stencilFail),this.stencilZFail!==np&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==np&&(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++}},lL=class extends cx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Pn(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 rh,this.combine=Z4,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 wi=new nt,V_=new Mn;let Q3e=0,Co=class{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Q3e++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=SV,this.updateRanges=[],this.gpuType=$l,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)V_.fromBufferAttribute(this,n),V_.applyMatrix3(e),this.setXY(n,V_.x,V_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.applyMatrix3(e),this.setXYZ(n,wi.x,wi.y,wi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.applyMatrix4(e),this.setXYZ(n,wi.x,wi.y,wi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.applyNormalMatrix(e),this.setXYZ(n,wi.x,wi.y,wi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)wi.fromBufferAttribute(this,n),wi.transformDirection(e),this.setXYZ(n,wi.x,wi.y,wi.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=xb(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=ms(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=xb(n,this.array)),n}setX(e,n){return this.normalized&&(n=ms(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=xb(n,this.array)),n}setY(e,n){return this.normalized&&(n=ms(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=xb(n,this.array)),n}setZ(e,n){return this.normalized&&(n=ms(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=xb(n,this.array)),n}setW(e,n){return this.normalized&&(n=ms(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=ms(n,this.array),r=ms(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=ms(n,this.array),r=ms(r,this.array),i=ms(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=ms(n,this.array),r=ms(r,this.array),i=ms(i,this.array),a=ms(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==SV&&(e.usage=this.usage),e}},vee=class extends Co{constructor(e,n,r){super(new Uint16Array(e),n,r)}},_ee=class extends Co{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Ks=class extends Co{constructor(e,n,r){super(new Float32Array(e),n,r)}},J3e=0;const fo=new pi,mk=new Js,hp=new nt,Is=new nm,wb=new nm,Gi=new nt;let yl=class wee extends mm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:J3e++}),this.uuid=qy(),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(dee(e)?_ee:vee)(e,1):this.index=e,this}setIndirect(e,n=0){return this.indirect=e,this.indirectOffset=n,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new En().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return fo.makeRotationFromQuaternion(e),this.applyMatrix4(fo),this}rotateX(e){return fo.makeRotationX(e),this.applyMatrix4(fo),this}rotateY(e){return fo.makeRotationY(e),this.applyMatrix4(fo),this}rotateZ(e){return fo.makeRotationZ(e),this.applyMatrix4(fo),this}translate(e,n,r){return fo.makeTranslation(e,n,r),this.applyMatrix4(fo),this}scale(e,n,r){return fo.makeScale(e,n,r),this.applyMatrix4(fo),this}lookAt(e){return mk.lookAt(e),mk.updateMatrix(),this.applyMatrix4(mk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(hp).negate(),this.translate(hp.x,hp.y,hp.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ks(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&cn("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 nm);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Kn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new nt(-1/0,-1/0,-1/0),new nt(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];Is.setFromBufferAttribute(a),this.morphTargetsRelative?(Gi.addVectors(this.boundingBox.min,Is.min),this.boundingBox.expandByPoint(Gi),Gi.addVectors(this.boundingBox.max,Is.max),this.boundingBox.expandByPoint(Gi)):(this.boundingBox.expandByPoint(Is.min),this.boundingBox.expandByPoint(Is.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Kn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new uE);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Kn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new nt,1/0);return}if(e){const r=this.boundingSphere.center;if(Is.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];wb.setFromBufferAttribute(l),this.morphTargetsRelative?(Gi.addVectors(Is.min,wb.min),Is.expandByPoint(Gi),Gi.addVectors(Is.max,wb.max),Is.expandByPoint(Gi)):(Is.expandByPoint(wb.min),Is.expandByPoint(wb.max))}Is.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Gi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Gi));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++)Gi.fromBufferAttribute(l,u),c&&(hp.fromBufferAttribute(e,u),Gi.add(hp)),i=Math.max(i,r.distanceToSquared(Gi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Kn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Kn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Co(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let D=0;D<r.count;D++)l[D]=new nt,c[D]=new nt;const u=new nt,d=new nt,f=new nt,m=new Mn,p=new Mn,b=new Mn,y=new nt,x=new nt;function v(D,C,R){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,C),f.fromBufferAttribute(r,R),m.fromBufferAttribute(a,D),p.fromBufferAttribute(a,C),b.fromBufferAttribute(a,R),d.sub(u),f.sub(u),p.sub(m),b.sub(m);const U=1/(p.x*b.y-b.x*p.y);isFinite(U)&&(y.copy(d).multiplyScalar(b.y).addScaledVector(f,-p.y).multiplyScalar(U),x.copy(f).multiplyScalar(p.x).addScaledVector(d,-b.x).multiplyScalar(U),l[D].add(y),l[C].add(y),l[R].add(y),c[D].add(x),c[C].add(x),c[R].add(x))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let D=0,C=S.length;D<C;++D){const R=S[D],U=R.start,O=R.count;for(let q=U,j=U+O;q<j;q+=3)v(e.getX(q+0),e.getX(q+1),e.getX(q+2))}const M=new nt,A=new nt,T=new nt,k=new nt;function E(D){T.fromBufferAttribute(i,D),k.copy(T);const C=l[D];M.copy(C),M.sub(T.multiplyScalar(T.dot(C))).normalize(),A.crossVectors(k,C);const U=A.dot(c[D])<0?-1:1;o.setXYZW(D,M.x,M.y,M.z,U)}for(let D=0,C=S.length;D<C;++D){const R=S[D],U=R.start,O=R.count;for(let q=U,j=U+O;q<j;q+=3)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 Co(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new nt,a=new nt,o=new nt,l=new nt,c=new nt,u=new nt,d=new nt,f=new nt;if(e)for(let m=0,p=e.count;m<p;m+=3){const b=e.getX(m+0),y=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Gi.fromBufferAttribute(e,n),Gi.normalize(),e.setXYZ(n,Gi.x,Gi.y,Gi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,b=0;for(let y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)m[b++]=u[p++]}return new Co(m,d,f)}if(this.index===null)return cn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new wee,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let m=0,p=f.length;m<p;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const FV=new pi,Bh=new oL,G_=new uE,UV=new nt,W_=new nt,q_=new nt,K_=new nt,pk=new nt,X_=new nt,zV=new nt,Y_=new nt;let hl=class extends Js{constructor(e=new yl,n=new lL){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){X_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(pk.fromBufferAttribute(f,e),o?X_.addScaledVector(pk,d):X_.addScaledVector(pk.sub(n),d))}n.add(X_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),G_.copy(r.boundingSphere),G_.applyMatrix4(a),Bh.copy(e.ray).recast(e.near),!(G_.containsPoint(Bh.origin)===!1&&(Bh.intersectSphere(G_,UV)===null||Bh.origin.distanceToSquared(UV)>(e.far-e.near)**2))&&(FV.copy(a).invert(),Bh.copy(e.ray).applyMatrix4(FV),!(r.boundingBox!==null&&Bh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,Bh)))}_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),D=l.getX(A+2);i=Z_(this,v,e,r,u,d,f,k,E,D),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=Z_(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,D=A+2;i=Z_(this,v,e,r,u,d,f,k,E,D),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=Z_(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===ws?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===nh,l),c===null)return null;Y_.copy(l),Y_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Y_);return u<n.near||u>n.far?null:{distance:u,point:Y_.clone(),object:t}}function Z_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,W_),t.getVertexPosition(c,q_),t.getVertexPosition(u,K_);const d=eRe(t,e,n,r,W_,q_,K_,zV);if(d){const f=new nt;_b.getBarycoord(zV,W_,q_,K_,f),i&&(d.uv=_b.getInterpolatedAttribute(i,l,c,u,f,new Mn)),a&&(d.uv1=_b.getInterpolatedAttribute(a,l,c,u,f,new Mn)),o&&(d.normal=_b.getInterpolatedAttribute(o,l,c,u,f,new nt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const m={a:l,b:c,c:u,normal:new nt,materialIndex:0};_b.getNormal(W_,q_,K_,m.normal),d.face=m,d.barycoord=f}return d}let cL=class See extends yl{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,p=0;b("z","y","x",-1,-1,r,n,e,o,a,0),b("z","y","x",1,-1,r,n,-e,o,a,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ks(u,3)),this.setAttribute("normal",new Ks(d,3)),this.setAttribute("uv",new Ks(f,2));function b(y,x,v,S,M,A,T,k,E,D,C){const R=A/E,U=T/D,O=A/2,q=T/2,j=k/2,W=E+1,K=D+1;let G=0,Q=0;const te=new nt;for(let J=0;J<K;J++){const z=J*U-q;for(let V=0;V<W;V++){const ne=V*R-O;te[y]=ne*S,te[x]=z*M,te[v]=j,u.push(te.x,te.y,te.z),te[y]=0,te[x]=0,te[v]=k>0?1:-1,d.push(te.x,te.y,te.z),f.push(V/E),f.push(1-J/D),G+=1}}for(let J=0;J<D;J++)for(let z=0;z<E;z++){const V=m+z+W*J,ne=m+z+W*(J+1),ae=m+(z+1)+W*(J+1),he=m+(z+1)+W*J;c.push(V,ne,he),c.push(ne,ae,he),Q+=6}l.addGroup(p,Q,C),p+=Q,m+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new See(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function jg(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(cn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function qa(t){const e={};for(let n=0;n<t.length;n++){const r=jg(t[n]);for(const i in r)e[i]=r[i]}return e}function tRe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function Mee(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Vn.workingColorSpace}const nRe={clone:jg,merge:qa};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 ic=class extends cx{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=jg(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}},Nee=class extends Js{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new pi,this.projectionMatrix=new pi,this.projectionMatrixInverse=new pi,this.coordinateSystem=Hl,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const sd=new nt,BV=new Mn,$V=new Mn;let So=class extends Nee{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=bR*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(g1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return bR*2*Math.atan(Math.tan(g1*.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){sd.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(sd.x,sd.y).multiplyScalar(-e/sd.z),sd.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(sd.x,sd.y).multiplyScalar(-e/sd.z)}getViewSize(e,n){return this.getViewBounds(e,BV,$V),n.subVectors($V,BV)}setViewOffset(e,n,r,i,a,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(g1*.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 fp=-90,mp=1;let aRe=class extends Js{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new So(fp,mp,e,n);i.layers=this.layers,this.add(i);const a=new So(fp,mp,e,n);a.layers=this.layers,this.add(a);const o=new So(fp,mp,e,n);o.layers=this.layers,this.add(o);const l=new So(fp,mp,e,n);l.layers=this.layers,this.add(l);const c=new So(fp,mp,e,n);c.layers=this.layers,this.add(c);const u=new So(fp,mp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===Hl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===$S)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}},Eee=class extends bl{constructor(e=[],n=em,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}},Aee=class extends Kl{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new Eee(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 cL(5,5,5),a=new ic({name:"CubemapFromEquirect",uniforms:jg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ws,blending:ou});a.uniforms.tEquirect.value=n;const o=new hl(i,a),l=n.minFilter;return n.minFilter===xf&&(n.minFilter=za),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)}},Hb=class extends Js{constructor(){super(),this.isGroup=!0,this.type="Group"}};const sRe={type:"move"};let gk=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Hb,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Hb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new nt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new nt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Hb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new nt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new nt),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&m>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(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 Hb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},oRe=class extends Js{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new rh,this.environmentIntensity=1,this.environmentRotation=new rh,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 bl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Ea,d=Ea,f,m){super(null,o,l,c,u,d,i,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const xk=new nt,cRe=new nt,uRe=new En;let yd=class{constructor(e=new nt(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=xk.subVectors(r,n).cross(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(xk),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||uRe.getNormalMatrix(e),i=this.coplanarPoint(xk).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const $h=new uE,dRe=new Mn(.5,.5),Q_=new nt;let uL=class{constructor(e=new yd,n=new yd,r=new yd,i=new yd,a=new yd,o=new yd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Hl,r=!1){const i=this.planes,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],m=a[6],p=a[7],b=a[8],y=a[9],x=a[10],v=a[11],S=a[12],M=a[13],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===Hl)i[5].setComponents(u+c,p+m,v+x,T+A).normalize();else if(n===$S)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(),$h.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),$h.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($h)}intersectsSprite(e){$h.center.set(0,0,0);const n=dRe.distanceTo(e.center);return $h.radius=.7071067811865476+n,$h.applyMatrix4(e.matrixWorld),this.intersectsSphere($h)}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(Q_.x=i.normal.x>0?e.max.x:e.min.x,Q_.y=i.normal.y>0?e.max.y:e.min.y,Q_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Q_)<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)}},Tee=class extends cx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Pn(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 VS=new nt,GS=new nt,HV=new pi,Sb=new oL,J_=new uE,bk=new nt,VV=new nt;let hRe=class extends Js{constructor(e=new yl,n=new Tee){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++)VS.fromBufferAttribute(n,i-1),GS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=VS.distanceTo(GS);e.setAttribute("lineDistance",new Ks(r,1))}else cn("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(),J_.copy(r.boundingSphere),J_.applyMatrix4(i),J_.radius+=a,e.ray.intersectsSphere(J_)===!1)return;HV.copy(i).invert(),Sb.copy(e.ray).applyMatrix4(HV);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,m=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),b=Math.min(d.count,o.start+o.count);for(let y=p,x=b-1;y<x;y+=u){const v=d.getX(y),S=d.getX(y+1),M=ew(this,e,Sb,c,v,S,y);M&&n.push(M)}if(this.isLineLoop){const y=d.getX(b-1),x=d.getX(p),v=ew(this,e,Sb,c,y,x,b-1);v&&n.push(v)}}else{const p=Math.max(0,o.start),b=Math.min(m.count,o.start+o.count);for(let y=p,x=b-1;y<x;y+=u){const v=ew(this,e,Sb,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=ew(this,e,Sb,c,b-1,p,b-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function ew(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(VS.fromBufferAttribute(l,i),GS.fromBufferAttribute(l,a),n.distanceSqToSegment(VS,GS,bk,VV)>r)return;bk.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(bk);if(!(u<e.near||u>e.far))return{distance:u,point:VV.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const GV=new nt,WV=new nt;let 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)GV.fromBufferAttribute(n,i),WV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+GV.distanceTo(WV);e.setAttribute("lineDistance",new Ks(r,1))}else cn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},Q0=class extends bl{constructor(e,n,r=rc,i,a,o,l=Ea,c=Ea,u,d=wu,f=1){if(d!==wu&&d!==bf)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 sL(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 Q0{constructor(e,n=rc,r=em,i,a,o=Ea,l=Ea,c,u=wu){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 Cee extends bl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let dL=class kee extends yl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,p=[],b=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*m-o;for(let M=0;M<u;M++){const 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 Ks(b,3)),this.setAttribute("normal",new Ks(y,3)),this.setAttribute("uv",new Ks(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kee(e.width,e.height,e.widthSegments,e.heightSegments)}};class pRe extends ic{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class gRe extends cx{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Pn(16777215),this.specular=new Pn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Pn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=uee,this.normalScale=new Mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new rh,this.combine=Z4,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 cx{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 cx{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},jee=class extends Js{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Pn(e),this.intensity=n}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,n}};const yk=new pi,qV=new nt,KV=new nt;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 Mn(512,512),this.mapType=Hs,this.map=null,this.mapPass=null,this.matrix=new pi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new uL,this._frameExtents=new Mn(1,1),this._viewportCount=1,this._viewports=[new Ni(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;qV.setFromMatrixPosition(e.matrixWorld),n.position.copy(qV),KV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(KV),n.updateMatrixWorld(),yk.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yk,n.coordinateSystem,n.reversedDepth),n.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(yk)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},hL=class extends Nee{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 hL(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class XV extends jee{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Js.DEFAULT_UP),this.updateMatrix(),this.target=new Js,this.shadow=new 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 jee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},wRe=class extends So{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},YV=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=jn(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(jn(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 Pn(r),i=new Pn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let m=0,p=0,b=-l;m<=n;m++,b+=o){c.push(-l,0,b,l,0,b),c.push(b,0,-l,b,0,l);const y=m===a?r:i;y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3}const d=new yl;d.setAttribute("position",new Ks(c,3)),d.setAttribute("color",new Ks(u,3));const f=new Tee({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class MRe extends mm{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){cn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ZV(t,e,n,r){const i=NRe(r);switch(n){case oee:return t*e;case cee:return t*e/i.components*i.byteLength;case tL:return t*e/i.components*i.byteLength;case Cg:return t*e*2/i.components*i.byteLength;case nL:return t*e*2/i.components*i.byteLength;case lee:return t*e*3/i.components*i.byteLength;case rl:return t*e*4/i.components*i.byteLength;case rL:return t*e*4/i.components*i.byteLength;case h1:case f1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case m1:case p1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case B3:case H3:return Math.max(t,16)*Math.max(e,8)/4;case z3:case $3:return Math.max(t,8)*Math.max(e,8)/2;case V3:case G3:case q3:case K3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case W3:case X3:case Y3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Z3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Q3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case J3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case eR:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case tR:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case nR:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case rR:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case iR:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case aR:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case sR:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case oR:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case lR:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case cR:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case uR:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case dR:case hR:case fR:return Math.ceil(t/4)*Math.ceil(e/4)*16;case mR:case pR:return Math.ceil(t/4)*Math.ceil(e/4)*8;case gR:case xR: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 Hs:case ree:return{byteLength:1,components:1};case X0:case iee:case _u:return{byteLength:2,components:1};case J4:case eL:return{byteLength:2,components:4};case rc:case Q4:case $l:return{byteLength:4,components:1};case aee:case see:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Y4}}));typeof window<"u"&&(window.__THREE__?cn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Y4);function Pee(){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>
- }`,wn={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},It={common:{diffuse:{value:new Pn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new En},alphaMap:{value:null},alphaMapTransform:{value:new En},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new En}},envmap:{envMap:{value:null},envMapRotation:{value:new En},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new En}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new En}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new En},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new En},normalScale:{value:new Mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new En},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new En}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new En}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new En}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Pn(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 Pn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new En},alphaTest:{value:0},uvTransform:{value:new En}},sprite:{diffuse:{value:new Pn(16777215)},opacity:{value:1},center:{value:new Mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new En},alphaMap:{value:null},alphaMapTransform:{value:new En},alphaTest:{value:0}}},Ll={basic:{uniforms:qa([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.fog]),vertexShader:wn.meshbasic_vert,fragmentShader:wn.meshbasic_frag},lambert:{uniforms:qa([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new Pn(0)}}]),vertexShader:wn.meshlambert_vert,fragmentShader:wn.meshlambert_frag},phong:{uniforms:qa([It.common,It.specularmap,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.fog,It.lights,{emissive:{value:new Pn(0)},specular:{value:new Pn(1118481)},shininess:{value:30}}]),vertexShader:wn.meshphong_vert,fragmentShader:wn.meshphong_frag},standard:{uniforms:qa([It.common,It.envmap,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.roughnessmap,It.metalnessmap,It.fog,It.lights,{emissive:{value:new Pn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag},toon:{uniforms:qa([It.common,It.aomap,It.lightmap,It.emissivemap,It.bumpmap,It.normalmap,It.displacementmap,It.gradientmap,It.fog,It.lights,{emissive:{value:new Pn(0)}}]),vertexShader:wn.meshtoon_vert,fragmentShader:wn.meshtoon_frag},matcap:{uniforms:qa([It.common,It.bumpmap,It.normalmap,It.displacementmap,It.fog,{matcap:{value:null}}]),vertexShader:wn.meshmatcap_vert,fragmentShader:wn.meshmatcap_frag},points:{uniforms:qa([It.points,It.fog]),vertexShader:wn.points_vert,fragmentShader:wn.points_frag},dashed:{uniforms:qa([It.common,It.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wn.linedashed_vert,fragmentShader:wn.linedashed_frag},depth:{uniforms:qa([It.common,It.displacementmap]),vertexShader:wn.depth_vert,fragmentShader:wn.depth_frag},normal:{uniforms:qa([It.common,It.bumpmap,It.normalmap,It.displacementmap,{opacity:{value:1}}]),vertexShader:wn.meshnormal_vert,fragmentShader:wn.meshnormal_frag},sprite:{uniforms:qa([It.sprite,It.fog]),vertexShader:wn.sprite_vert,fragmentShader:wn.sprite_frag},background:{uniforms:{uvTransform:{value:new En},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wn.background_vert,fragmentShader:wn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new En}},vertexShader:wn.backgroundCube_vert,fragmentShader:wn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wn.cube_vert,fragmentShader:wn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:wn.equirect_vert,fragmentShader:wn.equirect_frag},distance:{uniforms:qa([It.common,It.displacementmap,{referencePosition:{value:new nt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:wn.distance_vert,fragmentShader:wn.distance_frag},shadow:{uniforms:qa([It.lights,It.fog,{color:{value:new Pn(0)},opacity:{value:1}}]),vertexShader:wn.shadow_vert,fragmentShader:wn.shadow_frag}};Ll.physical={uniforms:qa([Ll.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new En},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new En},clearcoatNormalScale:{value:new Mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new En},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new En},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new En},sheen:{value:0},sheenColor:{value:new Pn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new En},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new En},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new En},transmissionSamplerSize:{value:new Mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new En},attenuationDistance:{value:0},attenuationColor:{value:new Pn(0)},specularColor:{value:new Pn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new En},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new En},anisotropyVector:{value:new Mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new En}}]),vertexShader:wn.meshphysical_vert,fragmentShader:wn.meshphysical_frag};const tw={r:0,b:0,g:0},Hh=new rh,s4e=new pi;function o4e(t,e,n,r,i,a,o){const l=new Pn(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===cE)?(d===void 0&&(d=new hl(new cL(1,1,1),new ic({name:"BackgroundCubeMaterial",uniforms:jg(Ll.backgroundCube.uniforms),vertexShader:Ll.backgroundCube.vertexShader,fragmentShader:Ll.backgroundCube.fragmentShader,side:ws,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,E,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),Hh.copy(A.backgroundRotation),Hh.x*=-1,Hh.y*=-1,Hh.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Hh.y*=-1,Hh.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(Hh)),d.material.toneMapped=Vn.getTransfer(T.colorSpace)!==sr,(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 hl(new dL(2,2),new ic({name:"BackgroundMaterial",uniforms:jg(Ll.background.uniforms),vertexShader:Ll.background.vertexShader,fragmentShader:Ll.background.fragmentShader,side:nh,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=Vn.getTransfer(T.colorSpace)!==sr,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(tw,Mee(t)),r.buffers.color.setClear(tw.r,tw.g,tw.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(R,U,O,q,j){let W=!1;const K=f(q,O,U);a!==K&&(a=K,u(a.object)),W=p(R,q,O,j),W&&b(R,q,O,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,A(R,U,O,q),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,U,O){const q=O.wireframe===!0;let j=r[R.id];j===void 0&&(j={},r[R.id]=j);let W=j[U.id];W===void 0&&(W={},j[U.id]=W);let K=W[q];return K===void 0&&(K=m(c()),W[q]=K),K}function m(R){const U=[],O=[],q=[];for(let j=0;j<n;j++)U[j]=0,O[j]=0,q[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:O,attributeDivisors:q,object:R,attributes:{},index:null}}function p(R,U,O,q){const j=a.attributes,W=U.attributes;let K=0;const G=O.getAttributes();for(const Q in G)if(G[Q].location>=0){const J=j[Q];let z=W[Q];if(z===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(z=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(z=R.instanceColor)),J===void 0||J.attribute!==z||z&&J.data!==z.data)return!0;K++}return a.attributesNum!==K||a.index!==q}function b(R,U,O,q){const j={},W=U.attributes;let K=0;const G=O.getAttributes();for(const Q in G)if(G[Q].location>=0){let J=W[Q];J===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(J=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(J=R.instanceColor));const z={};z.attribute=J,J&&J.data&&(z.data=J.data),j[Q]=z,K++}a.attributes=j,a.attributesNum=K,a.index=q}function y(){const R=a.newAttributes;for(let U=0,O=R.length;U<O;U++)R[U]=0}function x(R){v(R,0)}function v(R,U){const O=a.newAttributes,q=a.enabledAttributes,j=a.attributeDivisors;O[R]=1,q[R]===0&&(t.enableVertexAttribArray(R),q[R]=1),j[R]!==U&&(t.vertexAttribDivisor(R,U),j[R]=U)}function S(){const R=a.newAttributes,U=a.enabledAttributes;for(let O=0,q=U.length;O<q;O++)U[O]!==R[O]&&(t.disableVertexAttribArray(O),U[O]=0)}function M(R,U,O,q,j,W,K){K===!0?t.vertexAttribIPointer(R,U,O,j,W):t.vertexAttribPointer(R,U,O,q,j,W)}function A(R,U,O,q){y();const j=q.attributes,W=O.getAttributes(),K=U.defaultAttributeValues;for(const G in W){const Q=W[G];if(Q.location>=0){let te=j[G];if(te===void 0&&(G==="instanceMatrix"&&R.instanceMatrix&&(te=R.instanceMatrix),G==="instanceColor"&&R.instanceColor&&(te=R.instanceColor)),te!==void 0){const J=te.normalized,z=te.itemSize,V=e.get(te);if(V===void 0)continue;const ne=V.buffer,ae=V.type,he=V.bytesPerElement,pe=ae===t.INT||ae===t.UNSIGNED_INT||te.gpuType===Q4;if(te.isInterleavedBufferAttribute){const ie=te.data,Ee=ie.stride,xe=te.offset;if(ie.isInstancedInterleavedBuffer){for(let Ne=0;Ne<Q.locationSize;Ne++)v(Q.location+Ne,ie.meshPerAttribute);R.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,Ee*he,(xe+z/Q.locationSize*Ne)*he,pe)}else{if(te.isInstancedBufferAttribute){for(let ie=0;ie<Q.locationSize;ie++)v(Q.location+ie,te.meshPerAttribute);R.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=te.meshPerAttribute*te.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*he,z/Q.locationSize*ie*he,pe)}}else if(K!==void 0){const J=K[G];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(){D();for(const R in r){const U=r[R];for(const O in U){const q=U[O];for(const j in q)d(q[j].object),delete q[j];delete U[O]}delete r[R]}}function k(R){if(r[R.id]===void 0)return;const U=r[R.id];for(const O in U){const q=U[O];for(const j in q)d(q[j].object),delete q[j];delete U[O]}delete r[R.id]}function E(R){for(const U in r){const O=r[U];if(O[R.id]===void 0)continue;const q=O[R.id];for(const j in q)d(q[j].object),delete q[j];delete O[R.id]}}function D(){C(),o=!0,a!==i&&(a=i,u(a.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:C,dispose: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!==rl&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(E){const D=E===_u&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==Hs&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==$l&&!D)}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&&(cn("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 yd,l=new En,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const p=f.length!==0||m||r!==0||i;return i=m,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=d(f,m,0)},this.setState=function(f,m,p){const b=f.clippingPlanes,y=f.clipIntersection,x=f.clipShadows,v=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const S=a?0:r,M=S*4;let 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===L3?o.mapping=em:l===I3&&(o.mapping=Tg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===L3||l===I3)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 Aee(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 jd=4,QV=[.125,.215,.35,.446,.526,.582],rf=20,f4e=256,Mb=new hL,JV=new Pn;let vk=null,_k=0,wk=0,Sk=!1;const m4e=new nt;let eG=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:o=256,position:l=m4e}=a;vk=this._renderer.getRenderTarget(),_k=this._renderer.getActiveCubeFace(),wk=this._renderer.getActiveMipmapLevel(),Sk=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=rG(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=nG(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(vk,_k,wk),this._renderer.xr.enabled=Sk,e.scissorTest=!1,pp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===em||e.mapping===Tg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),vk=this._renderer.getRenderTarget(),_k=this._renderer.getActiveCubeFace(),wk=this._renderer.getActiveMipmapLevel(),Sk=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:za,minFilter:za,generateMipmaps:!1,type:_u,format:rl,colorSpace:kg,depthBuffer:!1},i=tG(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=tG(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=p4e(a)),this._blurMaterial=x4e(a,e,n),this._ggxMaterial=g4e(a,e,n)}return i}_compileMaterial(e){const n=new hl(new yl,e);this._renderer.compile(n,Mb)}_sceneToCubeUV(e,n,r,i,a){const c=new So(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,p=f.toneMapping;f.getClearColor(JV),f.toneMapping=ql,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new hl(new cL,new lL({name:"PMREM.Background",side:ws,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,x=y.material;let v=!1;const S=e.background;S?S.isColor&&(x.color.copy(S),e.background=null,v=!0):(x.color.copy(JV),v=!0);for(let M=0;M<6;M++){const 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;pp(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===em||e.mapping===Tg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=rG()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=nG());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;pp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Mb)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),m=0+u*1.25,p=f*m,{_lodMax:b}=this,y=this._sizeLods[r],x=3*y*(r>b-jd?r-b+jd:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=b-n,pp(a,x,v,3*y,2*y),i.setRenderTarget(a),i.render(l,Mb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,pp(e,x,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Mb)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Kn("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*rf-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):rf;x>rf&&cn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${rf}`);const v=[];let S=0;for(let E=0;E<rf;++E){const D=E/y,C=Math.exp(-D*D/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-jd?i-M+jd:0),k=4*(this._cubeSize-A);pp(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,Mb)}};function p4e(t){const e=[],n=[],r=[];let i=t;const a=t-jd+1+QV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-jd?c=QV[o-t+jd-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,D=k>2?0:-1,C=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];S.set(C,y*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];A.set(R,v*b*k)}const T=new yl;T.setAttribute("position",new Co(S,y)),T.setAttribute("uv",new Co(M,x)),T.setAttribute("faceIndex",new Co(A,v)),r.push(new hl(T,null)),i>jd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function tG(t,e,n){const r=new Kl(t,e,n);return r.texture.mapping=cE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function pp(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 ic({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:dE(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:ou,depthTest:!1,depthWrite:!1})}function x4e(t,e,n){const r=new Float32Array(rf),i=new nt(0,1,0);return new ic({name:"SphericalGaussianBlur",defines:{n:rf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:dE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:ou,depthTest:!1,depthWrite:!1})}function nG(){return new ic({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:dE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:ou,depthTest:!1,depthWrite:!1})}function rG(){return new ic({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:dE(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:ou,depthTest:!1,depthWrite:!1})}function dE(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function b4e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===L3||c===I3,d=c===em||c===Tg;if(u||d){let f=e.get(l);const m=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==m)return n===null&&(n=new eG(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new eG(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function 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&&Z0("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(dee(m)?_ee:vee)(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:Kn("WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function S4e(t,e,n){const r=new WeakMap,i=new Ni;function a(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let m=r.get(l);if(m===void 0||m.count!==f){let R=function(){D.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var p=R;m!==void 0&&m.texture.dispose();const b=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,x=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],M=l.morphAttributes.color||[];let 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),D=new gee(E,T,k,f);D.type=$l,D.needsUpdate=!0;const C=A*4;for(let U=0;U<f;U++){const O=v[U],q=S[U],j=M[U],W=T*k*4*U;for(let K=0;K<O.count;K++){const G=K*C;b===!0&&(i.fromBufferAttribute(O,K),E[W+G+0]=i.x,E[W+G+1]=i.y,E[W+G+2]=i.z,E[W+G+3]=0),y===!0&&(i.fromBufferAttribute(q,K),E[W+G+4]=i.x,E[W+G+5]=i.y,E[W+G+6]=i.z,E[W+G+7]=0),x===!0&&(i.fromBufferAttribute(j,K),E[W+G+8]=i.x,E[W+G+9]=i.y,E[W+G+10]=i.z,E[W+G+11]=j.itemSize===4?i.w:1)}}m={count:f,texture:D,size:new Mn(T,k)},r.set(l,m),l.addEventListener("dispose",R)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let b=0;for(let x=0;x<u.length;x++)b+=u[x];const y=l.morphTargetsRelative?1:1-b;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:a}}function 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={[XJ]:"LINEAR_TONE_MAPPING",[YJ]:"REINHARD_TONE_MAPPING",[ZJ]:"CINEON_TONE_MAPPING",[QJ]:"ACES_FILMIC_TONE_MAPPING",[eee]:"AGX_TONE_MAPPING",[tee]:"NEUTRAL_TONE_MAPPING",[JJ]:"CUSTOM_TONE_MAPPING"};function E4e(t,e,n,r,i){const a=new Kl(e,n,{type:t,depthBuffer:r,stencilBuffer:i}),o=new Kl(e,n,{type:_u,depthBuffer:!1,stencilBuffer:!1}),l=new yl;l.setAttribute("position",new Ks([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Ks([0,2,0,0,2,0],2));const c=new 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 hl(l,c),d=new hL(-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===ql&&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=ql,!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 D=A;A=T,T=D}}if(f!==S.outputColorSpace||m!==S.toneMapping){f=S.outputColorSpace,m=S.toneMapping,c.defines={},Vn.getTransfer(f)===sr&&(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 Ree=new bl,vR=new Q0(1,1),Dee=new gee,Oee=new H3e,Lee=new Eee,iG=[],aG=[],sG=new Float32Array(16),oG=new Float32Array(9),lG=new Float32Array(4);function ux(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=iG[i];if(a===void 0&&(a=new Float32Array(i),iG[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Oi(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 Li(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function hE(t,e){let n=aG[e];n===void 0&&(n=new Int32Array(e),aG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function 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(Oi(n,e))return;t.uniform2fv(this.addr,e),Li(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(Oi(n,e))return;t.uniform3fv(this.addr,e),Li(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(Oi(n,e))return;t.uniform4fv(this.addr,e),Li(n,e)}}function j4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Oi(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Li(n,e)}else{if(Oi(n,r))return;lG.set(r),t.uniformMatrix2fv(this.addr,!1,lG),Li(n,r)}}function P4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Oi(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Li(n,e)}else{if(Oi(n,r))return;oG.set(r),t.uniformMatrix3fv(this.addr,!1,oG),Li(n,r)}}function R4e(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Oi(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Li(n,e)}else{if(Oi(n,r))return;sG.set(r),t.uniformMatrix4fv(this.addr,!1,sG),Li(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(Oi(n,e))return;t.uniform2iv(this.addr,e),Li(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(Oi(n,e))return;t.uniform3iv(this.addr,e),Li(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(Oi(n,e))return;t.uniform4iv(this.addr,e),Li(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(Oi(n,e))return;t.uniform2uiv(this.addr,e),Li(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(Oi(n,e))return;t.uniform3uiv(this.addr,e),Li(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(Oi(n,e))return;t.uniform4uiv(this.addr,e),Li(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?(vR.compareFunction=n.isReversedDepthBuffer()?aL:iL,a=vR):a=Ree,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||Oee,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||Lee,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||Dee,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=ux(e,this.size,2);t.uniform2fv(this.addr,n)}function X4e(t,e){const n=ux(e,this.size,3);t.uniform3fv(this.addr,n)}function Y4e(t,e){const n=ux(e,this.size,4);t.uniform4fv(this.addr,n)}function Z4e(t,e){const n=ux(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Q4e(t,e){const n=ux(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function J4e(t,e){const n=ux(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=hE(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));let o;this.type===t.SAMPLER_2D_SHADOW?o=vR:o=Ree;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=hE(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||Oee,a[o])}function uLe(t,e,n){const r=this.cache,i=e.length,a=hE(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||Lee,a[o])}function dLe(t,e,n){const r=this.cache,i=e.length,a=hE(n,i);Oi(r,a)||(t.uniform1iv(this.addr,a),Li(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||Dee,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 Mk=/(\w+)(\])?(\[|\.)?/g;function cG(t,e){t.seq.push(e),t.map[e.id]=e}function gLe(t,e,n){const r=t.name,i=r.length;for(Mk.lastIndex=0;;){const a=Mk.exec(r),o=Mk.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){cG(n,u===void 0?new fLe(l,t,e):new mLe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new pLe(l),cG(n,f)),n=f}}}let y1=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 uG(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 dG=new En;function vLe(t){Vn._getMatrix(dG,Vn.workingColorSpace,t);const e=`mat3( ${dG.elements.map(n=>n.toFixed(4))} )`;switch(Vn.getTransfer(t)){case BS:return[e,"LinearTransferOETF"];case sr:return[e,"sRGBTransferOETF"];default:return cn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function hG(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+a+`
- `+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={[XJ]:"Linear",[YJ]:"Reinhard",[ZJ]:"Cineon",[QJ]:"ACESFilmic",[eee]:"AgX",[tee]:"Neutral",[JJ]:"Custom"};function SLe(t,e){const n=wLe[e];return n===void 0?(cn("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+t+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const nw=new nt;function MLe(){Vn.getLuminanceCoefficients(nw);const t=nw.x.toFixed(4),e=nw.y.toFixed(4),n=nw.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(Vb).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 Vb(t){return t!==""}function fG(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function mG(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const TLe=/^[ \t]*#include +<([\w\d./]+)>/gm;function _R(t){return t.replace(TLe,kLe)}const CLe=new Map;function kLe(t,e){let n=wn[e];if(n===void 0){const r=CLe.get(e);if(r!==void 0)n=wn[r],cn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return _R(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 pG(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 gG(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}const RLe={[d1]:"SHADOWMAP_TYPE_PCF",[$b]:"SHADOWMAP_TYPE_VSM"};function DLe(t){return RLe[t.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const OLe={[em]:"ENVMAP_TYPE_CUBE",[Tg]:"ENVMAP_TYPE_CUBE",[cE]:"ENVMAP_TYPE_CUBE_UV"};function LLe(t){return t.envMap===!1?"ENVMAP_TYPE_CUBE":OLe[t.envMapMode]||"ENVMAP_TYPE_CUBE"}const ILe={[Tg]:"ENVMAP_MODE_REFRACTION"};function FLe(t){return t.envMap===!1?"ENVMAP_MODE_REFLECTION":ILe[t.envMapMode]||"ENVMAP_MODE_REFLECTION"}const ULe={[Z4]:"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(Vb).join(`
- `),x.length>0&&(x+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Vb).join(`
- `),v.length>0&&(v+=`
- `)):(x=[gG(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Vb).join(`
- `),v=[gG(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==ql?"#define TONE_MAPPING":"",n.toneMapping!==ql?wn.tonemapping_pars_fragment:"",n.toneMapping!==ql?SLe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",wn.colorspace_pars_fragment,_Le("linearToOutputTexel",n.outputColorSpace),MLe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Vb).join(`
- `)),o=_R(o),o=fG(o,n),o=mG(o,n),l=_R(l),l=fG(l,n),l=mG(l,n),o=pG(o),l=pG(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,x=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,v=["#define varying in",n.glslVersion===MV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===MV?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+v);const M=S+x+o,A=S+v+l,T=uG(i,i.VERTEX_SHADER,M),k=uG(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 O=i.getProgramInfoLog(y)||"",q=i.getShaderInfoLog(T)||"",j=i.getShaderInfoLog(k)||"",W=O.trim(),K=q.trim(),G=j.trim();let Q=!0,te=!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=hG(i,T,"vertex"),z=hG(i,k,"fragment");Kn("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+U.name+`
- Material Type: `+U.type+`
- Program Info Log: `+W+`
- `+J+`
- `+z)}else W!==""?cn("WebGLProgram: Program Info Log:",W):(K===""||G==="")&&(te=!1);te&&(U.diagnostics={runnable:Q,programLog:W,vertexShader:{log:K,prefix:x},fragmentShader:{log:G,prefix:v}})}i.deleteShader(T),i.deleteShader(k),D=new y1(i,y),C=ALe(i,y)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let C;this.getAttributes=function(){return C===void 0&&E(this),C};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,xLe)),R},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 bee,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,R,U,O,q){const j=O.fog,W=q.geometry,K=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),Q=G&&G.mapping===cE?G.image.height:null,te=b[C.type];C.precision!==null&&(p=i.getMaxPrecision(C.precision),p!==C.precision&&cn("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 V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let ne,ae,he,pe;if(te){const Ot=Ll[te];ne=Ot.vertexShader,ae=Ot.fragmentShader}else ne=C.vertexShader,ae=C.fragmentShader,c.update(C),he=c.getVertexShaderID(C),pe=c.getFragmentShaderID(C);const ie=t.getRenderTarget(),Ee=t.state.buffers.depth.getReversed(),xe=q.isInstancedMesh===!0,Ne=q.isBatchedMesh===!0,_e=!!C.map,le=!!C.matcap,Ve=!!G,H=!!C.aoMap,ee=!!C.lightMap,X=!!C.bumpMap,B=!!C.normalMap,I=!!C.displacementMap,ue=!!C.emissiveMap,Ae=!!C.metalnessMap,Ie=!!C.roughnessMap,ce=C.anisotropy>0,$=C.clearcoat>0,L=C.dispersion>0,Y=C.iridescence>0,be=C.sheen>0,Se=C.transmission>0,se=ce&&!!C.anisotropyMap,Pe=$&&!!C.clearcoatMap,Re=$&&!!C.clearcoatNormalMap,Xe=$&&!!C.clearcoatRoughnessMap,et=Y&&!!C.iridescenceMap,Je=Y&&!!C.iridescenceThicknessMap,oe=be&&!!C.sheenColorMap,ye=be&&!!C.sheenRoughnessMap,je=!!C.specularMap,$e=!!C.specularColorMap,ft=!!C.specularIntensityMap,re=Se&&!!C.transmissionMap,ke=Se&&!!C.thicknessMap,ve=!!C.gradientMap,Fe=!!C.alphaMap,Ue=C.alphaTest>0,Te=!!C.alphaHash,qe=!!C.extensions;let bt=ql;C.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(bt=t.toneMapping);const Pt={shaderID:te,shaderType:C.type,shaderName:C.name,vertexShader:ne,fragmentShader:ae,defines:C.defines,customVertexShaderID:he,customFragmentShaderID:pe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:p,batching:Ne,batchingColor:Ne&&q._colorsTexture!==null,instancing:xe,instancingColor:xe&&q.instanceColor!==null,instancingMorph:xe&&q.morphTexture!==null,outputColorSpace:ie===null?t.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:kg,alphaToCoverage:!!C.alphaToCoverage,map:_e,matcap:le,envMap:Ve,envMapMode:Ve&&G.mapping,envMapCubeUVHeight:Q,aoMap:H,lightMap:ee,bumpMap:X,normalMap:B,displacementMap:I,emissiveMap:ue,normalMapObjectSpace:B&&C.normalMapType===A3e,normalMapTangentSpace:B&&C.normalMapType===uee,metalnessMap:Ae,roughnessMap:Ie,anisotropy:ce,anisotropyMap:se,clearcoat:$,clearcoatMap:Pe,clearcoatNormalMap:Re,clearcoatRoughnessMap:Xe,dispersion:L,iridescence:Y,iridescenceMap:et,iridescenceThicknessMap:Je,sheen:be,sheenColorMap:oe,sheenRoughnessMap:ye,specularMap:je,specularColorMap:$e,specularIntensityMap:ft,transmission:Se,transmissionMap:re,thicknessMap:ke,gradientMap:ve,opaque:C.transparent===!1&&C.blending===og&&C.alphaToCoverage===!1,alphaMap:Fe,alphaTest:Ue,alphaHash:Te,combine:C.combine,mapUv:_e&&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:ue&&y(C.emissiveMap.channel),metalnessMapUv:Ae&&y(C.metalnessMap.channel),roughnessMapUv:Ie&&y(C.roughnessMap.channel),anisotropyMapUv:se&&y(C.anisotropyMap.channel),clearcoatMapUv:Pe&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:Re&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Xe&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:et&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Je&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:ye&&y(C.sheenRoughnessMap.channel),specularMapUv:je&&y(C.specularMap.channel),specularColorMapUv:$e&&y(C.specularColorMap.channel),specularIntensityMapUv:ft&&y(C.specularIntensityMap.channel),transmissionMapUv:re&&y(C.transmissionMap.channel),thicknessMapUv:ke&&y(C.thicknessMap.channel),alphaMapUv:Fe&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(B||ce),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(_e||Fe),fog:!!j,useFog:C.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:C.flatShading===!0&&C.wireframe===!1,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Ee,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:bt,decodeVideoTexture:_e&&C.map.isVideoTexture===!0&&Vn.getTransfer(C.map.colorSpace)===sr,decodeVideoTextureEmissive:ue&&C.emissiveMap.isVideoTexture===!0&&Vn.getTransfer(C.emissiveMap.colorSpace)===sr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Il,flipSided:C.side===ws,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionClipCullDistance:qe&&C.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(qe&&C.extensions.multiDraw===!0||Ne)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()};return Pt.vertexUv1s=u.has(1),Pt.vertexUv2s=u.has(2),Pt.vertexUv3s=u.has(3),u.clear(),Pt}function v(C){const R=[];if(C.shaderID?R.push(C.shaderID):(R.push(C.customVertexShaderID),R.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)R.push(U),R.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(R,C),M(R,C),R.push(t.outputColorSpace)),R.push(C.customProgramCacheKey),R.join()}function S(C,R){C.push(R.precision),C.push(R.outputColorSpace),C.push(R.envMapMode),C.push(R.envMapCubeUVHeight),C.push(R.mapUv),C.push(R.alphaMapUv),C.push(R.lightMapUv),C.push(R.aoMapUv),C.push(R.bumpMapUv),C.push(R.normalMapUv),C.push(R.displacementMapUv),C.push(R.emissiveMapUv),C.push(R.metalnessMapUv),C.push(R.roughnessMapUv),C.push(R.anisotropyMapUv),C.push(R.clearcoatMapUv),C.push(R.clearcoatNormalMapUv),C.push(R.clearcoatRoughnessMapUv),C.push(R.iridescenceMapUv),C.push(R.iridescenceThicknessMapUv),C.push(R.sheenColorMapUv),C.push(R.sheenRoughnessMapUv),C.push(R.specularMapUv),C.push(R.specularColorMapUv),C.push(R.specularIntensityMapUv),C.push(R.transmissionMapUv),C.push(R.thicknessMapUv),C.push(R.combine),C.push(R.fogExp2),C.push(R.sizeAttenuation),C.push(R.morphTargetsCount),C.push(R.morphAttributeCount),C.push(R.numDirLights),C.push(R.numPointLights),C.push(R.numSpotLights),C.push(R.numSpotLightMaps),C.push(R.numHemiLights),C.push(R.numRectAreaLights),C.push(R.numDirLightShadows),C.push(R.numPointLightShadows),C.push(R.numSpotLightShadows),C.push(R.numSpotLightShadowsWithMaps),C.push(R.numLightProbes),C.push(R.shadowMapType),C.push(R.toneMapping),C.push(R.numClippingPlanes),C.push(R.numClipIntersection),C.push(R.depthPacking)}function M(C,R){l.disableAll(),R.instancing&&l.enable(0),R.instancingColor&&l.enable(1),R.instancingMorph&&l.enable(2),R.matcap&&l.enable(3),R.envMap&&l.enable(4),R.normalMapObjectSpace&&l.enable(5),R.normalMapTangentSpace&&l.enable(6),R.clearcoat&&l.enable(7),R.iridescence&&l.enable(8),R.alphaTest&&l.enable(9),R.vertexColors&&l.enable(10),R.vertexAlphas&&l.enable(11),R.vertexUv1s&&l.enable(12),R.vertexUv2s&&l.enable(13),R.vertexUv3s&&l.enable(14),R.vertexTangents&&l.enable(15),R.anisotropy&&l.enable(16),R.alphaHash&&l.enable(17),R.batching&&l.enable(18),R.dispersion&&l.enable(19),R.batchingColor&&l.enable(20),R.gradientMap&&l.enable(21),C.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.reversedDepthBuffer&&l.enable(4),R.skinning&&l.enable(5),R.morphTargets&&l.enable(6),R.morphNormals&&l.enable(7),R.morphColors&&l.enable(8),R.premultipliedAlpha&&l.enable(9),R.shadowMapEnabled&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),R.decodeVideoTextureEmissive&&l.enable(20),R.alphaToCoverage&&l.enable(21),C.push(l.mask)}function A(C){const R=b[C.type];let U;if(R){const O=Ll[R];U=nRe.clone(O.uniforms)}else U=C.uniforms;return U}function T(C,R){let U=f.get(R);return U!==void 0?++U.usedTimes:(U=new $Le(t,R,C,a),d.push(U),f.set(R,U)),U}function k(C){if(--C.usedTimes===0){const R=d.indexOf(C);d[R]=d[d.length-1],d.pop(),f.delete(C.cacheKey),C.destroy()}}function E(C){c.remove(C)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:E,programs:d,dispose:D}}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 xG(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function bG(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,p,b,y,x){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:y,group:x},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=b,v.renderOrder=f.renderOrder,v.z=y,v.group=x),e++,v}function l(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||KLe),r.length>1&&r.sort(m||xG),i.length>1&&i.sort(m||xG)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function XLe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new bG,t.set(r,[o])):i>=a.length?(o=new bG,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function 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 nt,color:new Pn};break;case"SpotLight":n={position:new nt,direction:new nt,color:new Pn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new nt,color:new Pn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new nt,skyColor:new Pn,groundColor:new Pn};break;case"RectAreaLight":n={color:new Pn,position:new nt,halfWidth:new nt,halfHeight:new nt};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 Mn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let 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 nt);const i=new nt,a=new pi,o=new pi;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,R=u.length;C<R;C++){const U=u[C],O=U.color,q=U.intensity,j=U.distance;let W=null;if(U.shadow&&U.shadow.map&&(U.shadow.map.texture.format===Cg?W=U.shadow.map.texture:W=U.shadow.map.depthTexture||U.shadow.map.texture),U.isAmbientLight)d+=O.r*q,f+=O.g*q,m+=O.b*q;else if(U.isLightProbe){for(let 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 G=U.shadow,Q=n.get(U);Q.shadowIntensity=G.intensity,Q.shadowBias=G.bias,Q.shadowNormalBias=G.normalBias,Q.shadowRadius=G.radius,Q.shadowMapSize=G.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(O).multiplyScalar(q),K.distance=j,K.coneCos=Math.cos(U.angle),K.penumbraCos=Math.cos(U.angle*(1-U.penumbra)),K.decay=U.decay,r.spot[y]=K;const G=U.shadow;if(U.map&&(r.spotLightMap[T]=U.map,T++,G.updateMatrices(U),U.castShadow&&k++),r.spotLightMatrix[y]=G.matrix,U.castShadow){const Q=n.get(U);Q.shadowIntensity=G.intensity,Q.shadowBias=G.bias,Q.shadowNormalBias=G.normalBias,Q.shadowRadius=G.radius,Q.shadowMapSize=G.mapSize,r.spotShadow[y]=Q,r.spotShadowMap[y]=W,A++}y++}else if(U.isRectAreaLight){const K=e.get(U);K.color.copy(O).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 G=U.shadow,Q=n.get(U);Q.shadowIntensity=G.intensity,Q.shadowBias=G.bias,Q.shadowNormalBias=G.normalBias,Q.shadowRadius=G.radius,Q.shadowMapSize=G.mapSize,Q.shadowCameraNear=G.camera.near,Q.shadowCameraFar=G.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=It.LTC_FLOAT_1,r.rectAreaLTC2=It.LTC_FLOAT_2):(r.rectAreaLTC1=It.LTC_HALF_1,r.rectAreaLTC2=It.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=m;const D=r.hash;(D.directionalLength!==p||D.pointLength!==b||D.spotLength!==y||D.rectAreaLength!==x||D.hemiLength!==v||D.numDirectionalShadows!==S||D.numPointShadows!==M||D.numSpotShadows!==A||D.numSpotMaps!==T||D.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,D.directionalLength=p,D.pointLength=b,D.spotLength=y,D.rectAreaLength=x,D.hemiLength=v,D.numDirectionalShadows=S,D.numPointShadows=M,D.numSpotShadows=A,D.numSpotMaps=T,D.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 yG(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 yG(t),e.set(i,[l])):a>=o.length?(l=new yG(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const 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 nt(1,0,0),new nt(-1,0,0),new nt(0,1,0),new nt(0,-1,0),new nt(0,0,1),new nt(0,0,-1)],aIe=[new nt(0,-1,0),new nt(0,-1,0),new nt(0,0,1),new nt(0,0,-1),new nt(0,-1,0),new nt(0,-1,0)],vG=new pi,Nb=new nt,Nk=new nt;function sIe(t,e,n){let r=new uL;const i=new Mn,a=new Mn,o=new Ni,l=new xRe,c=new bRe,u={},d=n.maxTextureSize,f={[nh]:ws,[ws]:nh,[Il]:Il},m=new ic({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Mn},radius:{value:4}},vertexShader:nIe,fragmentShader:rIe}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new yl;b.setAttribute("position",new Co(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new hl(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=d1;let v=this.type;this.render=function(k,E,D){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||k.length===0)return;k.type===i3e&&(cn("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),k.type=d1);const C=t.getRenderTarget(),R=t.getActiveCubeFace(),U=t.getActiveMipmapLevel(),O=t.state;O.setBlending(ou),O.buffers.depth.getReversed()===!0?O.buffers.color.setClear(0,0,0,0):O.buffers.color.setClear(1,1,1,1),O.buffers.depth.setTest(!0),O.setScissorTest(!1);const q=v!==this.type;q&&E.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(W=>W.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,W=k.length;j<W;j++){const K=k[j],G=K.shadow;if(G===void 0){cn("WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Q=G.getFrameExtents();if(i.multiply(Q),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,G.mapSize.y=a.y)),G.map===null||q===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===$b){if(K.isPointLight){cn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new Kl(i.x,i.y,{format:Cg,type:_u,minFilter:za,magFilter:za,generateMipmaps:!1}),G.map.texture.name=K.name+".shadowMap",G.map.depthTexture=new Q0(i.x,i.y,$l),G.map.depthTexture.name=K.name+".shadowMapDepth",G.map.depthTexture.format=wu,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ea,G.map.depthTexture.magFilter=Ea}else{K.isPointLight?(G.map=new Aee(i.x),G.map.depthTexture=new mRe(i.x,rc)):(G.map=new Kl(i.x,i.y),G.map.depthTexture=new Q0(i.x,i.y,rc)),G.map.depthTexture.name=K.name+".shadowMap",G.map.depthTexture.format=wu;const J=t.state.buffers.depth.getReversed();this.type===d1?(G.map.depthTexture.compareFunction=J?aL:iL,G.map.depthTexture.minFilter=za,G.map.depthTexture.magFilter=za):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=Ea,G.map.depthTexture.magFilter=Ea)}G.camera.updateProjectionMatrix()}const te=G.map.isWebGLCubeRenderTarget?6:1;for(let J=0;J<te;J++){if(G.map.isWebGLCubeRenderTarget)t.setRenderTarget(G.map,J),t.clear();else{J===0&&(t.setRenderTarget(G.map),t.clear());const z=G.getViewport(J);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),O.viewport(o)}if(K.isPointLight){const z=G.camera,V=G.matrix,ne=K.distance||z.far;ne!==z.far&&(z.far=ne,z.updateProjectionMatrix()),Nb.setFromMatrixPosition(K.matrixWorld),z.position.copy(Nb),Nk.copy(z.position),Nk.add(iIe[J]),z.up.copy(aIe[J]),z.lookAt(Nk),z.updateMatrixWorld(),V.makeTranslation(-Nb.x,-Nb.y,-Nb.z),vG.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),G._frustum.setFromProjectionMatrix(vG,z.coordinateSystem,z.reversedDepth)}else G.updateMatrices(K);r=G.getFrustum(),A(E,D,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===$b&&S(G,D),G.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(C,R,U)};function S(k,E){const D=e.update(y);m.defines.VSM_SAMPLES!==k.blurSamples&&(m.defines.VSM_SAMPLES=k.blurSamples,p.defines.VSM_SAMPLES=k.blurSamples,m.needsUpdate=!0,p.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new Kl(i.x,i.y,{format:Cg,type:_u})),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,D,m,y,null),p.uniforms.shadow_pass.value=k.mapPass.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(E,null,D,p,y,null)}function M(k,E,D,C){let R=null;const U=D.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(U!==void 0)R=U;else if(R=D.isPointLight===!0?c:l,t.localClippingEnabled&&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 O=R.uuid,q=E.uuid;let j=u[O];j===void 0&&(j={},u[O]=j);let W=j[q];W===void 0&&(W=R.clone(),j[q]=W,E.addEventListener("dispose",T)),R=W}if(R.visible=E.visible,R.wireframe=E.wireframe,C===$b?R.side=E.shadowSide!==null?E.shadowSide:E.side:R.side=E.shadowSide!==null?E.shadowSide:f[E.side],R.alphaMap=E.alphaMap,R.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,R.map=E.map,R.clipShadows=E.clipShadows,R.clippingPlanes=E.clippingPlanes,R.clipIntersection=E.clipIntersection,R.displacementMap=E.displacementMap,R.displacementScale=E.displacementScale,R.displacementBias=E.displacementBias,R.wireframeLinewidth=E.wireframeLinewidth,R.linewidth=E.linewidth,D.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const O=t.properties.get(R);O.light=D}return R}function A(k,E,D,C,R){if(k.visible===!1)return;if(k.layers.test(E.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&R===$b)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,k.matrixWorld);const q=e.update(k),j=k.material;if(Array.isArray(j)){const W=q.groups;for(let K=0,G=W.length;K<G;K++){const Q=W[K],te=j[Q.materialIndex];if(te&&te.visible){const J=M(k,te,C,R);k.onBeforeShadow(t,k,E,D,q,J,Q),t.renderBufferDirect(D,null,q,J,k,Q),k.onAfterShadow(t,k,E,D,q,J,Q)}}}else if(j.visible){const W=M(k,j,C,R);k.onBeforeShadow(t,k,E,D,q,W,null),t.renderBufferDirect(D,null,q,W,k,null),k.onAfterShadow(t,k,E,D,q,W,null)}}const O=k.children;for(let q=0,j=O.length;q<j;q++)A(O[q],E,D,C,R)}function T(k){k.target.removeEventListener("dispose",T);for(const D in u){const C=u[D],R=k.target.uuid;R in C&&(C[R].dispose(),delete C[R])}}}const oIe={[C3]:k3,[j3]:D3,[P3]:O3,[Ag]:R3,[k3]:C3,[D3]:j3,[O3]:P3,[R3]:Ag};function lIe(t,e){function n(){let re=!1;const ke=new Ni;let ve=null;const Fe=new Ni(0,0,0,0);return{setMask:function(Ue){ve!==Ue&&!re&&(t.colorMask(Ue,Ue,Ue,Ue),ve=Ue)},setLocked:function(Ue){re=Ue},setClear:function(Ue,Te,qe,bt,Pt){Pt===!0&&(Ue*=bt,Te*=bt,qe*=bt),ke.set(Ue,Te,qe,bt),Fe.equals(ke)===!1&&(t.clearColor(Ue,Te,qe,bt),Fe.copy(ke))},reset:function(){re=!1,ve=null,Fe.set(-1,0,0,0)}}}function r(){let re=!1,ke=!1,ve=null,Fe=null,Ue=null;return{setReversed:function(Te){if(ke!==Te){const qe=e.get("EXT_clip_control");Te?qe.clipControlEXT(qe.LOWER_LEFT_EXT,qe.ZERO_TO_ONE_EXT):qe.clipControlEXT(qe.LOWER_LEFT_EXT,qe.NEGATIVE_ONE_TO_ONE_EXT),ke=Te;const bt=Ue;Ue=null,this.setClear(bt)}},getReversed:function(){return ke},setTest:function(Te){Te?ie(t.DEPTH_TEST):Ee(t.DEPTH_TEST)},setMask:function(Te){ve!==Te&&!re&&(t.depthMask(Te),ve=Te)},setFunc:function(Te){if(ke&&(Te=oIe[Te]),Fe!==Te){switch(Te){case C3:t.depthFunc(t.NEVER);break;case k3:t.depthFunc(t.ALWAYS);break;case j3:t.depthFunc(t.LESS);break;case Ag:t.depthFunc(t.LEQUAL);break;case P3:t.depthFunc(t.EQUAL);break;case R3:t.depthFunc(t.GEQUAL);break;case D3:t.depthFunc(t.GREATER);break;case O3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Fe=Te}},setLocked:function(Te){re=Te},setClear:function(Te){Ue!==Te&&(ke&&(Te=1-Te),t.clearDepth(Te),Ue=Te)},reset:function(){re=!1,ve=null,Fe=null,Ue=null,ke=!1}}}function i(){let re=!1,ke=null,ve=null,Fe=null,Ue=null,Te=null,qe=null,bt=null,Pt=null;return{setTest:function(Ot){re||(Ot?ie(t.STENCIL_TEST):Ee(t.STENCIL_TEST))},setMask:function(Ot){ke!==Ot&&!re&&(t.stencilMask(Ot),ke=Ot)},setFunc:function(Ot,ln,Gt){(ve!==Ot||Fe!==ln||Ue!==Gt)&&(t.stencilFunc(Ot,ln,Gt),ve=Ot,Fe=ln,Ue=Gt)},setOp:function(Ot,ln,Gt){(Te!==Ot||qe!==ln||bt!==Gt)&&(t.stencilOp(Ot,ln,Gt),Te=Ot,qe=ln,bt=Gt)},setLocked:function(Ot){re=Ot},setClear:function(Ot){Pt!==Ot&&(t.clearStencil(Ot),Pt=Ot)},reset:function(){re=!1,ke=null,ve=null,Fe=null,Ue=null,Te=null,qe=null,bt=null,Pt=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 Pn(0,0,0),D=0,C=!1,R=null,U=null,O=null,q=null,j=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(Q)[1]),K=G>=1):Q.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),K=G>=2);let te=null,J={};const z=t.getParameter(t.SCISSOR_BOX),V=t.getParameter(t.VIEWPORT),ne=new Ni().fromArray(z),ae=new Ni().fromArray(V);function he(re,ke,ve,Fe){const Ue=new Uint8Array(4),Te=t.createTexture();t.bindTexture(re,Te),t.texParameteri(re,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(re,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let qe=0;qe<ve;qe++)re===t.TEXTURE_3D||re===t.TEXTURE_2D_ARRAY?t.texImage3D(ke,0,t.RGBA,1,1,Fe,0,t.RGBA,t.UNSIGNED_BYTE,Ue):t.texImage2D(ke+qe,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ue);return Te}const pe={};pe[t.TEXTURE_2D]=he(t.TEXTURE_2D,t.TEXTURE_2D,1),pe[t.TEXTURE_CUBE_MAP]=he(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),pe[t.TEXTURE_2D_ARRAY]=he(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),pe[t.TEXTURE_3D]=he(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(Ag),X(!1),B(bV),ie(t.CULL_FACE),H(ou);function ie(re){d[re]!==!0&&(t.enable(re),d[re]=!0)}function Ee(re){d[re]!==!1&&(t.disable(re),d[re]=!1)}function xe(re,ke){return f[re]!==ke?(t.bindFramebuffer(re,ke),f[re]=ke,re===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=ke),re===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=ke),!0):!1}function Ne(re,ke){let ve=p,Fe=!1;if(re){ve=m.get(ke),ve===void 0&&(ve=[],m.set(ke,ve));const Ue=re.textures;if(ve.length!==Ue.length||ve[0]!==t.COLOR_ATTACHMENT0){for(let Te=0,qe=Ue.length;Te<qe;Te++)ve[Te]=t.COLOR_ATTACHMENT0+Te;ve.length=Ue.length,Fe=!0}}else ve[0]!==t.BACK&&(ve[0]=t.BACK,Fe=!0);Fe&&t.drawBuffers(ve)}function _e(re){return b!==re?(t.useProgram(re),b=re,!0):!1}const le={[nf]:t.FUNC_ADD,[s3e]:t.FUNC_SUBTRACT,[o3e]:t.FUNC_REVERSE_SUBTRACT};le[l3e]=t.MIN,le[c3e]=t.MAX;const Ve={[u3e]:t.ZERO,[d3e]:t.ONE,[h3e]:t.SRC_COLOR,[A3]:t.SRC_ALPHA,[b3e]:t.SRC_ALPHA_SATURATE,[g3e]:t.DST_COLOR,[m3e]:t.DST_ALPHA,[f3e]:t.ONE_MINUS_SRC_COLOR,[T3]: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(re,ke,ve,Fe,Ue,Te,qe,bt,Pt,Ot){if(re===ou){y===!0&&(Ee(t.BLEND),y=!1);return}if(y===!1&&(ie(t.BLEND),y=!0),re!==a3e){if(re!==x||Ot!==C){if((v!==nf||A!==nf)&&(t.blendEquation(t.FUNC_ADD),v=nf,A=nf),Ot)switch(re){case og:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case yV:t.blendFunc(t.ONE,t.ONE);break;case vV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case _V:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Kn("WebGLState: Invalid blending: ",re);break}else switch(re){case og:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case yV:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case vV:Kn("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case _V:Kn("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Kn("WebGLState: Invalid blending: ",re);break}S=null,M=null,T=null,k=null,E.set(0,0,0),D=0,x=re,C=Ot}return}Ue=Ue||ke,Te=Te||ve,qe=qe||Fe,(ke!==v||Ue!==A)&&(t.blendEquationSeparate(le[ke],le[Ue]),v=ke,A=Ue),(ve!==S||Fe!==M||Te!==T||qe!==k)&&(t.blendFuncSeparate(Ve[ve],Ve[Fe],Ve[Te],Ve[qe]),S=ve,M=Fe,T=Te,k=qe),(bt.equals(E)===!1||Pt!==D)&&(t.blendColor(bt.r,bt.g,bt.b,Pt),E.copy(bt),D=Pt),x=re,C=!1}function ee(re,ke){re.side===Il?Ee(t.CULL_FACE):ie(t.CULL_FACE);let ve=re.side===ws;ke&&(ve=!ve),X(ve),re.blending===og&&re.transparent===!1?H(ou):H(re.blending,re.blendEquation,re.blendSrc,re.blendDst,re.blendEquationAlpha,re.blendSrcAlpha,re.blendDstAlpha,re.blendColor,re.blendAlpha,re.premultipliedAlpha),o.setFunc(re.depthFunc),o.setTest(re.depthTest),o.setMask(re.depthWrite),a.setMask(re.colorWrite);const Fe=re.stencilWrite;l.setTest(Fe),Fe&&(l.setMask(re.stencilWriteMask),l.setFunc(re.stencilFunc,re.stencilRef,re.stencilFuncMask),l.setOp(re.stencilFail,re.stencilZFail,re.stencilZPass)),ue(re.polygonOffset,re.polygonOffsetFactor,re.polygonOffsetUnits),re.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):Ee(t.SAMPLE_ALPHA_TO_COVERAGE)}function X(re){R!==re&&(re?t.frontFace(t.CW):t.frontFace(t.CCW),R=re)}function B(re){re!==n3e?(ie(t.CULL_FACE),re!==U&&(re===bV?t.cullFace(t.BACK):re===r3e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ee(t.CULL_FACE),U=re}function I(re){re!==O&&(K&&t.lineWidth(re),O=re)}function ue(re,ke,ve){re?(ie(t.POLYGON_OFFSET_FILL),(q!==ke||j!==ve)&&(t.polygonOffset(ke,ve),q=ke,j=ve)):Ee(t.POLYGON_OFFSET_FILL)}function Ae(re){re?ie(t.SCISSOR_TEST):Ee(t.SCISSOR_TEST)}function Ie(re){re===void 0&&(re=t.TEXTURE0+W-1),te!==re&&(t.activeTexture(re),te=re)}function ce(re,ke,ve){ve===void 0&&(te===null?ve=t.TEXTURE0+W-1:ve=te);let Fe=J[ve];Fe===void 0&&(Fe={type:void 0,texture:void 0},J[ve]=Fe),(Fe.type!==re||Fe.texture!==ke)&&(te!==ve&&(t.activeTexture(ve),te=ve),t.bindTexture(re,ke||pe[re]),Fe.type=re,Fe.texture=ke)}function $(){const re=J[te];re!==void 0&&re.type!==void 0&&(t.bindTexture(re.type,null),re.type=void 0,re.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Y(){try{t.compressedTexImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function be(){try{t.texSubImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Se(){try{t.texSubImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function se(){try{t.compressedTexSubImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Pe(){try{t.compressedTexSubImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Re(){try{t.texStorage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Xe(){try{t.texStorage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function et(){try{t.texImage2D(...arguments)}catch(re){Kn("WebGLState:",re)}}function Je(){try{t.texImage3D(...arguments)}catch(re){Kn("WebGLState:",re)}}function oe(re){ne.equals(re)===!1&&(t.scissor(re.x,re.y,re.z,re.w),ne.copy(re))}function ye(re){ae.equals(re)===!1&&(t.viewport(re.x,re.y,re.z,re.w),ae.copy(re))}function je(re,ke){let ve=u.get(ke);ve===void 0&&(ve=new WeakMap,u.set(ke,ve));let Fe=ve.get(re);Fe===void 0&&(Fe=t.getUniformBlockIndex(ke,re.name),ve.set(re,Fe))}function $e(re,ke){const Fe=u.get(ke).get(re);c.get(ke)!==Fe&&(t.uniformBlockBinding(ke,Fe,re.__bindingPointIndex),c.set(ke,Fe))}function ft(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),o.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},te=null,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 Pn(0,0,0),D=0,C=!1,R=null,U=null,O=null,q=null,j=null,ne.set(0,0,t.canvas.width,t.canvas.height),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:Ee,bindFramebuffer:xe,drawBuffers:Ne,useProgram:_e,setBlending:H,setMaterial:ee,setFlipSided:X,setCullFace:B,setLineWidth:I,setPolygonOffset:ue,setScissorTest:Ae,activeTexture:Ie,bindTexture:ce,unbindTexture:$,compressedTexImage2D:L,compressedTexImage3D:Y,texImage2D:et,texImage3D:Je,updateUBOMapping:je,uniformBlockBinding:$e,texStorage2D:Re,texStorage3D:Xe,texSubImage2D:be,texSubImage3D:Se,compressedTexSubImage2D:se,compressedTexSubImage3D:Pe,scissor:oe,viewport:ye,reset:ft}}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 Mn,d=new WeakMap;let f;const m=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b($,L){return p?new OffscreenCanvas($,L):HS("canvas")}function y($,L,Y){let be=1;const Se=ce($);if((Se.width>Y||Se.height>Y)&&(be=Y/Math.max(Se.width,Se.height)),be<1)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap||typeof VideoFrame<"u"&&$ instanceof VideoFrame){const se=Math.floor(be*Se.width),Pe=Math.floor(be*Se.height);f===void 0&&(f=b(se,Pe));const Re=L?b(se,Pe):f;return Re.width=se,Re.height=Pe,Re.getContext("2d").drawImage($,0,0,se,Pe),cn("WebGLRenderer: Texture has been resized from ("+Se.width+"x"+Se.height+") to ("+se+"x"+Pe+")."),Re}else return"data"in $&&cn("WebGLRenderer: Image in DataTexture is too big ("+Se.width+"x"+Se.height+")."),$;return $}function x($){return $.generateMipmaps}function v($){t.generateMipmap($)}function S($){return $.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:$.isWebGL3DRenderTarget?t.TEXTURE_3D:$.isWebGLArrayRenderTarget||$.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function M($,L,Y,be,Se=!1){if($!==null){if(t[$]!==void 0)return t[$];cn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let se=L;if(L===t.RED&&(Y===t.FLOAT&&(se=t.R32F),Y===t.HALF_FLOAT&&(se=t.R16F),Y===t.UNSIGNED_BYTE&&(se=t.R8)),L===t.RED_INTEGER&&(Y===t.UNSIGNED_BYTE&&(se=t.R8UI),Y===t.UNSIGNED_SHORT&&(se=t.R16UI),Y===t.UNSIGNED_INT&&(se=t.R32UI),Y===t.BYTE&&(se=t.R8I),Y===t.SHORT&&(se=t.R16I),Y===t.INT&&(se=t.R32I)),L===t.RG&&(Y===t.FLOAT&&(se=t.RG32F),Y===t.HALF_FLOAT&&(se=t.RG16F),Y===t.UNSIGNED_BYTE&&(se=t.RG8)),L===t.RG_INTEGER&&(Y===t.UNSIGNED_BYTE&&(se=t.RG8UI),Y===t.UNSIGNED_SHORT&&(se=t.RG16UI),Y===t.UNSIGNED_INT&&(se=t.RG32UI),Y===t.BYTE&&(se=t.RG8I),Y===t.SHORT&&(se=t.RG16I),Y===t.INT&&(se=t.RG32I)),L===t.RGB_INTEGER&&(Y===t.UNSIGNED_BYTE&&(se=t.RGB8UI),Y===t.UNSIGNED_SHORT&&(se=t.RGB16UI),Y===t.UNSIGNED_INT&&(se=t.RGB32UI),Y===t.BYTE&&(se=t.RGB8I),Y===t.SHORT&&(se=t.RGB16I),Y===t.INT&&(se=t.RGB32I)),L===t.RGBA_INTEGER&&(Y===t.UNSIGNED_BYTE&&(se=t.RGBA8UI),Y===t.UNSIGNED_SHORT&&(se=t.RGBA16UI),Y===t.UNSIGNED_INT&&(se=t.RGBA32UI),Y===t.BYTE&&(se=t.RGBA8I),Y===t.SHORT&&(se=t.RGBA16I),Y===t.INT&&(se=t.RGBA32I)),L===t.RGB&&(Y===t.UNSIGNED_INT_5_9_9_9_REV&&(se=t.RGB9_E5),Y===t.UNSIGNED_INT_10F_11F_11F_REV&&(se=t.R11F_G11F_B10F)),L===t.RGBA){const Pe=Se?BS:Vn.getTransfer(be);Y===t.FLOAT&&(se=t.RGBA32F),Y===t.HALF_FLOAT&&(se=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(se=Pe===sr?t.SRGB8_ALPHA8:t.RGBA8),Y===t.UNSIGNED_SHORT_4_4_4_4&&(se=t.RGBA4),Y===t.UNSIGNED_SHORT_5_5_5_1&&(se=t.RGB5_A1)}return(se===t.R16F||se===t.R32F||se===t.RG16F||se===t.RG32F||se===t.RGBA16F||se===t.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function A($,L){let Y;return $?L===null||L===rc||L===Y0?Y=t.DEPTH24_STENCIL8:L===$l?Y=t.DEPTH32F_STENCIL8:L===X0&&(Y=t.DEPTH24_STENCIL8,cn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===rc||L===Y0?Y=t.DEPTH_COMPONENT24:L===$l?Y=t.DEPTH_COMPONENT32F:L===X0&&(Y=t.DEPTH_COMPONENT16),Y}function T($,L){return x($)===!0||$.isFramebufferTexture&&$.minFilter!==Ea&&$.minFilter!==za?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function k($){const L=$.target;L.removeEventListener("dispose",k),D(L),L.isVideoTexture&&d.delete(L)}function E($){const L=$.target;L.removeEventListener("dispose",E),R(L)}function D($){const L=r.get($);if(L.__webglInit===void 0)return;const Y=$.source,be=m.get(Y);if(be){const Se=be[L.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&C($),Object.keys(be).length===0&&m.delete(Y)}r.remove($)}function C($){const L=r.get($);t.deleteTexture(L.__webglTexture);const Y=$.source,be=m.get(Y);delete be[L.__cacheKey],o.memory.textures--}function R($){const L=r.get($);if($.depthTexture&&($.depthTexture.dispose(),r.remove($.depthTexture)),$.isWebGLCubeRenderTarget)for(let be=0;be<6;be++){if(Array.isArray(L.__webglFramebuffer[be]))for(let Se=0;Se<L.__webglFramebuffer[be].length;Se++)t.deleteFramebuffer(L.__webglFramebuffer[be][Se]);else t.deleteFramebuffer(L.__webglFramebuffer[be]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[be])}else{if(Array.isArray(L.__webglFramebuffer))for(let be=0;be<L.__webglFramebuffer.length;be++)t.deleteFramebuffer(L.__webglFramebuffer[be]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let be=0;be<L.__webglColorRenderbuffer.length;be++)L.__webglColorRenderbuffer[be]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[be]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const Y=$.textures;for(let be=0,Se=Y.length;be<Se;be++){const se=r.get(Y[be]);se.__webglTexture&&(t.deleteTexture(se.__webglTexture),o.memory.textures--),r.remove(Y[be])}r.remove($)}let U=0;function O(){U=0}function q(){const $=U;return $>=i.maxTextures&&cn("WebGLTextures: Trying to use "+$+" texture units while this GPU supports only "+i.maxTextures),U+=1,$}function j($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function W($,L){const Y=r.get($);if($.isVideoTexture&&Ae($),$.isRenderTargetTexture===!1&&$.isExternalTexture!==!0&&$.version>0&&Y.__version!==$.version){const be=$.image;if(be===null)cn("WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)cn("WebGLRenderer: Texture marked for update but image is incomplete");else{pe(Y,$,L);return}}else $.isExternalTexture&&(Y.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+L)}function K($,L){const Y=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){pe(Y,$,L);return}else $.isExternalTexture&&(Y.__webglTexture=$.sourceTexture?$.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+L)}function G($,L){const Y=r.get($);if($.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){pe(Y,$,L);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+L)}function Q($,L){const Y=r.get($);if($.isCubeDepthTexture!==!0&&$.version>0&&Y.__version!==$.version){ie(Y,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+L)}const te={[F3]:t.REPEAT,[eu]:t.CLAMP_TO_EDGE,[U3]:t.MIRRORED_REPEAT},J={[Ea]:t.NEAREST,[N3e]:t.NEAREST_MIPMAP_NEAREST,[O_]:t.NEAREST_MIPMAP_LINEAR,[za]:t.LINEAR,[KC]:t.LINEAR_MIPMAP_NEAREST,[xf]:t.LINEAR_MIPMAP_LINEAR},z={[T3e]:t.NEVER,[R3e]:t.ALWAYS,[C3e]:t.LESS,[iL]:t.LEQUAL,[k3e]:t.EQUAL,[aL]:t.GEQUAL,[j3e]:t.GREATER,[P3e]:t.NOTEQUAL};function V($,L){if(L.type===$l&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===za||L.magFilter===KC||L.magFilter===O_||L.magFilter===xf||L.minFilter===za||L.minFilter===KC||L.minFilter===O_||L.minFilter===xf)&&cn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri($,t.TEXTURE_WRAP_S,te[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,te[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,te[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,J[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,J[L.minFilter]),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,z[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===Ea||L.minFilter!==O_&&L.minFilter!==xf||L.type===$l&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||r.get(L).__currentAnisotropy){const Y=e.get("EXT_texture_filter_anisotropic");t.texParameterf($,Y.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy}}}function ne($,L){let Y=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",k));const be=L.source;let Se=m.get(be);Se===void 0&&(Se={},m.set(be,Se));const se=j(L);if(se!==$.__cacheKey){Se[se]===void 0&&(Se[se]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),Se[se].usedTimes++;const Pe=Se[$.__cacheKey];Pe!==void 0&&(Se[$.__cacheKey].usedTimes--,Pe.usedTimes===0&&C(L)),$.__cacheKey=se,$.__webglTexture=Se[se].texture}return Y}function ae($,L,Y){return Math.floor(Math.floor($/Y)/L)}function he($,L,Y,be){const se=$.updateRanges;if(se.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,Y,be,L.data);else{se.sort((Je,oe)=>Je.start-oe.start);let Pe=0;for(let Je=1;Je<se.length;Je++){const oe=se[Pe],ye=se[Je],je=oe.start+oe.count,$e=ae(ye.start,L.width,4),ft=ae(oe.start,L.width,4);ye.start<=je+1&&$e===ft&&ae(ye.start+ye.count-1,L.width,4)===$e?oe.count=Math.max(oe.count,ye.start+ye.count-oe.start):(++Pe,se[Pe]=ye)}se.length=Pe+1;const Re=t.getParameter(t.UNPACK_ROW_LENGTH),Xe=t.getParameter(t.UNPACK_SKIP_PIXELS),et=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Je=0,oe=se.length;Je<oe;Je++){const ye=se[Je],je=Math.floor(ye.start/4),$e=Math.ceil(ye.count/4),ft=je%L.width,re=Math.floor(je/L.width),ke=$e,ve=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ft),t.pixelStorei(t.UNPACK_SKIP_ROWS,re),n.texSubImage2D(t.TEXTURE_2D,0,ft,re,ke,ve,Y,be,L.data)}$.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Re),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,et)}}function pe($,L,Y){let be=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(be=t.TEXTURE_3D);const Se=ne($,L),se=L.source;n.bindTexture(be,$.__webglTexture,t.TEXTURE0+Y);const Pe=r.get(se);if(se.version!==Pe.__version||Se===!0){n.activeTexture(t.TEXTURE0+Y);const Re=Vn.getPrimaries(Vn.workingColorSpace),Xe=L.colorSpace===Ed?null:Vn.getPrimaries(L.colorSpace),et=L.colorSpace===Ed||Re===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,et);let Je=y(L.image,!1,i.maxTextureSize);Je=Ie(L,Je);const oe=a.convert(L.format,L.colorSpace),ye=a.convert(L.type);let je=M(L.internalFormat,oe,ye,L.colorSpace,L.isVideoTexture);V(be,L);let $e;const ft=L.mipmaps,re=L.isVideoTexture!==!0,ke=Pe.__version===void 0||Se===!0,ve=se.dataReady,Fe=T(L,Je);if(L.isDepthTexture)je=A(L.format===bf,L.type),ke&&(re?n.texStorage2D(t.TEXTURE_2D,1,je,Je.width,Je.height):n.texImage2D(t.TEXTURE_2D,0,je,Je.width,Je.height,0,oe,ye,null));else if(L.isDataTexture)if(ft.length>0){re&&ke&&n.texStorage2D(t.TEXTURE_2D,Fe,je,ft[0].width,ft[0].height);for(let Ue=0,Te=ft.length;Ue<Te;Ue++)$e=ft[Ue],re?ve&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,$e.width,$e.height,oe,ye,$e.data):n.texImage2D(t.TEXTURE_2D,Ue,je,$e.width,$e.height,0,oe,ye,$e.data);L.generateMipmaps=!1}else re?(ke&&n.texStorage2D(t.TEXTURE_2D,Fe,je,Je.width,Je.height),ve&&he(L,Je,oe,ye)):n.texImage2D(t.TEXTURE_2D,0,je,Je.width,Je.height,0,oe,ye,Je.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){re&&ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Fe,je,ft[0].width,ft[0].height,Je.depth);for(let Ue=0,Te=ft.length;Ue<Te;Ue++)if($e=ft[Ue],L.format!==rl)if(oe!==null)if(re){if(ve)if(L.layerUpdates.size>0){const qe=ZV($e.width,$e.height,L.format,L.type);for(const bt of L.layerUpdates){const Pt=$e.data.subarray(bt*qe/$e.data.BYTES_PER_ELEMENT,(bt+1)*qe/$e.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,bt,$e.width,$e.height,1,oe,Pt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,$e.width,$e.height,Je.depth,oe,$e.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ue,je,$e.width,$e.height,Je.depth,0,$e.data,0,0);else cn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else re?ve&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,$e.width,$e.height,Je.depth,oe,ye,$e.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ue,je,$e.width,$e.height,Je.depth,0,oe,ye,$e.data)}else{re&&ke&&n.texStorage2D(t.TEXTURE_2D,Fe,je,ft[0].width,ft[0].height);for(let Ue=0,Te=ft.length;Ue<Te;Ue++)$e=ft[Ue],L.format!==rl?oe!==null?re?ve&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ue,0,0,$e.width,$e.height,oe,$e.data):n.compressedTexImage2D(t.TEXTURE_2D,Ue,je,$e.width,$e.height,0,$e.data):cn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):re?ve&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,$e.width,$e.height,oe,ye,$e.data):n.texImage2D(t.TEXTURE_2D,Ue,je,$e.width,$e.height,0,oe,ye,$e.data)}else if(L.isDataArrayTexture)if(re){if(ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Fe,je,Je.width,Je.height,Je.depth),ve)if(L.layerUpdates.size>0){const Ue=ZV(Je.width,Je.height,L.format,L.type);for(const Te of L.layerUpdates){const qe=Je.data.subarray(Te*Ue/Je.data.BYTES_PER_ELEMENT,(Te+1)*Ue/Je.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Te,Je.width,Je.height,1,oe,ye,qe)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Je.width,Je.height,Je.depth,oe,ye,Je.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,je,Je.width,Je.height,Je.depth,0,oe,ye,Je.data);else if(L.isData3DTexture)re?(ke&&n.texStorage3D(t.TEXTURE_3D,Fe,je,Je.width,Je.height,Je.depth),ve&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Je.width,Je.height,Je.depth,oe,ye,Je.data)):n.texImage3D(t.TEXTURE_3D,0,je,Je.width,Je.height,Je.depth,0,oe,ye,Je.data);else if(L.isFramebufferTexture){if(ke)if(re)n.texStorage2D(t.TEXTURE_2D,Fe,je,Je.width,Je.height);else{let Ue=Je.width,Te=Je.height;for(let qe=0;qe<Fe;qe++)n.texImage2D(t.TEXTURE_2D,qe,je,Ue,Te,0,oe,ye,null),Ue>>=1,Te>>=1}}else if(ft.length>0){if(re&&ke){const Ue=ce(ft[0]);n.texStorage2D(t.TEXTURE_2D,Fe,je,Ue.width,Ue.height)}for(let Ue=0,Te=ft.length;Ue<Te;Ue++)$e=ft[Ue],re?ve&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,oe,ye,$e):n.texImage2D(t.TEXTURE_2D,Ue,je,oe,ye,$e);L.generateMipmaps=!1}else if(re){if(ke){const Ue=ce(Je);n.texStorage2D(t.TEXTURE_2D,Fe,je,Ue.width,Ue.height)}ve&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe,ye,Je)}else n.texImage2D(t.TEXTURE_2D,0,je,oe,ye,Je);x(L)&&v(be),Pe.__version=se.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function ie($,L,Y){if(L.image.length!==6)return;const be=ne($,L),Se=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+Y);const se=r.get(Se);if(Se.version!==se.__version||be===!0){n.activeTexture(t.TEXTURE0+Y);const Pe=Vn.getPrimaries(Vn.workingColorSpace),Re=L.colorSpace===Ed?null:Vn.getPrimaries(L.colorSpace),Xe=L.colorSpace===Ed||Pe===Re?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const et=L.isCompressedTexture||L.image[0].isCompressedTexture,Je=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let Te=0;Te<6;Te++)!et&&!Je?oe[Te]=y(L.image[Te],!0,i.maxCubemapSize):oe[Te]=Je?L.image[Te].image:L.image[Te],oe[Te]=Ie(L,oe[Te]);const ye=oe[0],je=a.convert(L.format,L.colorSpace),$e=a.convert(L.type),ft=M(L.internalFormat,je,$e,L.colorSpace),re=L.isVideoTexture!==!0,ke=se.__version===void 0||be===!0,ve=Se.dataReady;let Fe=T(L,ye);V(t.TEXTURE_CUBE_MAP,L);let Ue;if(et){re&&ke&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,ft,ye.width,ye.height);for(let Te=0;Te<6;Te++){Ue=oe[Te].mipmaps;for(let qe=0;qe<Ue.length;qe++){const bt=Ue[qe];L.format!==rl?je!==null?re?ve&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,0,0,bt.width,bt.height,je,bt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,ft,bt.width,bt.height,0,bt.data):cn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,0,0,bt.width,bt.height,je,$e,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,ft,bt.width,bt.height,0,je,$e,bt.data)}}}else{if(Ue=L.mipmaps,re&&ke){Ue.length>0&&Fe++;const Te=ce(oe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,ft,Te.width,Te.height)}for(let Te=0;Te<6;Te++)if(Je){re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,oe[Te].width,oe[Te].height,je,$e,oe[Te].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,ft,oe[Te].width,oe[Te].height,0,je,$e,oe[Te].data);for(let qe=0;qe<Ue.length;qe++){const Pt=Ue[qe].image[Te].image;re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,0,0,Pt.width,Pt.height,je,$e,Pt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,ft,Pt.width,Pt.height,0,je,$e,Pt.data)}}else{re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,je,$e,oe[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,ft,je,$e,oe[Te]);for(let qe=0;qe<Ue.length;qe++){const bt=Ue[qe];re?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,0,0,je,$e,bt.image[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,ft,je,$e,bt.image[Te])}}}x(L)&&v(t.TEXTURE_CUBE_MAP),se.__version=Se.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Ee($,L,Y,be,Se,se){const Pe=a.convert(Y.format,Y.colorSpace),Re=a.convert(Y.type),Xe=M(Y.internalFormat,Pe,Re,Y.colorSpace),et=r.get(L),Je=r.get(Y);if(Je.__renderTarget=L,!et.__hasExternalTextures){const oe=Math.max(1,L.width>>se),ye=Math.max(1,L.height>>se);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,se,Xe,oe,ye,L.depth,0,Pe,Re,null):n.texImage2D(Se,se,Xe,oe,ye,0,Pe,Re,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),ue(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,Se,Je.__webglTexture,0,I(L)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,Se,Je.__webglTexture,se),n.bindFramebuffer(t.FRAMEBUFFER,null)}function xe($,L,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer){const be=L.depthTexture,Se=be&&be.isDepthTexture?be.type:null,se=A(L.stencilBuffer,Se),Pe=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;ue(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(L),se,L.width,L.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(L),se,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,se,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Pe,t.RENDERBUFFER,$)}else{const be=L.textures;for(let Se=0;Se<be.length;Se++){const se=be[Se],Pe=a.convert(se.format,se.colorSpace),Re=a.convert(se.type),Xe=M(se.internalFormat,Pe,Re,se.colorSpace);ue(L)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,I(L),Xe,L.width,L.height):Y?t.renderbufferStorageMultisample(t.RENDERBUFFER,I(L),Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ne($,L,Y){const be=L.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Se=r.get(L.depthTexture);if(Se.__renderTarget=L,(!Se.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),be){if(Se.__webglInit===void 0&&(Se.__webglInit=!0,L.depthTexture.addEventListener("dispose",k)),Se.__webglTexture===void 0){Se.__webglTexture=t.createTexture(),n.bindTexture(t.TEXTURE_CUBE_MAP,Se.__webglTexture),V(t.TEXTURE_CUBE_MAP,L.depthTexture);const et=a.convert(L.depthTexture.format),Je=a.convert(L.depthTexture.type);let oe;L.depthTexture.format===wu?oe=t.DEPTH_COMPONENT24:L.depthTexture.format===bf&&(oe=t.DEPTH24_STENCIL8);for(let ye=0;ye<6;ye++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,oe,L.width,L.height,0,et,Je,null)}}else W(L.depthTexture,0);const se=Se.__webglTexture,Pe=I(L),Re=be?t.TEXTURE_CUBE_MAP_POSITIVE_X+Y:t.TEXTURE_2D,Xe=L.depthTexture.format===bf?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(L.depthTexture.format===wu)ue(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Xe,Re,se,0,Pe):t.framebufferTexture2D(t.FRAMEBUFFER,Xe,Re,se,0);else if(L.depthTexture.format===bf)ue(L)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,Xe,Re,se,0,Pe):t.framebufferTexture2D(t.FRAMEBUFFER,Xe,Re,se,0);else throw new Error("Unknown depthTexture format")}function _e($){const L=r.get($),Y=$.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==$.depthTexture){const be=$.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),be){const Se=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,be.removeEventListener("dispose",Se)};be.addEventListener("dispose",Se),L.__depthDisposeCallback=Se}L.__boundDepthTexture=be}if($.depthTexture&&!L.__autoAllocateDepthBuffer)if(Y)for(let be=0;be<6;be++)Ne(L.__webglFramebuffer[be],$,be);else{const be=$.texture.mipmaps;be&&be.length>0?Ne(L.__webglFramebuffer[0],$,0):Ne(L.__webglFramebuffer,$,0)}else if(Y){L.__webglDepthbuffer=[];for(let be=0;be<6;be++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[be]),L.__webglDepthbuffer[be]===void 0)L.__webglDepthbuffer[be]=t.createRenderbuffer(),xe(L.__webglDepthbuffer[be],$,!1);else{const Se=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,se=L.__webglDepthbuffer[be];t.bindRenderbuffer(t.RENDERBUFFER,se),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,se)}}else{const be=$.texture.mipmaps;if(be&&be.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),xe(L.__webglDepthbuffer,$,!1);else{const Se=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,se=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,se),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,se)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function le($,L,Y){const be=r.get($);L!==void 0&&Ee(be.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&_e($)}function Ve($){const L=$.texture,Y=r.get($),be=r.get(L);$.addEventListener("dispose",E);const Se=$.textures,se=$.isWebGLCubeRenderTarget===!0,Pe=Se.length>1;if(Pe||(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=L.version,o.memory.textures++),se){Y.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)if(L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer[Re]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)Y.__webglFramebuffer[Re][Xe]=t.createFramebuffer()}else Y.__webglFramebuffer[Re]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer=[];for(let Re=0;Re<L.mipmaps.length;Re++)Y.__webglFramebuffer[Re]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(Pe)for(let Re=0,Xe=Se.length;Re<Xe;Re++){const et=r.get(Se[Re]);et.__webglTexture===void 0&&(et.__webglTexture=t.createTexture(),o.memory.textures++)}if($.samples>0&&ue($)===!1){Y.__webglMultisampledFramebuffer=t.createFramebuffer(),Y.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let Re=0;Re<Se.length;Re++){const Xe=Se[Re];Y.__webglColorRenderbuffer[Re]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[Re]);const et=a.convert(Xe.format,Xe.colorSpace),Je=a.convert(Xe.type),oe=M(Xe.internalFormat,et,Je,Xe.colorSpace,$.isXRRenderTarget===!0),ye=I($);t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,oe,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Re,t.RENDERBUFFER,Y.__webglColorRenderbuffer[Re])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),xe(Y.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(se){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),V(t.TEXTURE_CUBE_MAP,L);for(let Re=0;Re<6;Re++)if(L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ee(Y.__webglFramebuffer[Re][Xe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,Xe);else Ee(Y.__webglFramebuffer[Re],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0);x(L)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Pe){for(let Re=0,Xe=Se.length;Re<Xe;Re++){const et=Se[Re],Je=r.get(et);let oe=t.TEXTURE_2D;($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(oe=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(oe,Je.__webglTexture),V(oe,et),Ee(Y.__webglFramebuffer,$,et,t.COLOR_ATTACHMENT0+Re,oe,0),x(et)&&v(oe)}n.unbindTexture()}else{let Re=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(Re=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Re,be.__webglTexture),V(Re,L),L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ee(Y.__webglFramebuffer[Xe],$,L,t.COLOR_ATTACHMENT0,Re,Xe);else Ee(Y.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,Re,0);x(L)&&v(Re),n.unbindTexture()}$.depthBuffer&&_e($)}function H($){const L=$.textures;for(let Y=0,be=L.length;Y<be;Y++){const Se=L[Y];if(x(Se)){const se=S($),Pe=r.get(Se).__webglTexture;n.bindTexture(se,Pe),v(se),n.unbindTexture()}}}const ee=[],X=[];function B($){if($.samples>0){if(ue($)===!1){const L=$.textures,Y=$.width,be=$.height;let Se=t.COLOR_BUFFER_BIT;const se=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Pe=r.get($),Re=L.length>1;if(Re)for(let et=0;et<L.length;et++)n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Pe.__webglMultisampledFramebuffer);const Xe=$.texture.mipmaps;Xe&&Xe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Pe.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Pe.__webglFramebuffer);for(let et=0;et<L.length;et++){if($.resolveDepthBuffer&&($.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&$.resolveStencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Re){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Pe.__webglColorRenderbuffer[et]);const Je=r.get(L[et]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Je,0)}t.blitFramebuffer(0,0,Y,be,0,0,Y,be,Se,t.NEAREST),c===!0&&(ee.length=0,X.length=0,ee.push(t.COLOR_ATTACHMENT0+et),$.depthBuffer&&$.resolveDepthBuffer===!1&&(ee.push(se),X.push(se),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),Re)for(let et=0;et<L.length;et++){n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,Pe.__webglColorRenderbuffer[et]);const Je=r.get(L[et]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Pe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,Je,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Pe.__webglMultisampledFramebuffer)}else if($.depthBuffer&&$.resolveDepthBuffer===!1&&c){const L=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function I($){return Math.min(i.maxSamples,$.samples)}function ue($){const L=r.get($);return $.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ae($){const L=o.render.frame;d.get($)!==L&&(d.set($,L),$.update())}function Ie($,L){const Y=$.colorSpace,be=$.format,Se=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||Y!==kg&&Y!==Ed&&(Vn.getTransfer(Y)===sr?(be!==rl||Se!==Hs)&&cn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Kn("WebGLTextures: Unsupported texture color space:",Y)),L}function ce($){return typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement?(u.width=$.naturalWidth||$.width,u.height=$.naturalHeight||$.height):typeof VideoFrame<"u"&&$ instanceof VideoFrame?(u.width=$.displayWidth,u.height=$.displayHeight):(u.width=$.width,u.height=$.height),u}this.allocateTextureUnit=q,this.resetTextureUnits=O,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=Q,this.rebindTextures=le,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=B,this.setupDepthRenderbuffer=_e,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=ue,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function uIe(t,e){function n(r,i=Ed){let a;const o=Vn.getTransfer(i);if(r===Hs)return t.UNSIGNED_BYTE;if(r===J4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===eL)return t.UNSIGNED_SHORT_5_5_5_1;if(r===aee)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===see)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===ree)return t.BYTE;if(r===iee)return t.SHORT;if(r===X0)return t.UNSIGNED_SHORT;if(r===Q4)return t.INT;if(r===rc)return t.UNSIGNED_INT;if(r===$l)return t.FLOAT;if(r===_u)return t.HALF_FLOAT;if(r===oee)return t.ALPHA;if(r===lee)return t.RGB;if(r===rl)return t.RGBA;if(r===wu)return t.DEPTH_COMPONENT;if(r===bf)return t.DEPTH_STENCIL;if(r===cee)return t.RED;if(r===tL)return t.RED_INTEGER;if(r===Cg)return t.RG;if(r===nL)return t.RG_INTEGER;if(r===rL)return t.RGBA_INTEGER;if(r===h1||r===f1||r===m1||r===p1)if(o===sr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===h1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===f1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===m1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===p1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===h1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===f1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===m1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===p1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===z3||r===B3||r===$3||r===H3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===z3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===B3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===$3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===H3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===V3||r===G3||r===W3||r===q3||r===K3||r===X3||r===Y3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===V3||r===G3)return o===sr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===W3)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC;if(r===q3)return a.COMPRESSED_R11_EAC;if(r===K3)return a.COMPRESSED_SIGNED_R11_EAC;if(r===X3)return a.COMPRESSED_RG11_EAC;if(r===Y3)return a.COMPRESSED_SIGNED_RG11_EAC}else return null;if(r===Z3||r===Q3||r===J3||r===eR||r===tR||r===nR||r===rR||r===iR||r===aR||r===sR||r===oR||r===lR||r===cR||r===uR)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===Z3)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Q3)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===J3)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===eR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===tR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===nR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===rR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===iR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===aR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===sR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===oR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===lR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===cR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===uR)return o===sr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===dR||r===hR||r===fR)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===dR)return o===sr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===hR)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===fR)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===mR||r===pR||r===gR||r===xR)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===mR)return a.COMPRESSED_RED_RGTC1_EXT;if(r===pR)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===gR)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===xR)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Y0?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 Cee(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,r=new ic({vertexShader:dIe,fragmentShader:hIe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new hl(new dL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let mIe=class extends mm{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 Mn;let D=null;const C=new So;C.viewport=new Ni;const R=new So;R.viewport=new Ni;const U=[C,R],O=new wRe;let q=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pe){let ie=T[pe];return ie===void 0&&(ie=new gk,T[pe]=ie),ie.getTargetRaySpace()},this.getControllerGrip=function(pe){let ie=T[pe];return ie===void 0&&(ie=new gk,T[pe]=ie),ie.getGripSpace()},this.getHand=function(pe){let ie=T[pe];return ie===void 0&&(ie=new gk,T[pe]=ie),ie.getHandSpace()};function W(pe){const ie=k.indexOf(pe.inputSource);if(ie===-1)return;const Ee=T[ie];Ee!==void 0&&(Ee.update(pe.inputSource,pe.frame,u||o),Ee.dispatchEvent({type:pe.type,data:pe.inputSource}))}function K(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",G);for(let pe=0;pe<T.length;pe++){const ie=k[pe];ie!==null&&(k[pe]=null,T[pe].disconnect(ie))}q=null,j=null,x.reset();for(const pe in v)delete v[pe];e.setRenderTarget(M),p=null,m=null,f=null,i=null,A=null,he.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pe){a=pe,r.isPresenting===!0&&cn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pe){l=pe,r.isPresenting===!0&&cn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(pe){u=pe},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(pe){if(i=pe,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",G),S.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(E),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ee=null,xe=null,Ne=null;S.depth&&(Ne=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ee=S.stencil?bf:wu,xe=S.stencil?Y0:rc);const _e={colorFormat:n.RGBA8,depthFormat:Ne,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(_e),i.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),A=new Kl(m.textureWidth,m.textureHeight,{format:rl,type:Hs,depthTexture:new Q0(m.textureWidth,m.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,Ee),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const Ee={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,Ee),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new Kl(p.framebufferWidth,p.framebufferHeight,{format:rl,type:Hs,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),he.setContext(i),he.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function G(pe){for(let ie=0;ie<pe.removed.length;ie++){const Ee=pe.removed[ie],xe=k.indexOf(Ee);xe>=0&&(k[xe]=null,T[xe].disconnect(Ee))}for(let ie=0;ie<pe.added.length;ie++){const Ee=pe.added[ie];let xe=k.indexOf(Ee);if(xe===-1){for(let _e=0;_e<T.length;_e++)if(_e>=k.length){k.push(Ee),xe=_e;break}else if(k[_e]===null){k[_e]=Ee,xe=_e;break}if(xe===-1)break}const Ne=T[xe];Ne&&Ne.connect(Ee)}}const Q=new nt,te=new nt;function J(pe,ie,Ee){Q.setFromMatrixPosition(ie.matrixWorld),te.setFromMatrixPosition(Ee.matrixWorld);const xe=Q.distanceTo(te),Ne=ie.projectionMatrix.elements,_e=Ee.projectionMatrix.elements,le=Ne[14]/(Ne[10]-1),Ve=Ne[14]/(Ne[10]+1),H=(Ne[9]+1)/Ne[5],ee=(Ne[9]-1)/Ne[5],X=(Ne[8]-1)/Ne[0],B=(_e[8]+1)/_e[0],I=le*X,ue=le*B,Ae=xe/(-X+B),Ie=Ae*-X;if(ie.matrixWorld.decompose(pe.position,pe.quaternion,pe.scale),pe.translateX(Ie),pe.translateZ(Ae),pe.matrixWorld.compose(pe.position,pe.quaternion,pe.scale),pe.matrixWorldInverse.copy(pe.matrixWorld).invert(),Ne[10]===-1)pe.projectionMatrix.copy(ie.projectionMatrix),pe.projectionMatrixInverse.copy(ie.projectionMatrixInverse);else{const ce=le+Ae,$=Ve+Ae,L=I-Ie,Y=ue+(xe-Ie),be=H*Ve/$*ce,Se=ee*Ve/$*ce;pe.projectionMatrix.makePerspective(L,Y,be,Se,ce,$),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert()}}function z(pe,ie){ie===null?pe.matrixWorld.copy(pe.matrix):pe.matrixWorld.multiplyMatrices(ie.matrixWorld,pe.matrix),pe.matrixWorldInverse.copy(pe.matrixWorld).invert()}this.updateCamera=function(pe){if(i===null)return;let ie=pe.near,Ee=pe.far;x.texture!==null&&(x.depthNear>0&&(ie=x.depthNear),x.depthFar>0&&(Ee=x.depthFar)),O.near=R.near=C.near=ie,O.far=R.far=C.far=Ee,(q!==O.near||j!==O.far)&&(i.updateRenderState({depthNear:O.near,depthFar:O.far}),q=O.near,j=O.far),O.layers.mask=pe.layers.mask|6,C.layers.mask=O.layers.mask&3,R.layers.mask=O.layers.mask&5;const xe=pe.parent,Ne=O.cameras;z(O,xe);for(let _e=0;_e<Ne.length;_e++)z(Ne[_e],xe);Ne.length===2?J(O,C,R):O.projectionMatrix.copy(C.projectionMatrix),V(pe,O,xe)};function V(pe,ie,Ee){Ee===null?pe.matrix.copy(ie.matrixWorld):(pe.matrix.copy(Ee.matrixWorld),pe.matrix.invert(),pe.matrix.multiply(ie.matrixWorld)),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.updateMatrixWorld(!0),pe.projectionMatrix.copy(ie.projectionMatrix),pe.projectionMatrixInverse.copy(ie.projectionMatrixInverse),pe.isPerspectiveCamera&&(pe.fov=bR*2*Math.atan(1/pe.projectionMatrix.elements[5]),pe.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(m===null&&p===null))return c},this.setFoveation=function(pe){c=pe,m!==null&&(m.fixedFoveation=pe),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=pe)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(O)},this.getCameraTexture=function(pe){return v[pe]};let ne=null;function ae(pe,ie){if(d=ie.getViewerPose(u||o),b=ie,d!==null){const Ee=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let xe=!1;Ee.length!==O.cameras.length&&(O.cameras.length=0,xe=!0);for(let Ve=0;Ve<Ee.length;Ve++){const H=Ee[Ve];let ee=null;if(p!==null)ee=p.getViewport(H);else{const B=f.getViewSubImage(m,H);ee=B.viewport,Ve===0&&(e.setRenderTargetTextures(A,B.colorTexture,B.depthStencilTexture),e.setRenderTarget(A))}let X=U[Ve];X===void 0&&(X=new So,X.layers.enable(Ve),X.viewport=new Ni,U[Ve]=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),Ve===0&&(O.matrix.copy(X.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),xe===!0&&O.cameras.push(X)}const Ne=i.enabledFeatures;if(Ne&&Ne.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const Ve=f.getDepthInformation(Ee[0]);Ve&&Ve.isValid&&Ve.texture&&x.init(Ve,i.renderState)}if(Ne&&Ne.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let Ve=0;Ve<Ee.length;Ve++){const H=Ee[Ve].camera;if(H){let ee=v[H];ee||(ee=new Cee,v[H]=ee);const X=f.getCameraImage(H);ee.sourceTexture=X}}}}for(let Ee=0;Ee<T.length;Ee++){const xe=k[Ee],Ne=T[Ee];xe!==null&&Ne!==void 0&&Ne.update(xe,ie,u||o)}ne&&ne(pe,ie),ie.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ie}),b=null}const he=new Pee;he.setAnimationLoop(ae),this.setAnimationLoop=function(pe){ne=pe},this.dispose=function(){}}};const Vh=new rh,pIe=new pi;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,Mee(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===ws&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===ws&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v),M=S.envMap,A=S.envMapRotation;M&&(x.envMap.value=M,Vh.copy(A),Vh.x*=-1,Vh.y*=-1,Vh.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Vh.y*=-1,Vh.z*=-1),x.envMapRotation.value.setFromMatrix4(pIe.makeRotationFromEuler(Vh)),x.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap&&(x.lightMap.value=v.lightMap,x.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,x.lightMapTransform)),v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,M){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=M*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function f(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function m(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),v.envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function p(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ws&&x.clearcoatNormalScale.value.negate())),v.dispersion>0&&(x.dispersion.value=v.dispersion),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function 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 Kn("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 D=Array.isArray(A[k])?A[k]:[A[k]];for(let C=0,R=D.length;C<R;C++){const U=D[C];if(p(U,k,C,T)===!0){const O=U.__offset,q=Array.isArray(U.value)?U.value:[U.value];let j=0;for(let W=0;W<q.length;W++){const K=q[W],G=y(K);typeof K=="number"||typeof K=="boolean"?(U.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,O+j,U.__data)):K.isMatrix3?(U.__data[0]=K.elements[0],U.__data[1]=K.elements[1],U.__data[2]=K.elements[2],U.__data[3]=0,U.__data[4]=K.elements[3],U.__data[5]=K.elements[4],U.__data[6]=K.elements[5],U.__data[7]=0,U.__data[8]=K.elements[6],U.__data[9]=K.elements[7],U.__data[10]=K.elements[8],U.__data[11]=0):(K.toArray(U.__data,j),j+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,O,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 D=T[E];if(typeof k=="number"||typeof k=="boolean"){if(D!==k)return T[E]=k,!0}else if(D.equals(k)===!1)return D.copy(k),!0}return!1}function b(S){const M=S.uniforms;let A=0;const T=16;for(let E=0,D=M.length;E<D;E++){const C=Array.isArray(M[E])?M[E]:[M[E]];for(let R=0,U=C.length;R<U;R++){const O=C[R],q=Array.isArray(O.value)?O.value:[O.value];for(let j=0,W=q.length;j<W;j++){const K=q[j],G=y(K),Q=A%T,te=Q%G.boundary,J=Q+te;A+=te,J!==0&&T-J<G.storage&&(A+=T-J),O.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),O.__offset=A,A+=G.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?cn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):cn("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 Tl=null;function yIe(){return Tl===null&&(Tl=new lRe(bIe,16,16,Cg,_u),Tl.name="DFG_LUT",Tl.minFilter=za,Tl.magFilter=za,Tl.wrapS=eu,Tl.wrapT=eu,Tl.generateMipmaps=!1,Tl.needsUpdate=!0),Tl}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=Hs}=e;this.isWebGLRenderer=!0;let b;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");b=r.getContextAttributes().alpha}else b=o;const y=p,x=new Set([rL,nL,tL]),v=new Set([Hs,rc,X0,Y0,J4,eL]),S=new Uint32Array(4),M=new Int32Array(4);let A=null,T=null;const k=[],E=[];let D=null;this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=ql,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let R=!1;this._outputColorSpace=vo;let U=0,O=0,q=null,j=-1,W=null;const K=new Ni,G=new Ni;let Q=null;const te=new Pn(0);let J=0,z=n.width,V=n.height,ne=1,ae=null,he=null;const pe=new Ni(0,0,z,V),ie=new Ni(0,0,z,V);let Ee=!1;const xe=new uL;let Ne=!1,_e=!1;const le=new pi,Ve=new nt,H=new Ni,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 ue(de,De){return n.getContext(de,De)}try{const de={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${Y4}`),n.addEventListener("webglcontextlost",bt,!1),n.addEventListener("webglcontextrestored",Pt,!1),n.addEventListener("webglcontextcreationerror",Ot,!1),I===null){const De="webgl2";if(I=ue(De,de),I===null)throw ue(De)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(de){throw Kn("WebGLRenderer: "+de.message),de}let Ae,Ie,ce,$,L,Y,be,Se,se,Pe,Re,Xe,et,Je,oe,ye,je,$e,ft,re,ke,ve,Fe,Ue;function Te(){Ae=new y4e(I),Ae.init(),ve=new uIe(I,Ae),Ie=new u4e(I,Ae,e,ve),ce=new lIe(I,Ae),Ie.reversedDepthBuffer&&m&&ce.buffers.depth.setReversed(!0),$=new w4e(I),L=new qLe,Y=new cIe(I,Ae,ce,L,Ie,ve,$),be=new h4e(C),Se=new b4e(C),se=new ERe(I),Fe=new l4e(I,se),Pe=new v4e(I,se,$,Fe),Re=new M4e(I,Pe,se,$),ft=new S4e(I,Ie,Y),ye=new d4e(L),Xe=new WLe(C,be,Se,Ae,Ie,Fe,ye),et=new gIe(C,L),Je=new XLe,oe=new tIe(Ae),$e=new o4e(C,be,Se,ce,Re,b,c),je=new sIe(C,Re,Ie),Ue=new xIe(I,$,Ie,ce),re=new c4e(I,Ae,$),ke=new _4e(I,Ae,$),$.programs=Xe.programs,C.capabilities=Ie,C.extensions=Ae,C.properties=L,C.renderLists=Je,C.shadowMap=je,C.state=ce,C.info=$}Te(),y!==Hs&&(D=new E4e(y,n.width,n.height,i,a));const qe=new mIe(C,I);this.xr=qe,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const de=Ae.get("WEBGL_lose_context");de&&de.loseContext()},this.forceContextRestore=function(){const de=Ae.get("WEBGL_lose_context");de&&de.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(de){de!==void 0&&(ne=de,this.setSize(z,V,!1))},this.getSize=function(de){return de.set(z,V)},this.setSize=function(de,De,We=!0){if(qe.isPresenting){cn("WebGLRenderer: Can't change size while VR device is presenting.");return}z=de,V=De,n.width=Math.floor(de*ne),n.height=Math.floor(De*ne),We===!0&&(n.style.width=de+"px",n.style.height=De+"px"),D!==null&&D.setSize(n.width,n.height),this.setViewport(0,0,de,De)},this.getDrawingBufferSize=function(de){return de.set(z*ne,V*ne).floor()},this.setDrawingBufferSize=function(de,De,We){z=de,V=De,ne=We,n.width=Math.floor(de*We),n.height=Math.floor(De*We),this.setViewport(0,0,de,De)},this.setEffects=function(de){if(y===Hs){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(de){for(let De=0;De<de.length;De++)if(de[De].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}D.setEffects(de||[])},this.getCurrentViewport=function(de){return de.copy(K)},this.getViewport=function(de){return de.copy(pe)},this.setViewport=function(de,De,We,Ze){de.isVector4?pe.set(de.x,de.y,de.z,de.w):pe.set(de,De,We,Ze),ce.viewport(K.copy(pe).multiplyScalar(ne).round())},this.getScissor=function(de){return de.copy(ie)},this.setScissor=function(de,De,We,Ze){de.isVector4?ie.set(de.x,de.y,de.z,de.w):ie.set(de,De,We,Ze),ce.scissor(G.copy(ie).multiplyScalar(ne).round())},this.getScissorTest=function(){return Ee},this.setScissorTest=function(de){ce.setScissorTest(Ee=de)},this.setOpaqueSort=function(de){ae=de},this.setTransparentSort=function(de){he=de},this.getClearColor=function(de){return de.copy($e.getClearColor())},this.setClearColor=function(){$e.setClearColor(...arguments)},this.getClearAlpha=function(){return $e.getClearAlpha()},this.setClearAlpha=function(){$e.setClearAlpha(...arguments)},this.clear=function(de=!0,De=!0,We=!0){let Ze=0;if(de){let Ge=!1;if(q!==null){const lt=q.texture.format;Ge=x.has(lt)}if(Ge){const lt=q.texture.type,kt=v.has(lt),wt=$e.getClearColor(),_t=$e.getClearAlpha(),Ut=wt.r,Le=wt.g,pt=wt.b;kt?(S[0]=Ut,S[1]=Le,S[2]=pt,S[3]=_t,I.clearBufferuiv(I.COLOR,0,S)):(M[0]=Ut,M[1]=Le,M[2]=pt,M[3]=_t,I.clearBufferiv(I.COLOR,0,M))}else Ze|=I.COLOR_BUFFER_BIT}De&&(Ze|=I.DEPTH_BUFFER_BIT),We&&(Ze|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(Ze)},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",bt,!1),n.removeEventListener("webglcontextrestored",Pt,!1),n.removeEventListener("webglcontextcreationerror",Ot,!1),$e.dispose(),Je.dispose(),oe.dispose(),L.dispose(),be.dispose(),Se.dispose(),Re.dispose(),Fe.dispose(),Ue.dispose(),Xe.dispose(),qe.dispose(),qe.removeEventListener("sessionstart",Et),qe.removeEventListener("sessionend",Ln),Nr.stop()};function bt(de){de.preventDefault(),EV("WebGLRenderer: Context Lost."),R=!0}function Pt(){EV("WebGLRenderer: Context Restored."),R=!1;const de=$.autoReset,De=je.enabled,We=je.autoUpdate,Ze=je.needsUpdate,Ge=je.type;Te(),$.autoReset=de,je.enabled=De,je.autoUpdate=We,je.needsUpdate=Ze,je.type=Ge}function Ot(de){Kn("WebGLRenderer: A WebGL context could not be created. Reason: ",de.statusMessage)}function ln(de){const De=de.target;De.removeEventListener("dispose",ln),Gt(De)}function Gt(de){vn(de),L.remove(de)}function vn(de){const De=L.get(de).programs;De!==void 0&&(De.forEach(function(We){Xe.releaseProgram(We)}),de.isShaderMaterial&&Xe.releaseShaderCache(de))}this.renderBufferDirect=function(de,De,We,Ze,Ge,lt){De===null&&(De=ee);const kt=Ge.isMesh&&Ge.matrixWorld.determinant()<0,wt=ct(de,De,We,Ze,Ge);ce.setMaterial(Ze,kt);let _t=We.index,Ut=1;if(Ze.wireframe===!0){if(_t=Pe.getWireframeAttribute(We),_t===void 0)return;Ut=2}const Le=We.drawRange,pt=We.attributes.position;let me=Le.start*Ut,He=(Le.start+Le.count)*Ut;lt!==null&&(me=Math.max(me,lt.start*Ut),He=Math.min(He,(lt.start+lt.count)*Ut)),_t!==null?(me=Math.max(me,0),He=Math.min(He,_t.count)):pt!=null&&(me=Math.max(me,0),He=Math.min(He,pt.count));const Lt=He-me;if(Lt<0||Lt===1/0)return;Fe.setup(Ge,Ze,wt,We,_t);let jt,Wt=re;if(_t!==null&&(jt=se.get(_t),Wt=ke,Wt.setIndex(jt)),Ge.isMesh)Ze.wireframe===!0?(ce.setLineWidth(Ze.wireframeLinewidth*B()),Wt.setMode(I.LINES)):Wt.setMode(I.TRIANGLES);else if(Ge.isLine){let Rt=Ze.linewidth;Rt===void 0&&(Rt=1),ce.setLineWidth(Rt*B()),Ge.isLineSegments?Wt.setMode(I.LINES):Ge.isLineLoop?Wt.setMode(I.LINE_LOOP):Wt.setMode(I.LINE_STRIP)}else Ge.isPoints?Wt.setMode(I.POINTS):Ge.isSprite&&Wt.setMode(I.TRIANGLES);if(Ge.isBatchedMesh)if(Ge._multiDrawInstances!==null)Z0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Wt.renderMultiDrawInstances(Ge._multiDrawStarts,Ge._multiDrawCounts,Ge._multiDrawCount,Ge._multiDrawInstances);else if(Ae.get("WEBGL_multi_draw"))Wt.renderMultiDraw(Ge._multiDrawStarts,Ge._multiDrawCounts,Ge._multiDrawCount);else{const Rt=Ge._multiDrawStarts,Bt=Ge._multiDrawCounts,At=Ge._multiDrawCount,nn=_t?se.get(_t).bytesPerElement:1,Zr=L.get(Ze).currentProgram.getUniforms();for(let Lr=0;Lr<At;Lr++)Zr.setValue(I,"_gl_DrawID",Lr),Wt.render(Rt[Lr]/nn,Bt[Lr])}else if(Ge.isInstancedMesh)Wt.renderInstances(me,Lt,Ge.count);else if(We.isInstancedBufferGeometry){const Rt=We._maxInstanceCount!==void 0?We._maxInstanceCount:1/0,Bt=Math.min(We.instanceCount,Rt);Wt.renderInstances(me,Lt,Bt)}else Wt.render(me,Lt)};function gt(de,De,We){de.transparent===!0&&de.side===Il&&de.forceSinglePass===!1?(de.side=ws,de.needsUpdate=!0,we(de,De,We),de.side=nh,de.needsUpdate=!0,we(de,De,We),de.side=Il):we(de,De,We)}this.compile=function(de,De,We=null){We===null&&(We=de),T=oe.get(We),T.init(De),E.push(T),We.traverseVisible(function(Ge){Ge.isLight&&Ge.layers.test(De.layers)&&(T.pushLight(Ge),Ge.castShadow&&T.pushShadow(Ge))}),de!==We&&de.traverseVisible(function(Ge){Ge.isLight&&Ge.layers.test(De.layers)&&(T.pushLight(Ge),Ge.castShadow&&T.pushShadow(Ge))}),T.setupLights();const Ze=new Set;return de.traverse(function(Ge){if(!(Ge.isMesh||Ge.isPoints||Ge.isLine||Ge.isSprite))return;const lt=Ge.material;if(lt)if(Array.isArray(lt))for(let kt=0;kt<lt.length;kt++){const wt=lt[kt];gt(wt,We,Ge),Ze.add(wt)}else gt(lt,We,Ge),Ze.add(lt)}),T=E.pop(),Ze},this.compileAsync=function(de,De,We=null){const Ze=this.compile(de,De,We);return new Promise(Ge=>{function lt(){if(Ze.forEach(function(kt){L.get(kt).currentProgram.isReady()&&Ze.delete(kt)}),Ze.size===0){Ge(de);return}setTimeout(lt,10)}Ae.get("KHR_parallel_shader_compile")!==null?lt():setTimeout(lt,10)})};let Kt=null;function pn(de){Kt&&Kt(de)}function Et(){Nr.stop()}function Ln(){Nr.start()}const Nr=new Pee;Nr.setAnimationLoop(pn),typeof self<"u"&&Nr.setContext(self),this.setAnimationLoop=function(de){Kt=de,qe.setAnimationLoop(de),de===null?Nr.stop():Nr.start()},qe.addEventListener("sessionstart",Et),qe.addEventListener("sessionend",Ln),this.render=function(de,De){if(De!==void 0&&De.isCamera!==!0){Kn("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;const We=qe.enabled===!0&&qe.isPresenting===!0,Ze=D!==null&&(q===null||We)&&D.begin(C,q);if(de.matrixWorldAutoUpdate===!0&&de.updateMatrixWorld(),De.parent===null&&De.matrixWorldAutoUpdate===!0&&De.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(D===null||D.isCompositing()===!1)&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(De),De=qe.getCamera()),de.isScene===!0&&de.onBeforeRender(C,de,De,q),T=oe.get(de,E.length),T.init(De),E.push(T),le.multiplyMatrices(De.projectionMatrix,De.matrixWorldInverse),xe.setFromProjectionMatrix(le,Hl,De.reversedDepth),_e=this.localClippingEnabled,Ne=ye.init(this.clippingPlanes,_e),A=Je.get(de,k.length),A.init(),k.push(A),qe.enabled===!0&&qe.isPresenting===!0){const kt=C.xr.getDepthSensingMesh();kt!==null&&Or(kt,De,-1/0,C.sortObjects)}Or(de,De,0,C.sortObjects),A.finish(),C.sortObjects===!0&&A.sort(ae,he),X=qe.enabled===!1||qe.isPresenting===!1||qe.hasDepthSensing()===!1,X&&$e.addToRenderList(A,de),this.info.render.frame++,Ne===!0&&ye.beginShadows();const Ge=T.state.shadowsArray;if(je.render(Ge,de,De),Ne===!0&&ye.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Ze&&D.hasRenderPass())===!1){const kt=A.opaque,wt=A.transmissive;if(T.setupLights(),De.isArrayCamera){const _t=De.cameras;if(wt.length>0)for(let Ut=0,Le=_t.length;Ut<Le;Ut++){const pt=_t[Ut];yr(kt,wt,de,pt)}X&&$e.render(de);for(let Ut=0,Le=_t.length;Ut<Le;Ut++){const pt=_t[Ut];tn(A,de,pt,pt.viewport)}}else wt.length>0&&yr(kt,wt,de,De),X&&$e.render(de),tn(A,de,De)}q!==null&&O===0&&(Y.updateMultisampleRenderTarget(q),Y.updateRenderTargetMipmap(q)),Ze&&D.end(C),de.isScene===!0&&de.onAfterRender(C,de,De),Fe.resetDefaultState(),j=-1,W=null,E.pop(),E.length>0?(T=E[E.length-1],Ne===!0&&ye.setGlobalState(C.clippingPlanes,T.state.camera)):T=null,k.pop(),k.length>0?A=k[k.length-1]:A=null};function Or(de,De,We,Ze){if(de.visible===!1)return;if(de.layers.test(De.layers)){if(de.isGroup)We=de.renderOrder;else if(de.isLOD)de.autoUpdate===!0&&de.update(De);else if(de.isLight)T.pushLight(de),de.castShadow&&T.pushShadow(de);else if(de.isSprite){if(!de.frustumCulled||xe.intersectsSprite(de)){Ze&&H.setFromMatrixPosition(de.matrixWorld).applyMatrix4(le);const kt=Re.update(de),wt=de.material;wt.visible&&A.push(de,kt,wt,We,H.z,null)}}else if((de.isMesh||de.isLine||de.isPoints)&&(!de.frustumCulled||xe.intersectsObject(de))){const kt=Re.update(de),wt=de.material;if(Ze&&(de.boundingSphere!==void 0?(de.boundingSphere===null&&de.computeBoundingSphere(),H.copy(de.boundingSphere.center)):(kt.boundingSphere===null&&kt.computeBoundingSphere(),H.copy(kt.boundingSphere.center)),H.applyMatrix4(de.matrixWorld).applyMatrix4(le)),Array.isArray(wt)){const _t=kt.groups;for(let Ut=0,Le=_t.length;Ut<Le;Ut++){const pt=_t[Ut],me=wt[pt.materialIndex];me&&me.visible&&A.push(de,kt,me,We,H.z,pt)}}else wt.visible&&A.push(de,kt,wt,We,H.z,null)}}const lt=de.children;for(let kt=0,wt=lt.length;kt<wt;kt++)Or(lt[kt],De,We,Ze)}function tn(de,De,We,Ze){const{opaque:Ge,transmissive:lt,transparent:kt}=de;T.setupLightsView(We),Ne===!0&&ye.setGlobalState(C.clippingPlanes,We),Ze&&ce.viewport(K.copy(Ze)),Ge.length>0&&xi(Ge,De,We),lt.length>0&&xi(lt,De,We),kt.length>0&&xi(kt,De,We),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function yr(de,De,We,Ze){if((We.isScene===!0?We.overrideMaterial:null)!==null)return;if(T.state.transmissionRenderTarget[Ze.id]===void 0){const me=Ae.has("EXT_color_buffer_half_float")||Ae.has("EXT_color_buffer_float");T.state.transmissionRenderTarget[Ze.id]=new Kl(1,1,{generateMipmaps:!0,type:me?_u:Hs,minFilter:xf,samples:Ie.samples,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Vn.workingColorSpace})}const lt=T.state.transmissionRenderTarget[Ze.id],kt=Ze.viewport||K;lt.setSize(kt.z*C.transmissionResolutionScale,kt.w*C.transmissionResolutionScale);const wt=C.getRenderTarget(),_t=C.getActiveCubeFace(),Ut=C.getActiveMipmapLevel();C.setRenderTarget(lt),C.getClearColor(te),J=C.getClearAlpha(),J<1&&C.setClearColor(16777215,.5),C.clear(),X&&$e.render(We);const Le=C.toneMapping;C.toneMapping=ql;const pt=Ze.viewport;if(Ze.viewport!==void 0&&(Ze.viewport=void 0),T.setupLightsView(Ze),Ne===!0&&ye.setGlobalState(C.clippingPlanes,Ze),xi(de,We,Ze),Y.updateMultisampleRenderTarget(lt),Y.updateRenderTargetMipmap(lt),Ae.has("WEBGL_multisampled_render_to_texture")===!1){let me=!1;for(let He=0,Lt=De.length;He<Lt;He++){const jt=De[He],{object:Wt,geometry:Rt,material:Bt,group:At}=jt;if(Bt.side===Il&&Wt.layers.test(Ze.layers)){const nn=Bt.side;Bt.side=ws,Bt.needsUpdate=!0,lr(Wt,We,Ze,Rt,Bt,At),Bt.side=nn,Bt.needsUpdate=!0,me=!0}}me===!0&&(Y.updateMultisampleRenderTarget(lt),Y.updateRenderTargetMipmap(lt))}C.setRenderTarget(wt,_t,Ut),C.setClearColor(te,J),pt!==void 0&&(Ze.viewport=pt),C.toneMapping=Le}function xi(de,De,We){const Ze=De.isScene===!0?De.overrideMaterial:null;for(let Ge=0,lt=de.length;Ge<lt;Ge++){const kt=de[Ge],{object:wt,geometry:_t,group:Ut}=kt;let Le=kt.material;Le.allowOverride===!0&&Ze!==null&&(Le=Ze),wt.layers.test(We.layers)&&lr(wt,De,We,_t,Le,Ut)}}function lr(de,De,We,Ze,Ge,lt){de.onBeforeRender(C,De,We,Ze,Ge,lt),de.modelViewMatrix.multiplyMatrices(We.matrixWorldInverse,de.matrixWorld),de.normalMatrix.getNormalMatrix(de.modelViewMatrix),Ge.onBeforeRender(C,De,We,Ze,de,lt),Ge.transparent===!0&&Ge.side===Il&&Ge.forceSinglePass===!1?(Ge.side=ws,Ge.needsUpdate=!0,C.renderBufferDirect(We,De,Ze,Ge,de,lt),Ge.side=nh,Ge.needsUpdate=!0,C.renderBufferDirect(We,De,Ze,Ge,de,lt),Ge.side=Il):C.renderBufferDirect(We,De,Ze,Ge,de,lt),de.onAfterRender(C,De,We,Ze,Ge,lt)}function we(de,De,We){De.isScene!==!0&&(De=ee);const Ze=L.get(de),Ge=T.state.lights,lt=T.state.shadowsArray,kt=Ge.state.version,wt=Xe.getParameters(de,Ge.state,lt,De,We),_t=Xe.getProgramCacheKey(wt);let Ut=Ze.programs;Ze.environment=de.isMeshStandardMaterial?De.environment:null,Ze.fog=De.fog,Ze.envMap=(de.isMeshStandardMaterial?Se:be).get(de.envMap||Ze.environment),Ze.envMapRotation=Ze.environment!==null&&de.envMap===null?De.environmentRotation:de.envMapRotation,Ut===void 0&&(de.addEventListener("dispose",ln),Ut=new Map,Ze.programs=Ut);let Le=Ut.get(_t);if(Le!==void 0){if(Ze.currentProgram===Le&&Ze.lightsStateVersion===kt)return at(de,wt),Le}else wt.uniforms=Xe.getUniforms(de),de.onBeforeCompile(wt,C),Le=Xe.acquireProgram(wt,_t),Ut.set(_t,Le),Ze.uniforms=wt.uniforms;const pt=Ze.uniforms;return(!de.isShaderMaterial&&!de.isRawShaderMaterial||de.clipping===!0)&&(pt.clippingPlanes=ye.uniform),at(de,wt),Ze.needsLights=Ct(de),Ze.lightsStateVersion=kt,Ze.needsLights&&(pt.ambientLightColor.value=Ge.state.ambient,pt.lightProbe.value=Ge.state.probe,pt.directionalLights.value=Ge.state.directional,pt.directionalLightShadows.value=Ge.state.directionalShadow,pt.spotLights.value=Ge.state.spot,pt.spotLightShadows.value=Ge.state.spotShadow,pt.rectAreaLights.value=Ge.state.rectArea,pt.ltc_1.value=Ge.state.rectAreaLTC1,pt.ltc_2.value=Ge.state.rectAreaLTC2,pt.pointLights.value=Ge.state.point,pt.pointLightShadows.value=Ge.state.pointShadow,pt.hemisphereLights.value=Ge.state.hemi,pt.directionalShadowMap.value=Ge.state.directionalShadowMap,pt.directionalShadowMatrix.value=Ge.state.directionalShadowMatrix,pt.spotShadowMap.value=Ge.state.spotShadowMap,pt.spotLightMatrix.value=Ge.state.spotLightMatrix,pt.spotLightMap.value=Ge.state.spotLightMap,pt.pointShadowMap.value=Ge.state.pointShadowMap,pt.pointShadowMatrix.value=Ge.state.pointShadowMatrix),Ze.currentProgram=Le,Ze.uniformsList=null,Le}function Ye(de){if(de.uniformsList===null){const De=de.currentProgram.getUniforms();de.uniformsList=y1.seqWithValue(De.seq,de.uniforms)}return de.uniformsList}function at(de,De){const We=L.get(de);We.outputColorSpace=De.outputColorSpace,We.batching=De.batching,We.batchingColor=De.batchingColor,We.instancing=De.instancing,We.instancingColor=De.instancingColor,We.instancingMorph=De.instancingMorph,We.skinning=De.skinning,We.morphTargets=De.morphTargets,We.morphNormals=De.morphNormals,We.morphColors=De.morphColors,We.morphTargetsCount=De.morphTargetsCount,We.numClippingPlanes=De.numClippingPlanes,We.numIntersection=De.numClipIntersection,We.vertexAlphas=De.vertexAlphas,We.vertexTangents=De.vertexTangents,We.toneMapping=De.toneMapping}function ct(de,De,We,Ze,Ge){De.isScene!==!0&&(De=ee),Y.resetTextureUnits();const lt=De.fog,kt=Ze.isMeshStandardMaterial?De.environment:null,wt=q===null?C.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:kg,_t=(Ze.isMeshStandardMaterial?Se:be).get(Ze.envMap||kt),Ut=Ze.vertexColors===!0&&!!We.attributes.color&&We.attributes.color.itemSize===4,Le=!!We.attributes.tangent&&(!!Ze.normalMap||Ze.anisotropy>0),pt=!!We.morphAttributes.position,me=!!We.morphAttributes.normal,He=!!We.morphAttributes.color;let Lt=ql;Ze.toneMapped&&(q===null||q.isXRRenderTarget===!0)&&(Lt=C.toneMapping);const jt=We.morphAttributes.position||We.morphAttributes.normal||We.morphAttributes.color,Wt=jt!==void 0?jt.length:0,Rt=L.get(Ze),Bt=T.state.lights;if(Ne===!0&&(_e===!0||de!==W)){const Zn=de===W&&Ze.id===j;ye.setState(Ze,de,Zn)}let At=!1;Ze.version===Rt.__version?(Rt.needsLights&&Rt.lightsStateVersion!==Bt.state.version||Rt.outputColorSpace!==wt||Ge.isBatchedMesh&&Rt.batching===!1||!Ge.isBatchedMesh&&Rt.batching===!0||Ge.isBatchedMesh&&Rt.batchingColor===!0&&Ge.colorTexture===null||Ge.isBatchedMesh&&Rt.batchingColor===!1&&Ge.colorTexture!==null||Ge.isInstancedMesh&&Rt.instancing===!1||!Ge.isInstancedMesh&&Rt.instancing===!0||Ge.isSkinnedMesh&&Rt.skinning===!1||!Ge.isSkinnedMesh&&Rt.skinning===!0||Ge.isInstancedMesh&&Rt.instancingColor===!0&&Ge.instanceColor===null||Ge.isInstancedMesh&&Rt.instancingColor===!1&&Ge.instanceColor!==null||Ge.isInstancedMesh&&Rt.instancingMorph===!0&&Ge.morphTexture===null||Ge.isInstancedMesh&&Rt.instancingMorph===!1&&Ge.morphTexture!==null||Rt.envMap!==_t||Ze.fog===!0&&Rt.fog!==lt||Rt.numClippingPlanes!==void 0&&(Rt.numClippingPlanes!==ye.numPlanes||Rt.numIntersection!==ye.numIntersection)||Rt.vertexAlphas!==Ut||Rt.vertexTangents!==Le||Rt.morphTargets!==pt||Rt.morphNormals!==me||Rt.morphColors!==He||Rt.toneMapping!==Lt||Rt.morphTargetsCount!==Wt)&&(At=!0):(At=!0,Rt.__version=Ze.version);let nn=Rt.currentProgram;At===!0&&(nn=we(Ze,De,Ge));let Zr=!1,Lr=!1,ca=!1;const $n=nn.getUniforms(),di=Rt.uniforms;if(ce.useProgram(nn.program)&&(Zr=!0,Lr=!0,ca=!0),Ze.id!==j&&(j=Ze.id,Lr=!0),Zr||W!==de){ce.buffers.depth.getReversed()&&de.reversedDepth!==!0&&(de._reversedDepth=!0,de.updateProjectionMatrix()),$n.setValue(I,"projectionMatrix",de.projectionMatrix),$n.setValue(I,"viewMatrix",de.matrixWorldInverse);const Tr=$n.map.cameraPosition;Tr!==void 0&&Tr.setValue(I,Ve.setFromMatrixPosition(de.matrixWorld)),Ie.logarithmicDepthBuffer&&$n.setValue(I,"logDepthBufFC",2/(Math.log(de.far+1)/Math.LN2)),(Ze.isMeshPhongMaterial||Ze.isMeshToonMaterial||Ze.isMeshLambertMaterial||Ze.isMeshBasicMaterial||Ze.isMeshStandardMaterial||Ze.isShaderMaterial)&&$n.setValue(I,"isOrthographic",de.isOrthographicCamera===!0),W!==de&&(W=de,Lr=!0,ca=!0)}if(Rt.needsLights&&(Bt.state.directionalShadowMap.length>0&&$n.setValue(I,"directionalShadowMap",Bt.state.directionalShadowMap,Y),Bt.state.spotShadowMap.length>0&&$n.setValue(I,"spotShadowMap",Bt.state.spotShadowMap,Y),Bt.state.pointShadowMap.length>0&&$n.setValue(I,"pointShadowMap",Bt.state.pointShadowMap,Y)),Ge.isSkinnedMesh){$n.setOptional(I,Ge,"bindMatrix"),$n.setOptional(I,Ge,"bindMatrixInverse");const Zn=Ge.skeleton;Zn&&(Zn.boneTexture===null&&Zn.computeBoneTexture(),$n.setValue(I,"boneTexture",Zn.boneTexture,Y))}Ge.isBatchedMesh&&($n.setOptional(I,Ge,"batchingTexture"),$n.setValue(I,"batchingTexture",Ge._matricesTexture,Y),$n.setOptional(I,Ge,"batchingIdTexture"),$n.setValue(I,"batchingIdTexture",Ge._indirectTexture,Y),$n.setOptional(I,Ge,"batchingColorTexture"),Ge._colorsTexture!==null&&$n.setValue(I,"batchingColorTexture",Ge._colorsTexture,Y));const vr=We.morphAttributes;if((vr.position!==void 0||vr.normal!==void 0||vr.color!==void 0)&&ft.update(Ge,We,nn),(Lr||Rt.receiveShadow!==Ge.receiveShadow)&&(Rt.receiveShadow=Ge.receiveShadow,$n.setValue(I,"receiveShadow",Ge.receiveShadow)),Ze.isMeshGouraudMaterial&&Ze.envMap!==null&&(di.envMap.value=_t,di.flipEnvMap.value=_t.isCubeTexture&&_t.isRenderTargetTexture===!1?-1:1),Ze.isMeshStandardMaterial&&Ze.envMap===null&&De.environment!==null&&(di.envMapIntensity.value=De.environmentIntensity),di.dfgLUT!==void 0&&(di.dfgLUT.value=yIe()),Lr&&($n.setValue(I,"toneMappingExposure",C.toneMappingExposure),Rt.needsLights&&st(di,ca),lt&&Ze.fog===!0&&et.refreshFogUniforms(di,lt),et.refreshMaterialUniforms(di,Ze,ne,V,T.state.transmissionRenderTarget[de.id]),y1.upload(I,Ye(Rt),di,Y)),Ze.isShaderMaterial&&Ze.uniformsNeedUpdate===!0&&(y1.upload(I,Ye(Rt),di,Y),Ze.uniformsNeedUpdate=!1),Ze.isSpriteMaterial&&$n.setValue(I,"center",Ge.center),$n.setValue(I,"modelViewMatrix",Ge.modelViewMatrix),$n.setValue(I,"normalMatrix",Ge.normalMatrix),$n.setValue(I,"modelMatrix",Ge.matrixWorld),Ze.isShaderMaterial||Ze.isRawShaderMaterial){const Zn=Ze.uniformsGroups;for(let Tr=0,to=Zn.length;Tr<to;Tr++){const Cr=Zn[Tr];Ue.update(Cr,nn),Ue.bind(Cr,nn)}}return nn}function st(de,De){de.ambientLightColor.needsUpdate=De,de.lightProbe.needsUpdate=De,de.directionalLights.needsUpdate=De,de.directionalLightShadows.needsUpdate=De,de.pointLights.needsUpdate=De,de.pointLightShadows.needsUpdate=De,de.spotLights.needsUpdate=De,de.spotLightShadows.needsUpdate=De,de.rectAreaLights.needsUpdate=De,de.hemisphereLights.needsUpdate=De}function Ct(de){return de.isMeshLambertMaterial||de.isMeshToonMaterial||de.isMeshPhongMaterial||de.isMeshStandardMaterial||de.isShadowMaterial||de.isShaderMaterial&&de.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return O},this.getRenderTarget=function(){return q},this.setRenderTargetTextures=function(de,De,We){const Ze=L.get(de);Ze.__autoAllocateDepthBuffer=de.resolveDepthBuffer===!1,Ze.__autoAllocateDepthBuffer===!1&&(Ze.__useRenderToTexture=!1),L.get(de.texture).__webglTexture=De,L.get(de.depthTexture).__webglTexture=Ze.__autoAllocateDepthBuffer?void 0:We,Ze.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(de,De){const We=L.get(de);We.__webglFramebuffer=De,We.__useDefaultFramebuffer=De===void 0};const Ft=I.createFramebuffer();this.setRenderTarget=function(de,De=0,We=0){q=de,U=De,O=We;let Ze=null,Ge=!1,lt=!1;if(de){const wt=L.get(de);if(wt.__useDefaultFramebuffer!==void 0){ce.bindFramebuffer(I.FRAMEBUFFER,wt.__webglFramebuffer),K.copy(de.viewport),G.copy(de.scissor),Q=de.scissorTest,ce.viewport(K),ce.scissor(G),ce.setScissorTest(Q),j=-1;return}else if(wt.__webglFramebuffer===void 0)Y.setupRenderTarget(de);else if(wt.__hasExternalTextures)Y.rebindTextures(de,L.get(de.texture).__webglTexture,L.get(de.depthTexture).__webglTexture);else if(de.depthBuffer){const Le=de.depthTexture;if(wt.__boundDepthTexture!==Le){if(Le!==null&&L.has(Le)&&(de.width!==Le.image.width||de.height!==Le.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(de)}}const _t=de.texture;(_t.isData3DTexture||_t.isDataArrayTexture||_t.isCompressedArrayTexture)&&(lt=!0);const Ut=L.get(de).__webglFramebuffer;de.isWebGLCubeRenderTarget?(Array.isArray(Ut[De])?Ze=Ut[De][We]:Ze=Ut[De],Ge=!0):de.samples>0&&Y.useMultisampledRTT(de)===!1?Ze=L.get(de).__webglMultisampledFramebuffer:Array.isArray(Ut)?Ze=Ut[We]:Ze=Ut,K.copy(de.viewport),G.copy(de.scissor),Q=de.scissorTest}else K.copy(pe).multiplyScalar(ne).floor(),G.copy(ie).multiplyScalar(ne).floor(),Q=Ee;if(We!==0&&(Ze=Ft),ce.bindFramebuffer(I.FRAMEBUFFER,Ze)&&ce.drawBuffers(de,Ze),ce.viewport(K),ce.scissor(G),ce.setScissorTest(Q),Ge){const wt=L.get(de.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+De,wt.__webglTexture,We)}else if(lt){const wt=De;for(let _t=0;_t<de.textures.length;_t++){const Ut=L.get(de.textures[_t]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+_t,Ut.__webglTexture,We,wt)}}else if(de!==null&&We!==0){const wt=L.get(de.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,wt.__webglTexture,We)}j=-1},this.readRenderTargetPixels=function(de,De,We,Ze,Ge,lt,kt,wt=0){if(!(de&&de.isWebGLRenderTarget)){Kn("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _t=L.get(de).__webglFramebuffer;if(de.isWebGLCubeRenderTarget&&kt!==void 0&&(_t=_t[kt]),_t){ce.bindFramebuffer(I.FRAMEBUFFER,_t);try{const Ut=de.textures[wt],Le=Ut.format,pt=Ut.type;if(!Ie.textureFormatReadable(Le)){Kn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Ie.textureTypeReadable(pt)){Kn("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}De>=0&&De<=de.width-Ze&&We>=0&&We<=de.height-Ge&&(de.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+wt),I.readPixels(De,We,Ze,Ge,ve.convert(Le),ve.convert(pt),lt))}finally{const Ut=q!==null?L.get(q).__webglFramebuffer:null;ce.bindFramebuffer(I.FRAMEBUFFER,Ut)}}},this.readRenderTargetPixelsAsync=async function(de,De,We,Ze,Ge,lt,kt,wt=0){if(!(de&&de.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let _t=L.get(de).__webglFramebuffer;if(de.isWebGLCubeRenderTarget&&kt!==void 0&&(_t=_t[kt]),_t)if(De>=0&&De<=de.width-Ze&&We>=0&&We<=de.height-Ge){ce.bindFramebuffer(I.FRAMEBUFFER,_t);const Ut=de.textures[wt],Le=Ut.format,pt=Ut.type;if(!Ie.textureFormatReadable(Le))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Ie.textureTypeReadable(pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const me=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,me),I.bufferData(I.PIXEL_PACK_BUFFER,lt.byteLength,I.STREAM_READ),de.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+wt),I.readPixels(De,We,Ze,Ge,ve.convert(Le),ve.convert(pt),0);const He=q!==null?L.get(q).__webglFramebuffer:null;ce.bindFramebuffer(I.FRAMEBUFFER,He);const Lt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await O3e(I,Lt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,me),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,lt),I.deleteBuffer(me),I.deleteSync(Lt),lt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(de,De=null,We=0){const Ze=Math.pow(2,-We),Ge=Math.floor(de.image.width*Ze),lt=Math.floor(de.image.height*Ze),kt=De!==null?De.x:0,wt=De!==null?De.y:0;Y.setTexture2D(de,0),I.copyTexSubImage2D(I.TEXTURE_2D,We,0,0,kt,wt,Ge,lt),ce.unbindTexture()};const Yt=I.createFramebuffer(),Zt=I.createFramebuffer();this.copyTextureToTexture=function(de,De,We=null,Ze=null,Ge=0,lt=null){lt===null&&(Ge!==0?(Z0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),lt=Ge,Ge=0):lt=0);let kt,wt,_t,Ut,Le,pt,me,He,Lt;const jt=de.isCompressedTexture?de.mipmaps[lt]:de.image;if(We!==null)kt=We.max.x-We.min.x,wt=We.max.y-We.min.y,_t=We.isBox3?We.max.z-We.min.z:1,Ut=We.min.x,Le=We.min.y,pt=We.isBox3?We.min.z:0;else{const vr=Math.pow(2,-Ge);kt=Math.floor(jt.width*vr),wt=Math.floor(jt.height*vr),de.isDataArrayTexture?_t=jt.depth:de.isData3DTexture?_t=Math.floor(jt.depth*vr):_t=1,Ut=0,Le=0,pt=0}Ze!==null?(me=Ze.x,He=Ze.y,Lt=Ze.z):(me=0,He=0,Lt=0);const Wt=ve.convert(De.format),Rt=ve.convert(De.type);let Bt;De.isData3DTexture?(Y.setTexture3D(De,0),Bt=I.TEXTURE_3D):De.isDataArrayTexture||De.isCompressedArrayTexture?(Y.setTexture2DArray(De,0),Bt=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(De,0),Bt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,De.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,De.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,De.unpackAlignment);const At=I.getParameter(I.UNPACK_ROW_LENGTH),nn=I.getParameter(I.UNPACK_IMAGE_HEIGHT),Zr=I.getParameter(I.UNPACK_SKIP_PIXELS),Lr=I.getParameter(I.UNPACK_SKIP_ROWS),ca=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,jt.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,jt.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Ut),I.pixelStorei(I.UNPACK_SKIP_ROWS,Le),I.pixelStorei(I.UNPACK_SKIP_IMAGES,pt);const $n=de.isDataArrayTexture||de.isData3DTexture,di=De.isDataArrayTexture||De.isData3DTexture;if(de.isDepthTexture){const vr=L.get(de),Zn=L.get(De),Tr=L.get(vr.__renderTarget),to=L.get(Zn.__renderTarget);ce.bindFramebuffer(I.READ_FRAMEBUFFER,Tr.__webglFramebuffer),ce.bindFramebuffer(I.DRAW_FRAMEBUFFER,to.__webglFramebuffer);for(let Cr=0;Cr<_t;Cr++)$n&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,L.get(de).__webglTexture,Ge,pt+Cr),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,L.get(De).__webglTexture,lt,Lt+Cr)),I.blitFramebuffer(Ut,Le,kt,wt,me,He,kt,wt,I.DEPTH_BUFFER_BIT,I.NEAREST);ce.bindFramebuffer(I.READ_FRAMEBUFFER,null),ce.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(Ge!==0||de.isRenderTargetTexture||L.has(de)){const vr=L.get(de),Zn=L.get(De);ce.bindFramebuffer(I.READ_FRAMEBUFFER,Yt),ce.bindFramebuffer(I.DRAW_FRAMEBUFFER,Zt);for(let Tr=0;Tr<_t;Tr++)$n?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,vr.__webglTexture,Ge,pt+Tr):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,vr.__webglTexture,Ge),di?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Zn.__webglTexture,lt,Lt+Tr):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Zn.__webglTexture,lt),Ge!==0?I.blitFramebuffer(Ut,Le,kt,wt,me,He,kt,wt,I.COLOR_BUFFER_BIT,I.NEAREST):di?I.copyTexSubImage3D(Bt,lt,me,He,Lt+Tr,Ut,Le,kt,wt):I.copyTexSubImage2D(Bt,lt,me,He,Ut,Le,kt,wt);ce.bindFramebuffer(I.READ_FRAMEBUFFER,null),ce.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else di?de.isDataTexture||de.isData3DTexture?I.texSubImage3D(Bt,lt,me,He,Lt,kt,wt,_t,Wt,Rt,jt.data):De.isCompressedArrayTexture?I.compressedTexSubImage3D(Bt,lt,me,He,Lt,kt,wt,_t,Wt,jt.data):I.texSubImage3D(Bt,lt,me,He,Lt,kt,wt,_t,Wt,Rt,jt):de.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,lt,me,He,kt,wt,Wt,Rt,jt.data):de.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,lt,me,He,jt.width,jt.height,Wt,jt.data):I.texSubImage2D(I.TEXTURE_2D,lt,me,He,kt,wt,Wt,Rt,jt);I.pixelStorei(I.UNPACK_ROW_LENGTH,At),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,nn),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Zr),I.pixelStorei(I.UNPACK_SKIP_ROWS,Lr),I.pixelStorei(I.UNPACK_SKIP_IMAGES,ca),lt===0&&De.generateMipmaps&&I.generateMipmap(Bt),ce.unbindTexture()},this.initRenderTarget=function(de){L.get(de).__webglFramebuffer===void 0&&Y.setupRenderTarget(de)},this.initTexture=function(de){de.isCubeTexture?Y.setTextureCube(de,0):de.isData3DTexture?Y.setTexture3D(de,0):de.isDataArrayTexture||de.isCompressedArrayTexture?Y.setTexture2DArray(de,0):Y.setTexture2D(de,0),ce.unbindTexture()},this.resetState=function(){U=0,O=0,q=null,ce.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Hl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Vn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Vn._getUnpackColorSpace()}};const _G={type:"change"},fL={type:"start"},Iee={type:"end"},rw=new oL,wG=new yd,_Ie=Math.cos(70*I3e.DEG2RAD),ji=new nt,ps=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},Ek=1e-6;class wIe extends MRe{constructor(e,n=null){super(e,n),this.state=pr.NONE,this.target=new nt,this.cursor=new nt,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:sg.ROTATE,MIDDLE:sg.DOLLY,RIGHT:sg.PAN},this.touches={ONE:Zp.ROTATE,TWO:Zp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new nt,this._lastQuaternion=new tm,this._lastTargetPosition=new nt,this._quat=new tm().setFromUnitVectors(e.up,new nt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new YV,this._sphericalDelta=new YV,this._scale=1,this._panOffset=new nt,this._rotateStart=new Mn,this._rotateEnd=new Mn,this._rotateDelta=new Mn,this._panStart=new Mn,this._panEnd=new Mn,this._panDelta=new Mn,this._dollyStart=new Mn,this._dollyEnd=new Mn,this._dollyDelta=new Mn,this._dollyDirection=new nt,this._mouse=new Mn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=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(_G),this.update(),this.state=pr.NONE}update(e=null){const n=this.object.position;ji.copy(n).sub(this.target),ji.applyQuaternion(this._quat),this._spherical.setFromVector3(ji),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+=ps:r>Math.PI&&(r-=ps),i<-Math.PI?i+=ps:i>Math.PI&&(i-=ps),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(ji.setFromSpherical(this._spherical),ji.applyQuaternion(this._quatInverse),n.copy(this.target).add(ji),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=ji.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new nt(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new nt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=ji.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):(rw.origin.copy(this.object.position),rw.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(rw.direction))<_Ie?this.object.lookAt(this.target):(wG.setFromNormalAndCoplanarPoint(this.object.up,this.target),rw.intersectPlane(wG,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Ek||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ek||this._lastTargetPosition.distanceToSquared(this.target)>Ek?(this.dispatchEvent(_G),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ps/60*this.autoRotateSpeed*e:ps/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){ji.setFromMatrixColumn(n,0),ji.multiplyScalar(-e),this._panOffset.add(ji)}_panUp(e,n){this.screenSpacePanning===!0?ji.setFromMatrixColumn(n,1):(ji.setFromMatrixColumn(n,0),ji.crossVectors(this.object.up,ji)),ji.multiplyScalar(e),this._panOffset.add(ji)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ji.copy(i).sub(this.target);let a=ji.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(ps*this._rotateDelta.x/n.clientHeight),this._rotateUp(ps*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(ps*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-ps*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(ps*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-ps*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(ps*this._rotateDelta.x/n.clientHeight),this._rotateUp(ps*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new Mn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function 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(Iee),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 sg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=pr.DOLLY;break;case sg.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 sg.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(fL)}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(fL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(Iee))}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 Zp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=pr.TOUCH_ROTATE;break;case Zp.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 Zp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=pr.TOUCH_DOLLY_PAN;break;case Zp.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(fL)}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 yl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let m=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),m++}if(m!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let m=0;m<t.length;++m){const p=t[m].index;for(let b=0;b<p.count;++b)f.push(p.getX(b)+d);d+=t[m].attributes.position.count}c.setIndex(f)}for(const d in a){const f=SG(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let m=0;m<f;++m){const p=[];for(let y=0;y<o[d].length;++y)p.push(o[d][y][m]);const b=SG(p);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(b)}}return c}function SG(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const o=new e(a),l=new Co(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let m=0,p=d.count;m<p;m++)for(let b=0;b<n;b++){const y=d.getComponent(m,b);l.setComponent(m+f,b,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function iw(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ak={exports:{}};var MG;function LIe(){return MG||(MG=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof iw=="function"&&iw;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 iw=="function"&&iw,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,D=l.transformTo("string",S(T.name)),C=l.transformTo("string",u.utf8encode(T.name)),R=T.comment,U=l.transformTo("string",S(R)),O=l.transformTo("string",u.utf8encode(R)),q=C.length!==T.name.length,j=O.length!==R.length,W="",K="",G="",Q=T.dir,te=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&&!j||(z|=2048);var V=0,ne=0;Q&&(V|=16),v==="UNIX"?(ne=798,V|=(function(he,pe){var ie=he;return he||(ie=pe?16893:33204),(65535&ie)<<16})(T.unixPermissions,Q)):(ne=20,V|=(function(he){return 63&(he||0)})(T.dosPermissions)),M=te.getUTCHours(),M<<=6,M|=te.getUTCMinutes(),M<<=5,M|=te.getUTCSeconds()/2,A=te.getUTCFullYear()-1980,A<<=4,A|=te.getUTCMonth()+1,A<<=5,A|=te.getUTCDate(),q&&(K=a(1,1)+a(d(D),4)+C,W+="up"+a(K.length,2)+K),j&&(G=a(1,1)+a(d(U),4)+O,W+="uc"+a(G.length,2)+G);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(D.length,2),ae+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ae+D+W,dirRecord:f.CENTRAL_FILE_HEADER+a(ne,2)+ae+a(U.length,2)+"\0\0\0\0"+a(V,4)+a(x,4)+D+W+U}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function m(p,b,y,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=y,this.encodeFileName=x,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(p){var b=p.meta.percent||0,y=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:y?(b+100*(y-x-1))/y:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var b=this.streamFiles&&!p.file.dir;if(b){var y=o(p,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var b=this.streamFiles&&!p.file.dir,y=o(p,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),b)this.push({data:(function(x){return f.DATA_DESCRIPTOR+a(x.crc32,4)+a(x.compressedSize,4)+a(x.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var y=this.bytesWritten-p,x=(function(v,S,M,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 D,C=l.getTypeOf(k),R=l.extend(E||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(T=v(T)),R.createFolders&&(D=x(T))&&S.call(this,D,!0);var U=C==="string"&&R.binary===!1&&R.base64===!1;E&&E.binary!==void 0||(R.binary=!U),(k instanceof f&&k.uncompressedSize===0||R.dir||!k||k.length===0)&&(R.base64=!1,R.binary=!0,k="",R.compression="STORE",C="string");var O=null;O=k instanceof f||k instanceof c?k:b.isNode&&b.isStream(k)?new y(T,k):l.prepareContent(T,k,R.binary,R.optimizedBinaryString,R.base64);var q=new m(T,O,R);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,D;for(k in this.files)D=this.files[k],(E=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&T(E,D)},filter:function(T){var k=[];return this.forEach(function(E,D){T(E,D)&&k.push(D)}),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 D=T;return this.filter(function(R,U){return!U.dir&&D.test(R)})}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,R){return R.dir&&T.test(C)});var k=this.root+T,E=S.call(this,k),D=this.clone();return D.root=E.name,D},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,R){return R.name.slice(0,T.length)===T}),D=0;D<E.length;D++)delete this.files[E[D].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(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 D=E.comment||this.comment||"";k=p.generateWorker(this,E,D)}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,D,C){switch(E){case"blob":return a.newBlob(a.transformTo("arraybuffer",D),C);case"base64":return c.encode(D);default:return a.transformTo(E,D)}})(A,(function(E,D){var C,R=0,U=null,O=0;for(C=0;C<D.length;C++)O+=D[C].length;switch(E){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(U=new Uint8Array(O),C=0;C<D.length;C++)U.set(D[C],R),R+=D[C].length;return U;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+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(D){T(D.target.result)},E.onerror=function(D){k(D.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 f_<"u"?f_: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,D=new this(o);++E<M;)C(v[E],E);return D;function C(R,U){S.resolve(R).then(function(O){T[U]=O,++k!==M||A||(A=!0,l.resolve(D,T))},function(O){A||(A=!0,l.reject(D,O))})}},f.race=function(v){var S=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var M=v.length,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(D){A||(A=!0,l.resolve(k,D))},function(D){A||(A=!0,l.reject(k,D))});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,D=this.options.chunkSize,C=this.options.dictionary,R=!1;if(this.ended)return!1;S=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?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(D),E.next_out=0,E.avail_out=D),(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&&R===!0&&(v=c.Z_OK,R=!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=D-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&&(R=!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,D=15,C=3,R=258,U=R+C+1,O=42,q=113,j=1,W=2,K=3,G=4;function Q(H,ee){return H.msg=d[ee],ee}function te(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 V(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 he(H,ee){var X,B,I=H.max_chain_length,ue=H.strstart,Ae=H.prev_length,Ie=H.nice_match,ce=H.strstart>H.w_size-U?H.strstart-(H.w_size-U):0,$=H.window,L=H.w_mask,Y=H.prev,be=H.strstart+R,Se=$[ue+Ae-1],se=$[ue+Ae];H.prev_length>=H.good_match&&(I>>=2),Ie>H.lookahead&&(Ie=H.lookahead);do if($[(X=ee)+Ae]===se&&$[X+Ae-1]===Se&&$[X]===$[ue]&&$[++X]===$[ue+1]){ue+=2,X++;do;while($[++ue]===$[++X]&&$[++ue]===$[++X]&&$[++ue]===$[++X]&&$[++ue]===$[++X]&&$[++ue]===$[++X]&&$[++ue]===$[++X]&&$[++ue]===$[++X]&&$[++ue]===$[++X]&&ue<be);if(B=R-(be-ue),ue=be-R,Ae<B){if(H.match_start=ee,Ie<=(Ae=B))break;Se=$[ue+Ae-1],se=$[ue+Ae]}}while((ee=Y[ee&L])>ce&&--I!=0);return Ae<=H.lookahead?Ae:H.lookahead}function pe(H){var ee,X,B,I,ue,Ae,Ie,ce,$,L,Y=H.w_size;do{if(I=H.window_size-H.lookahead-H.strstart,H.strstart>=Y+(Y-U)){for(o.arraySet(H.window,H.window,Y,Y,0),H.match_start-=Y,H.strstart-=Y,H.block_start-=Y,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(Ae=H.strm,Ie=H.window,ce=H.strstart+H.lookahead,$=I,L=void 0,L=Ae.avail_in,$<L&&(L=$),X=L===0?0:(Ae.avail_in-=L,o.arraySet(Ie,Ae.input,Ae.next_in,L,ce),Ae.state.wrap===1?Ae.adler=c(Ae.adler,Ie,L,ce):Ae.state.wrap===2&&(Ae.adler=u(Ae.adler,Ie,L,ce)),Ae.next_in+=L,Ae.total_in+=L,L),H.lookahead+=X,H.lookahead+H.insert>=C)for(ue=H.strstart-H.insert,H.ins_h=H.window[ue],H.ins_h=(H.ins_h<<H.hash_shift^H.window[ue+1])&H.hash_mask;H.insert&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[ue+C-1])&H.hash_mask,H.prev[ue&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=ue,ue++,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(pe(H),H.lookahead<U&&ee===f)return j;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=he(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&&(V(H,!1),H.strm.avail_out===0))return j}return H.insert=H.strstart<C-1?H.strstart:C-1,ee===m?(V(H,!0),H.strm.avail_out===0?K:G):H.last_lit&&(V(H,!1),H.strm.avail_out===0)?j:W}function Ee(H,ee){for(var X,B,I;;){if(H.lookahead<U){if(pe(H),H.lookahead<U&&ee===f)return j;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=he(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&&(V(H,!1),H.strm.avail_out===0))return j}else if(H.match_available){if((B=l._tr_tally(H,0,H.window[H.strstart-1]))&&V(H,!1),H.strstart++,H.lookahead--,H.strm.avail_out===0)return j}else H.match_available=1,H.strstart++,H.lookahead--}return H.match_available&&(B=l._tr_tally(H,0,H.window[H.strstart-1]),H.match_available=0),H.insert=H.strstart<C-1?H.strstart:C-1,ee===m?(V(H,!0),H.strm.avail_out===0?K:G):H.last_lit&&(V(H,!1),H.strm.avail_out===0)?j:W}function xe(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(D+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 _e(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?O: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=_e(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 Ve(H,ee,X,B,I,ue){if(!H)return b;var Ae=1;if(ee===y&&(ee=6),B<0?(Ae=0,B=-B):15<B&&(Ae=2,B-=16),I<1||M<I||X!==S||B<8||15<B||ee<0||9<ee||ue<0||x<ue)return Q(H,b);B===8&&(B=9);var Ie=new Ne;return(H.state=Ie).strm=H,Ie.wrap=Ae,Ie.gzhead=null,Ie.w_bits=B,Ie.w_size=1<<Ie.w_bits,Ie.w_mask=Ie.w_size-1,Ie.hash_bits=I+7,Ie.hash_size=1<<Ie.hash_bits,Ie.hash_mask=Ie.hash_size-1,Ie.hash_shift=~~((Ie.hash_bits+C-1)/C),Ie.window=new o.Buf8(2*Ie.w_size),Ie.head=new o.Buf16(Ie.hash_size),Ie.prev=new o.Buf16(Ie.w_size),Ie.lit_bufsize=1<<I+6,Ie.pending_buf_size=4*Ie.lit_bufsize,Ie.pending_buf=new o.Buf8(Ie.pending_buf_size),Ie.d_buf=1*Ie.lit_bufsize,Ie.l_buf=3*Ie.lit_bufsize,Ie.level=ee,Ie.strategy=ue,Ie.method=X,le(H)}a=[new xe(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(pe(H),H.lookahead===0&&ee===f)return j;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,V(H,!1),H.strm.avail_out===0)||H.strstart-H.block_start>=H.w_size-U&&(V(H,!1),H.strm.avail_out===0))return j}return H.insert=0,ee===m?(V(H,!0),H.strm.avail_out===0?K:G):(H.strstart>H.block_start&&(V(H,!1),H.strm.avail_out),j)}),new xe(4,4,8,4,ie),new xe(4,5,16,8,ie),new xe(4,6,32,32,ie),new xe(4,4,16,16,Ee),new xe(8,16,32,32,Ee),new xe(8,16,128,128,Ee),new xe(8,32,128,256,Ee),new xe(32,128,258,1024,Ee),new xe(32,258,258,4096,Ee)],i.deflateInit=function(H,ee){return Ve(H,ee,S,15,8,0)},i.deflateInit2=Ve,i.deflateReset=le,i.deflateResetKeep=_e,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,ue;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===O)if(B.wrap===2)H.adler=0,ne(B,31),ne(B,139),ne(B,8),B.gzhead?(ne(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),ne(B,255&B.gzhead.time),ne(B,B.gzhead.time>>8&255),ne(B,B.gzhead.time>>16&255),ne(B,B.gzhead.time>>24&255),ne(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ne(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ne(B,255&B.gzhead.extra.length),ne(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(H.adler=u(H.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ne(B,0),ne(B,0),ne(B,0),ne(B,0),ne(B,0),ne(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ne(B,3),B.status=q);else{var Ae=S+(B.w_bits-8<<4)<<8;Ae|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Ae|=32),Ae+=31-Ae%31,B.status=q,ae(B,Ae),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)){ue=1;break}ue=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,ne(B,ue)}while(ue!==0);B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),ue===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)){ue=1;break}ue=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,ne(B,ue)}while(ue!==0);B.gzhead.hcrc&&B.pending>I&&(H.adler=u(H.adler,B.pending_buf,B.pending-I,I)),ue===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&z(H),B.pending+2<=B.pending_buf_size&&(ne(B,255&H.adler),ne(B,H.adler>>8&255),H.adler=0,B.status=q)):B.status=q),B.pending!==0){if(z(H),H.avail_out===0)return B.last_flush=-1,p}else if(H.avail_in===0&&te(ee)<=te(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 Ie=B.strategy===2?(function(ce,$){for(var L;;){if(ce.lookahead===0&&(pe(ce),ce.lookahead===0)){if($===f)return j;break}if(ce.match_length=0,L=l._tr_tally(ce,0,ce.window[ce.strstart]),ce.lookahead--,ce.strstart++,L&&(V(ce,!1),ce.strm.avail_out===0))return j}return ce.insert=0,$===m?(V(ce,!0),ce.strm.avail_out===0?K:G):ce.last_lit&&(V(ce,!1),ce.strm.avail_out===0)?j:W})(B,ee):B.strategy===3?(function(ce,$){for(var L,Y,be,Se,se=ce.window;;){if(ce.lookahead<=R){if(pe(ce),ce.lookahead<=R&&$===f)return j;if(ce.lookahead===0)break}if(ce.match_length=0,ce.lookahead>=C&&0<ce.strstart&&(Y=se[be=ce.strstart-1])===se[++be]&&Y===se[++be]&&Y===se[++be]){Se=ce.strstart+R;do;while(Y===se[++be]&&Y===se[++be]&&Y===se[++be]&&Y===se[++be]&&Y===se[++be]&&Y===se[++be]&&Y===se[++be]&&Y===se[++be]&&be<Se);ce.match_length=R-(Se-be),ce.match_length>ce.lookahead&&(ce.match_length=ce.lookahead)}if(ce.match_length>=C?(L=l._tr_tally(ce,1,ce.match_length-C),ce.lookahead-=ce.match_length,ce.strstart+=ce.match_length,ce.match_length=0):(L=l._tr_tally(ce,0,ce.window[ce.strstart]),ce.lookahead--,ce.strstart++),L&&(V(ce,!1),ce.strm.avail_out===0))return j}return ce.insert=0,$===m?(V(ce,!0),ce.strm.avail_out===0?K:G):ce.last_lit&&(V(ce,!1),ce.strm.avail_out===0)?j:W})(B,ee):a[B.level].func(B,ee);if(Ie!==K&&Ie!==G||(B.status=666),Ie===j||Ie===K)return H.avail_out===0&&(B.last_flush=-1),p;if(Ie===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)!==O&&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,ue,Ae,Ie,ce,$,L=ee.length;if(!H||!H.state||(ue=(X=H.state).wrap)===2||ue===1&&X.status!==O||X.lookahead)return b;for(ue===1&&(H.adler=c(H.adler,ee,L,0)),X.wrap=0,L>=X.w_size&&(ue===0&&(J(X.head),X.strstart=0,X.block_start=0,X.insert=0),$=new o.Buf8(X.w_size),o.arraySet($,ee,L-X.w_size,X.w_size,0),ee=$,L=X.w_size),Ae=H.avail_in,Ie=H.next_in,ce=H.input,H.avail_in=L,H.next_in=0,H.input=ee,pe(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,pe(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=Ie,H.input=ce,H.avail_in=Ae,X.wrap=ue,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,D,C,R,U,O,q,j,W;l=a.state,c=a.next_in,j=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(o-a.avail_out),m=d+(a.avail_out-257),p=l.dmax,b=l.wsize,y=l.whave,x=l.wnext,v=l.window,S=l.hold,M=l.bits,A=l.lencode,T=l.distcode,k=(1<<l.lenbits)-1,E=(1<<l.distbits)-1;e:do{M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=A[S&k];t:for(;;){if(S>>>=C=D>>>24,M-=C,(C=D>>>16&255)===0)W[d++]=65535&D;else{if(!(16&C)){if((64&C)==0){D=A[(65535&D)+(S&(1<<C)-1)];continue t}if(32&C){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&D,(C&=15)&&(M<C&&(S+=j[c++]<<M,M+=8),R+=S&(1<<C)-1,S>>>=C,M-=C),M<15&&(S+=j[c++]<<M,M+=8,S+=j[c++]<<M,M+=8),D=T[S&E];n:for(;;){if(S>>>=C=D>>>24,M-=C,!(16&(C=D>>>16&255))){if((64&C)==0){D=T[(65535&D)+(S&(1<<C)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(U=65535&D,M<(C&=15)&&(S+=j[c++]<<M,(M+=8)<C&&(S+=j[c++]<<M,M+=8)),p<(U+=S&(1<<C)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=C,M-=C,(C=d-f)<U){if(y<(C=U-C)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(q=v,(O=0)===x){if(O+=b-C,C<R){for(R-=C;W[d++]=v[O++],--C;);O=d-U,q=W}}else if(x<C){if(O+=b+x-C,(C-=x)<R){for(R-=C;W[d++]=v[O++],--C;);if(O=0,x<R){for(R-=C=x;W[d++]=v[O++],--C;);O=d-U,q=W}}}else if(O+=x-C,C<R){for(R-=C;W[d++]=v[O++],--C;);O=d-U,q=W}for(;2<R;)W[d++]=q[O++],W[d++]=q[O++],W[d++]=q[O++],R-=3;R&&(W[d++]=q[O++],1<R&&(W[d++]=q[O++]))}else{for(O=d-U;W[d++]=W[O++],W[d++]=W[O++],W[d++]=W[O++],2<(R-=3););R&&(W[d++]=W[O++],1<R&&(W[d++]=W[O++]))}break}}break}}while(c<u&&d<m);c-=R=M>>3,S&=(1<<(M-=R<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<m?m-d+257:257-(d-m),l.hold=S,l.bits=M}},{}],49:[function(n,r,i){var a=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,m=0,p=-2,b=1,y=852,x=592;function v(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(O){var q;return O&&O.state?(q=O.state,O.total_in=O.total_out=q.total=0,O.msg="",q.wrap&&(O.adler=1&q.wrap),q.mode=b,q.last=0,q.havedict=0,q.dmax=32768,q.head=null,q.hold=0,q.bits=0,q.lencode=q.lendyn=new a.Buf32(y),q.distcode=q.distdyn=new a.Buf32(x),q.sane=1,q.back=-1,m):p}function A(O){var q;return O&&O.state?((q=O.state).wsize=0,q.whave=0,q.wnext=0,M(O)):p}function T(O,q){var j,W;return O&&O.state?(W=O.state,q<0?(j=0,q=-q):(j=1+(q>>4),q<48&&(q&=15)),q&&(q<8||15<q)?p:(W.window!==null&&W.wbits!==q&&(W.window=null),W.wrap=j,W.wbits=q,A(O))):p}function k(O,q){var j,W;return O?(W=new S,(O.state=W).window=null,(j=T(O,q))!==m&&(O.state=null),j):p}var E,D,C=!0;function R(O){if(C){var q;for(E=new a.Buf32(512),D=new a.Buf32(32),q=0;q<144;)O.lens[q++]=8;for(;q<256;)O.lens[q++]=9;for(;q<280;)O.lens[q++]=7;for(;q<288;)O.lens[q++]=8;for(u(d,O.lens,0,288,E,0,O.work,{bits:9}),q=0;q<32;)O.lens[q++]=5;u(f,O.lens,0,32,D,0,O.work,{bits:5}),C=!1}O.lencode=E,O.lenbits=9,O.distcode=D,O.distbits=5}function U(O,q,j,W){var K,G=O.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),W>=G.wsize?(a.arraySet(G.window,q,j-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(K=G.wsize-G.wnext)&&(K=W),a.arraySet(G.window,q,j-W,K,G.wnext),(W-=K)?(a.arraySet(G.window,q,j-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}i.inflateReset=A,i.inflateReset2=T,i.inflateResetKeep=M,i.inflateInit=function(O){return k(O,15)},i.inflateInit2=k,i.inflate=function(O,q){var j,W,K,G,Q,te,J,z,V,ne,ae,he,pe,ie,Ee,xe,Ne,_e,le,Ve,H,ee,X,B,I=0,ue=new a.Buf8(4),Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return p;(j=O.state).mode===12&&(j.mode=13),Q=O.next_out,K=O.output,J=O.avail_out,G=O.next_in,W=O.input,te=O.avail_in,z=j.hold,V=j.bits,ne=te,ae=J,ee=m;e:for(;;)switch(j.mode){case b:if(j.wrap===0){j.mode=13;break}for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(2&j.wrap&&z===35615){ue[j.check=0]=255&z,ue[1]=z>>>8&255,j.check=l(j.check,ue,2,0),V=z=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&z)<<8)+(z>>8))%31){O.msg="incorrect header check",j.mode=30;break}if((15&z)!=8){O.msg="unknown compression method",j.mode=30;break}if(V-=4,H=8+(15&(z>>>=4)),j.wbits===0)j.wbits=H;else if(H>j.wbits){O.msg="invalid window size",j.mode=30;break}j.dmax=1<<H,O.adler=j.check=1,j.mode=512&z?10:12,V=z=0;break;case 2:for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(j.flags=z,(255&j.flags)!=8){O.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){O.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=z>>8&1),512&j.flags&&(ue[0]=255&z,ue[1]=z>>>8&255,j.check=l(j.check,ue,2,0)),V=z=0,j.mode=3;case 3:for(;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.head&&(j.head.time=z),512&j.flags&&(ue[0]=255&z,ue[1]=z>>>8&255,ue[2]=z>>>16&255,ue[3]=z>>>24&255,j.check=l(j.check,ue,4,0)),V=z=0,j.mode=4;case 4:for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.head&&(j.head.xflags=255&z,j.head.os=z>>8),512&j.flags&&(ue[0]=255&z,ue[1]=z>>>8&255,j.check=l(j.check,ue,2,0)),V=z=0,j.mode=5;case 5:if(1024&j.flags){for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.length=z,j.head&&(j.head.extra_len=z),512&j.flags&&(ue[0]=255&z,ue[1]=z>>>8&255,j.check=l(j.check,ue,2,0)),V=z=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(te<(he=j.length)&&(he=te),he&&(j.head&&(H=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),a.arraySet(j.head.extra,W,G,he,H)),512&j.flags&&(j.check=l(j.check,W,he,G)),te-=he,G+=he,j.length-=he),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(te===0)break e;for(he=0;H=W[G+he++],j.head&&H&&j.length<65536&&(j.head.name+=String.fromCharCode(H)),H&&he<te;);if(512&j.flags&&(j.check=l(j.check,W,he,G)),te-=he,G+=he,H)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(te===0)break e;for(he=0;H=W[G+he++],j.head&&H&&j.length<65536&&(j.head.comment+=String.fromCharCode(H)),H&&he<te;);if(512&j.flags&&(j.check=l(j.check,W,he,G)),te-=he,G+=he,H)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;V<16;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(z!==(65535&j.check)){O.msg="header crc mismatch",j.mode=30;break}V=z=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),O.adler=j.check=0,j.mode=12;break;case 10:for(;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}O.adler=j.check=v(z),V=z=0,j.mode=11;case 11:if(j.havedict===0)return O.next_out=Q,O.avail_out=J,O.next_in=G,O.avail_in=te,j.hold=z,j.bits=V,2;O.adler=j.check=1,j.mode=12;case 12:if(q===5||q===6)break e;case 13:if(j.last){z>>>=7&V,V-=7&V,j.mode=27;break}for(;V<3;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}switch(j.last=1&z,V-=1,3&(z>>>=1)){case 0:j.mode=14;break;case 1:if(R(j),j.mode=20,q!==6)break;z>>>=2,V-=2;break e;case 2:j.mode=17;break;case 3:O.msg="invalid block type",j.mode=30}z>>>=2,V-=2;break;case 14:for(z>>>=7&V,V-=7&V;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if((65535&z)!=(z>>>16^65535)){O.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&z,V=z=0,j.mode=15,q===6)break e;case 15:j.mode=16;case 16:if(he=j.length){if(te<he&&(he=te),J<he&&(he=J),he===0)break e;a.arraySet(K,W,G,he,Q),te-=he,G+=he,J-=he,Q+=he,j.length-=he;break}j.mode=12;break;case 17:for(;V<14;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(j.nlen=257+(31&z),z>>>=5,V-=5,j.ndist=1+(31&z),z>>>=5,V-=5,j.ncode=4+(15&z),z>>>=4,V-=4,286<j.nlen||30<j.ndist){O.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;V<3;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.lens[Ae[j.have++]]=7&z,z>>>=3,V-=3}for(;j.have<19;)j.lens[Ae[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,X={bits:j.lenbits},ee=u(0,j.lens,0,19,j.lencode,0,j.work,X),j.lenbits=X.bits,ee){O.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;xe=(I=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Ne=65535&I,!((Ee=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(Ne<16)z>>>=Ee,V-=Ee,j.lens[j.have++]=Ne;else{if(Ne===16){for(B=Ee+2;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(z>>>=Ee,V-=Ee,j.have===0){O.msg="invalid bit length repeat",j.mode=30;break}H=j.lens[j.have-1],he=3+(3&z),z>>>=2,V-=2}else if(Ne===17){for(B=Ee+3;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}V-=Ee,H=0,he=3+(7&(z>>>=Ee)),z>>>=3,V-=3}else{for(B=Ee+7;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}V-=Ee,H=0,he=11+(127&(z>>>=Ee)),z>>>=7,V-=7}if(j.have+he>j.nlen+j.ndist){O.msg="invalid bit length repeat",j.mode=30;break}for(;he--;)j.lens[j.have++]=H}}if(j.mode===30)break;if(j.lens[256]===0){O.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,X={bits:j.lenbits},ee=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,X),j.lenbits=X.bits,ee){O.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,X={bits:j.distbits},ee=u(f,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,X),j.distbits=X.bits,ee){O.msg="invalid distances set",j.mode=30;break}if(j.mode=20,q===6)break e;case 20:j.mode=21;case 21:if(6<=te&&258<=J){O.next_out=Q,O.avail_out=J,O.next_in=G,O.avail_in=te,j.hold=z,j.bits=V,c(O,ae),Q=O.next_out,K=O.output,J=O.avail_out,G=O.next_in,W=O.input,te=O.avail_in,z=j.hold,V=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;xe=(I=j.lencode[z&(1<<j.lenbits)-1])>>>16&255,Ne=65535&I,!((Ee=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(xe&&(240&xe)==0){for(_e=Ee,le=xe,Ve=Ne;xe=(I=j.lencode[Ve+((z&(1<<_e+le)-1)>>_e)])>>>16&255,Ne=65535&I,!(_e+(Ee=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}z>>>=_e,V-=_e,j.back+=_e}if(z>>>=Ee,V-=Ee,j.back+=Ee,j.length=Ne,xe===0){j.mode=26;break}if(32&xe){j.back=-1,j.mode=12;break}if(64&xe){O.msg="invalid literal/length code",j.mode=30;break}j.extra=15&xe,j.mode=22;case 22:if(j.extra){for(B=j.extra;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.length+=z&(1<<j.extra)-1,z>>>=j.extra,V-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;xe=(I=j.distcode[z&(1<<j.distbits)-1])>>>16&255,Ne=65535&I,!((Ee=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if((240&xe)==0){for(_e=Ee,le=xe,Ve=Ne;xe=(I=j.distcode[Ve+((z&(1<<_e+le)-1)>>_e)])>>>16&255,Ne=65535&I,!(_e+(Ee=I>>>24)<=V);){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}z>>>=_e,V-=_e,j.back+=_e}if(z>>>=Ee,V-=Ee,j.back+=Ee,64&xe){O.msg="invalid distance code",j.mode=30;break}j.offset=Ne,j.extra=15&xe,j.mode=24;case 24:if(j.extra){for(B=j.extra;V<B;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}j.offset+=z&(1<<j.extra)-1,z>>>=j.extra,V-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){O.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(J===0)break e;if(he=ae-J,j.offset>he){if((he=j.offset-he)>j.whave&&j.sane){O.msg="invalid distance too far back",j.mode=30;break}pe=he>j.wnext?(he-=j.wnext,j.wsize-he):j.wnext-he,he>j.length&&(he=j.length),ie=j.window}else ie=K,pe=Q-j.offset,he=j.length;for(J<he&&(he=J),J-=he,j.length-=he;K[Q++]=ie[pe++],--he;);j.length===0&&(j.mode=21);break;case 26:if(J===0)break e;K[Q++]=j.length,J--,j.mode=21;break;case 27:if(j.wrap){for(;V<32;){if(te===0)break e;te--,z|=W[G++]<<V,V+=8}if(ae-=J,O.total_out+=ae,j.total+=ae,ae&&(O.adler=j.check=j.flags?l(j.check,K,ae,Q-ae):o(j.check,K,ae,Q-ae)),ae=J,(j.flags?z:v(z))!==j.check){O.msg="incorrect data check",j.mode=30;break}V=z=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;V<32;){if(te===0)break e;te--,z+=W[G++]<<V,V+=8}if(z!==(4294967295&j.total)){O.msg="incorrect length check",j.mode=30;break}V=z=0}j.mode=29;case 29:ee=1;break e;case 30:ee=-3;break e;case 31:return-4;default:return p}return O.next_out=Q,O.avail_out=J,O.next_in=G,O.avail_in=te,j.hold=z,j.bits=V,(j.wsize||ae!==O.avail_out&&j.mode<30&&(j.mode<27||q!==4))&&U(O,O.output,O.next_out,ae-O.avail_out)?(j.mode=31,-4):(ne-=O.avail_in,ae-=O.avail_out,O.total_in+=ne,O.total_out+=ae,j.total+=ae,j.wrap&&ae&&(O.adler=j.check=j.flags?l(j.check,K,ae,O.next_out-ae):o(j.check,K,ae,O.next_out-ae)),O.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(ne==0&&ae===0||q===4)&&ee===m&&(ee=-5),ee)},i.inflateEnd=function(O){if(!O||!O.state)return p;var q=O.state;return q.window&&(q.window=null),O.state=null,m},i.inflateGetHeader=function(O,q){var j;return O&&O.state?(2&(j=O.state).wrap)==0?p:((j.head=q).done=!1,m):p},i.inflateSetDictionary=function(O,q){var j,W=q.length;return O&&O.state?(j=O.state).wrap!==0&&j.mode!==11?p:j.mode===11&&o(1,q,W,0)!==j.check?-3:U(O,q,W,W)?(j.mode=31,-4):(j.havedict=1,m):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,m,p,b,y,x,v){var S,M,A,T,k,E,D,C,R,U=v.bits,O=0,q=0,j=0,W=0,K=0,G=0,Q=0,te=0,J=0,z=0,V=null,ne=0,ae=new a.Buf16(16),he=new a.Buf16(16),pe=null,ie=0;for(O=0;O<=15;O++)ae[O]=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(j=1;j<W&&ae[j]===0;j++);for(K<j&&(K=j),O=te=1;O<=15;O++)if(te<<=1,(te-=ae[O])<0)return-1;if(0<te&&(d===0||W!==1))return-1;for(he[1]=0,O=1;O<15;O++)he[O+1]=he[O]+ae[O];for(q=0;q<p;q++)f[m+q]!==0&&(x[he[f[m+q]]++]=q);if(E=d===0?(V=pe=x,19):d===1?(V=o,ne-=257,pe=l,ie-=257,256):(V=c,pe=u,-1),O=j,k=y,Q=q=z=0,A=-1,T=(J=1<<(G=K))-1,d===1&&852<J||d===2&&592<J)return 1;for(;;){for(D=O-Q,R=x[q]<E?(C=0,x[q]):x[q]>E?(C=pe[ie+x[q]],V[ne+x[q]]):(C=96,0),S=1<<O-Q,j=M=1<<G;b[k+(z>>Q)+(M-=S)]=D<<24|C<<16|R|0,M!==0;);for(S=1<<O-1;z&S;)S>>=1;if(S!==0?(z&=S-1,z+=S):z=0,q++,--ae[O]==0){if(O===W)break;O=f[m+x[q]]}if(K<O&&(z&T)!==A){for(Q===0&&(Q=K),k+=j,te=1<<(G=O-Q);G+Q<W&&!((te-=ae[G+Q])<=0);)G++,te<<=1;if(J+=1<<G,d===1&&852<J||d===2&&592<J)return 1;b[A=z&T]=K<<24|G<<16|k-y|0}}return z!==0&&(b[k+z]=O-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 ue=I.length;0<=--ue;)I[ue]=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],D=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=new Array(2*(m+2));c(U);var O=new Array(2*p);c(O);var q=new Array(512);c(q);var j=new Array(256);c(j);var W=new Array(d);c(W);var K,G,Q,te=new Array(p);function J(I,ue,Ae,Ie,ce){this.static_tree=I,this.extra_bits=ue,this.extra_base=Ae,this.elems=Ie,this.max_length=ce,this.has_stree=I&&I.length}function z(I,ue){this.dyn_tree=I,this.max_code=0,this.stat_desc=ue}function V(I){return I<256?q[I]:q[256+(I>>>7)]}function ne(I,ue){I.pending_buf[I.pending++]=255&ue,I.pending_buf[I.pending++]=ue>>>8&255}function ae(I,ue,Ae){I.bi_valid>v-Ae?(I.bi_buf|=ue<<I.bi_valid&65535,ne(I,I.bi_buf),I.bi_buf=ue>>v-I.bi_valid,I.bi_valid+=Ae-v):(I.bi_buf|=ue<<I.bi_valid&65535,I.bi_valid+=Ae)}function he(I,ue,Ae){ae(I,Ae[2*ue],Ae[2*ue+1])}function pe(I,ue){for(var Ae=0;Ae|=1&I,I>>>=1,Ae<<=1,0<--ue;);return Ae>>>1}function ie(I,ue,Ae){var Ie,ce,$=new Array(x+1),L=0;for(Ie=1;Ie<=x;Ie++)$[Ie]=L=L+Ae[Ie-1]<<1;for(ce=0;ce<=ue;ce++){var Y=I[2*ce+1];Y!==0&&(I[2*ce]=pe($[Y]++,Y))}}function Ee(I){var ue;for(ue=0;ue<m;ue++)I.dyn_ltree[2*ue]=0;for(ue=0;ue<p;ue++)I.dyn_dtree[2*ue]=0;for(ue=0;ue<b;ue++)I.bl_tree[2*ue]=0;I.dyn_ltree[2*M]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function xe(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,ue,Ae,Ie){var ce=2*ue,$=2*Ae;return I[ce]<I[$]||I[ce]===I[$]&&Ie[ue]<=Ie[Ae]}function _e(I,ue,Ae){for(var Ie=I.heap[Ae],ce=Ae<<1;ce<=I.heap_len&&(ce<I.heap_len&&Ne(ue,I.heap[ce+1],I.heap[ce],I.depth)&&ce++,!Ne(ue,Ie,I.heap[ce],I.depth));)I.heap[Ae]=I.heap[ce],Ae=ce,ce<<=1;I.heap[Ae]=Ie}function le(I,ue,Ae){var Ie,ce,$,L,Y=0;if(I.last_lit!==0)for(;Ie=I.pending_buf[I.d_buf+2*Y]<<8|I.pending_buf[I.d_buf+2*Y+1],ce=I.pending_buf[I.l_buf+Y],Y++,Ie===0?he(I,ce,ue):(he(I,($=j[ce])+f+1,ue),(L=E[$])!==0&&ae(I,ce-=W[$],L),he(I,$=V(--Ie),Ae),(L=D[$])!==0&&ae(I,Ie-=te[$],L)),Y<I.last_lit;);he(I,M,ue)}function Ve(I,ue){var Ae,Ie,ce,$=ue.dyn_tree,L=ue.stat_desc.static_tree,Y=ue.stat_desc.has_stree,be=ue.stat_desc.elems,Se=-1;for(I.heap_len=0,I.heap_max=y,Ae=0;Ae<be;Ae++)$[2*Ae]!==0?(I.heap[++I.heap_len]=Se=Ae,I.depth[Ae]=0):$[2*Ae+1]=0;for(;I.heap_len<2;)$[2*(ce=I.heap[++I.heap_len]=Se<2?++Se:0)]=1,I.depth[ce]=0,I.opt_len--,Y&&(I.static_len-=L[2*ce+1]);for(ue.max_code=Se,Ae=I.heap_len>>1;1<=Ae;Ae--)_e(I,$,Ae);for(ce=be;Ae=I.heap[1],I.heap[1]=I.heap[I.heap_len--],_e(I,$,1),Ie=I.heap[1],I.heap[--I.heap_max]=Ae,I.heap[--I.heap_max]=Ie,$[2*ce]=$[2*Ae]+$[2*Ie],I.depth[ce]=(I.depth[Ae]>=I.depth[Ie]?I.depth[Ae]:I.depth[Ie])+1,$[2*Ae+1]=$[2*Ie+1]=ce,I.heap[1]=ce++,_e(I,$,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],(function(se,Pe){var Re,Xe,et,Je,oe,ye,je=Pe.dyn_tree,$e=Pe.max_code,ft=Pe.stat_desc.static_tree,re=Pe.stat_desc.has_stree,ke=Pe.stat_desc.extra_bits,ve=Pe.stat_desc.extra_base,Fe=Pe.stat_desc.max_length,Ue=0;for(Je=0;Je<=x;Je++)se.bl_count[Je]=0;for(je[2*se.heap[se.heap_max]+1]=0,Re=se.heap_max+1;Re<y;Re++)Fe<(Je=je[2*je[2*(Xe=se.heap[Re])+1]+1]+1)&&(Je=Fe,Ue++),je[2*Xe+1]=Je,$e<Xe||(se.bl_count[Je]++,oe=0,ve<=Xe&&(oe=ke[Xe-ve]),ye=je[2*Xe],se.opt_len+=ye*(Je+oe),re&&(se.static_len+=ye*(ft[2*Xe+1]+oe)));if(Ue!==0){do{for(Je=Fe-1;se.bl_count[Je]===0;)Je--;se.bl_count[Je]--,se.bl_count[Je+1]+=2,se.bl_count[Fe]--,Ue-=2}while(0<Ue);for(Je=Fe;Je!==0;Je--)for(Xe=se.bl_count[Je];Xe!==0;)$e<(et=se.heap[--Re])||(je[2*et+1]!==Je&&(se.opt_len+=(Je-je[2*et+1])*je[2*et],je[2*et+1]=Je),Xe--)}})(I,ue),ie($,Se,I.bl_count)}function H(I,ue,Ae){var Ie,ce,$=-1,L=ue[1],Y=0,be=7,Se=4;for(L===0&&(be=138,Se=3),ue[2*(Ae+1)+1]=65535,Ie=0;Ie<=Ae;Ie++)ce=L,L=ue[2*(Ie+1)+1],++Y<be&&ce===L||(Y<Se?I.bl_tree[2*ce]+=Y:ce!==0?(ce!==$&&I.bl_tree[2*ce]++,I.bl_tree[2*A]++):Y<=10?I.bl_tree[2*T]++:I.bl_tree[2*k]++,$=ce,Se=(Y=0)===L?(be=138,3):ce===L?(be=6,3):(be=7,4))}function ee(I,ue,Ae){var Ie,ce,$=-1,L=ue[1],Y=0,be=7,Se=4;for(L===0&&(be=138,Se=3),Ie=0;Ie<=Ae;Ie++)if(ce=L,L=ue[2*(Ie+1)+1],!(++Y<be&&ce===L)){if(Y<Se)for(;he(I,ce,I.bl_tree),--Y!=0;);else ce!==0?(ce!==$&&(he(I,ce,I.bl_tree),Y--),he(I,A,I.bl_tree),ae(I,Y-3,2)):Y<=10?(he(I,T,I.bl_tree),ae(I,Y-3,3)):(he(I,k,I.bl_tree),ae(I,Y-11,7));$=ce,Se=(Y=0)===L?(be=138,3):ce===L?(be=6,3):(be=7,4)}}c(te);var X=!1;function B(I,ue,Ae,Ie){ae(I,(u<<1)+(Ie?1:0),3),(function(ce,$,L,Y){xe(ce),ne(ce,L),ne(ce,~L),a.arraySet(ce.pending_buf,ce.window,$,L,ce.pending),ce.pending+=L})(I,ue,Ae)}i._tr_init=function(I){X||((function(){var ue,Ae,Ie,ce,$,L=new Array(x+1);for(ce=Ie=0;ce<d-1;ce++)for(W[ce]=Ie,ue=0;ue<1<<E[ce];ue++)j[Ie++]=ce;for(j[Ie-1]=ce,ce=$=0;ce<16;ce++)for(te[ce]=$,ue=0;ue<1<<D[ce];ue++)q[$++]=ce;for($>>=7;ce<p;ce++)for(te[ce]=$<<7,ue=0;ue<1<<D[ce]-7;ue++)q[256+$++]=ce;for(Ae=0;Ae<=x;Ae++)L[Ae]=0;for(ue=0;ue<=143;)U[2*ue+1]=8,ue++,L[8]++;for(;ue<=255;)U[2*ue+1]=9,ue++,L[9]++;for(;ue<=279;)U[2*ue+1]=7,ue++,L[7]++;for(;ue<=287;)U[2*ue+1]=8,ue++,L[8]++;for(ie(U,m+1,L),ue=0;ue<p;ue++)O[2*ue+1]=5,O[2*ue]=pe(ue,5);K=new J(U,E,f+1,m,x),G=new J(O,D,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,G),I.bl_desc=new z(I.bl_tree,Q),I.bi_buf=0,I.bi_valid=0,Ee(I)},i._tr_stored_block=B,i._tr_flush_block=function(I,ue,Ae,Ie){var ce,$,L=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=(function(Y){var be,Se=4093624447;for(be=0;be<=31;be++,Se>>>=1)if(1&Se&&Y.dyn_ltree[2*be]!==0)return o;if(Y.dyn_ltree[18]!==0||Y.dyn_ltree[20]!==0||Y.dyn_ltree[26]!==0)return l;for(be=32;be<f;be++)if(Y.dyn_ltree[2*be]!==0)return l;return o})(I)),Ve(I,I.l_desc),Ve(I,I.d_desc),L=(function(Y){var be;for(H(Y,Y.dyn_ltree,Y.l_desc.max_code),H(Y,Y.dyn_dtree,Y.d_desc.max_code),Ve(Y,Y.bl_desc),be=b-1;3<=be&&Y.bl_tree[2*R[be]+1]===0;be--);return Y.opt_len+=3*(be+1)+5+5+4,be})(I),ce=I.opt_len+3+7>>>3,($=I.static_len+3+7>>>3)<=ce&&(ce=$)):ce=$=Ae+5,Ae+4<=ce&&ue!==-1?B(I,ue,Ae,Ie):I.strategy===4||$===ce?(ae(I,2+(Ie?1:0),3),le(I,U,O)):(ae(I,4+(Ie?1:0),3),(function(Y,be,Se,se){var Pe;for(ae(Y,be-257,5),ae(Y,Se-1,5),ae(Y,se-4,4),Pe=0;Pe<se;Pe++)ae(Y,Y.bl_tree[2*R[Pe]+1],3);ee(Y,Y.dyn_ltree,be-1),ee(Y,Y.dyn_dtree,Se-1)})(I,I.l_desc.max_code+1,I.d_desc.max_code+1,L+1),le(I,I.dyn_ltree,I.dyn_dtree)),Ee(I),Ie&&xe(I)},i._tr_tally=function(I,ue,Ae){return I.pending_buf[I.d_buf+2*I.last_lit]=ue>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&ue,I.pending_buf[I.l_buf+I.last_lit]=255&Ae,I.last_lit++,ue===0?I.dyn_ltree[2*Ae]++:(I.matches++,ue--,I.dyn_ltree[2*(j[Ae]+f+1)]++,I.dyn_dtree[2*V(ue)]++),I.last_lit===I.lit_bufsize-1},i._tr_align=function(I){ae(I,2,3),he(I,M,U),(function(ue){ue.bi_valid===16?(ne(ue,ue.bi_buf),ue.bi_buf=0,ue.bi_valid=0):8<=ue.bi_valid&&(ue.pending_buf[ue.pending++]=255&ue.bi_buf,ue.bi_buf>>=8,ue.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,D=k.args;switch(D.length){case 0:E();break;case 1:E(D[0]);break;case 2:E(D[0],D[1]);break;case 3:E(D[0],D[1],D[2]);break;default:E.apply(l,D)}})(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 f_<"u"?f_:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Ak)),Ak.exports}var IIe=LIe();const FIe=ml(IIe);function UIe(t){const e=new pi;if(!t)return e;const n=t.trim().split(/\s+/).map(parseFloat);return n.length>=12&&e.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),e}const NG=UIe;async function EG(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=a.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function 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 D=Array.from(k.children).filter(C=>C.tagName==="metadata"&&C.getAttribute("key")==="extruder");if(D.length>0){const C=D[0].getAttribute("value");C&&l.set(`${S}:${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 EG(b,0);y.length>0&&n.set("1",{id:"1",meshes:y,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let p=0;p<f.length;p++){const b=f[p],y=b.getAttribute("id");if(!y)continue;let x=o.get(y)??-1;if(x<0){const 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=[],D=T.getElementsByTagName("vertex");for(let R=0;R<D.length;R++){const U=D[R];k.push(parseFloat(U.getAttribute("x")||"0"),parseFloat(U.getAttribute("y")||"0"),parseFloat(U.getAttribute("z")||"0"))}const C=T.getElementsByTagName("triangle");for(let R=0;R<C.length;R++){const U=C[R];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 D=await a(k);if(D){const C=E?`${y}:${E}`:null,R=C?l.get(C)??x:x,U=await EG(D,R),O=T.getAttribute("transform"),q=NG(O);for(const j of U)if(O){const W=[];for(let K=0;K<j.vertices.length;K+=3){const G=new nt(j.vertices[K],j.vertices[K+1],j.vertices[K+2]);G.applyMatrix4(q),W.push(G.x,G.y,G.z)}v.push({vertices:W,triangles:j.triangles,extruder:j.extruder})}else v.push(j)}}}v.length>0&&n.set(y,{id:y,meshes:v,defaultExtruder:x})}const m=d.getElementsByTagName("build");if(m.length>0){const p=m[0].getElementsByTagName("item");for(let b=0;b<p.length;b++){const y=p[b],x=y.getAttribute("objectid");if(!x)continue;const v=NG(y.getAttribute("transform"));r.push({objectId:x,transform:v})}}return{objects:n,buildItems:r}}function AG(t){const e=new yl,n=new Float32Array(t.vertices.length);for(let r=0;r<t.vertices.length;r+=3)n[r]=t.vertices[r],n[r+1]=t.vertices[r+2],n[r+2]=t.vertices[r+1];return e.setAttribute("position",new Co(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function 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 Pn(1710618),o.current=S;const M=new So(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 XV(16777215,.8);E.position.set(100,100,100),S.add(E);const D=new XV(16777215,.4);D.position.set(-100,50,-100),S.add(D);const C=Math.max(e.x,e.y),R=Math.ceil(C/16),U=new SRe(C,R,4473924,3355443);S.add(U);const O=new dL(e.x,e.y),q=new lL({color:44610,transparent:!0,opacity:.15,side:Il}),j=new hl(O,q);j.rotation.x=-Math.PI/2,j.position.y=-.5,S.add(j);let W;const 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:te})=>{if(Q.size===0)throw new Error("No meshes found in 3MF file");const J=Ne=>{const le=n?.[Ne]||"#00ae42",Ve=new Pn(le);return new gRe({color:Ve,shininess:30,flatShading:!1})},z=new Hb,V=new Map;if(te.length>0)for(const Ne of te){const _e=Q.get(Ne.objectId);if(_e)for(const le of _e.meshes){const Ve=Ne.extruder??le.extruder,H=[];for(let X=0;X<le.vertices.length;X+=3){const B=new nt(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=AG({vertices:H,triangles:le.triangles});V.has(Ve)||V.set(Ve,[]),V.get(Ve).push(ee)}}else for(const Ne of Q.values())for(const _e of Ne.meshes){const le=_e.extruder,Ve=AG(_e);V.has(le)||V.set(le,[]),V.get(le).push(Ve)}for(const[Ne,_e]of V){if(_e.length===0)continue;const le=_e.length===1?_e[0]:OIe(_e,!1);if(le){const Ve=J(Ne),H=new hl(le,Ve);z.add(H)}if(_e.length>1)for(const Ve of _e)Ve.dispose()}const ne=new nm().setFromObject(z),ae=ne.getCenter(new nt);z.position.y=-ne.min.y,te.length===0&&(z.position.x=-ae.x,z.position.z=-ae.z),S.add(z);const he=new nm().setFromObject(z),pe=he.getCenter(new nt),ie=he.getSize(new nt),xe=Math.max(ie.x,ie.y,ie.z)*1.8;M.position.set(pe.x+xe*.7,pe.y+xe*.5,pe.z+xe*.7),T.target.copy(pe),T.update(),d(!1)}).catch(Q=>{m(Q.message),d(!1)});const G=()=>{if(!y)return;const Q=y.clientWidth,te=y.clientHeight;M.aspect=Q/te,M.updateProjectionMatrix(),A.setSize(Q,te)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),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(Me,{variant:"secondary",size:"sm",onClick:()=>b(.8),children:s.jsx(GD,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>b(1.25),children:s.jsx(WD,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(dm,{className:"w-4 h-4"})})]})]})}const fE="159",gp={ROTATE:0,DOLLY:1,PAN:2},xp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},$Ie=0,TG=1,HIe=2,Fee=1,VIe=2,Vc=3,ih=0,Ss=1,Yc=2,Hd=0,cg=1,CG=2,kG=3,jG=4,GIe=5,af=100,WIe=101,qIe=102,PG=103,RG=104,KIe=200,XIe=201,YIe=202,ZIe=203,wR=204,SR=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,WS=3,uFe=4,dFe=5,hFe=6,fFe=7,mL=0,mFe=1,pFe=2,Vd=0,gFe=1,xFe=2,bFe=3,yFe=4,vFe=5,Uee=300,Pg=301,Rg=302,MR=303,NR=304,mE=306,ER=1e3,tl=1001,AR=1002,va=1003,DG=1004,Tk=1005,Mo=1006,_Fe=1007,J0=1008,Gd=1009,wFe=1010,SFe=1011,pL=1012,zee=1013,Pd=1014,tu=1015,ey=1016,Bee=1017,$ee=1018,Cf=1020,MFe=1021,No=1023,NFe=1024,EFe=1025,kf=1026,Dg=1027,AFe=1028,Hee=1029,TFe=1030,Vee=1031,Gee=1033,Ck=33776,kk=33777,jk=33778,Pk=33779,OG=35840,LG=35841,IG=35842,FG=35843,Wee=36196,UG=37492,zG=37496,BG=37808,$G=37809,HG=37810,VG=37811,GG=37812,WG=37813,qG=37814,KG=37815,XG=37816,YG=37817,ZG=37818,QG=37819,JG=37820,e7=37821,Rk=36492,t7=36494,n7=36495,CFe=36283,r7=36284,i7=36285,a7=36286,qee=3e3,jf=3001,kFe=3200,jFe=3201,Kee=0,PFe=1,Eo="",_a="srgb",Su="srgb-linear",gL="display-p3",pE="display-p3-linear",qS="linear",Pr="srgb",KS="rec709",XS="p3",bp=7680,s7=519,RFe=512,DFe=513,OFe=514,Xee=515,LFe=516,IFe=517,FFe=518,UFe=519,TR=35044,o7="300 es",CR=1035,Vl=2e3,ty=2001;class pm{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 Ra=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let l7=1234567;const i0=Math.PI/180,ny=180/Math.PI;function cu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ra[t&255]+Ra[t>>8&255]+Ra[t>>16&255]+Ra[t>>24&255]+"-"+Ra[e&255]+Ra[e>>8&255]+"-"+Ra[e>>16&15|64]+Ra[e>>24&255]+"-"+Ra[n&63|128]+Ra[n>>8&255]+"-"+Ra[n>>16&255]+Ra[n>>24&255]+Ra[r&255]+Ra[r>>8&255]+Ra[r>>16&255]+Ra[r>>24&255]).toLowerCase()}function wa(t,e,n){return Math.max(e,Math.min(n,t))}function xL(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 a0(t,e,n){return(1-n)*t+n*e}function $Fe(t,e,n,r){return a0(t,e,1-Math.exp(-n*r))}function HFe(t,e=1){return e-Math.abs(xL(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&&(l7=t);let e=l7+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function YFe(t){return t*i0}function ZFe(t){return t*ny}function kR(t){return(t&t-1)===0&&t!==0}function QFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function YS(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 Fl(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function 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 Yee={DEG2RAD:i0,RAD2DEG:ny,generateUUID:cu,clamp:wa,euclideanModulo:xL,mapLinear:zFe,inverseLerp:BFe,lerp:a0,damp:$Fe,pingpong:HFe,smoothstep:VFe,smootherstep:GFe,randInt:WFe,randFloat:qFe,randFloatSpread:KFe,seededRandom:XFe,degToRad:YFe,radToDeg:ZFe,isPowerOfTwo:kR,ceilPowerOfTwo:QFe,floorPowerOfTwo:YS,setQuaternionFromProperEuler:JFe,normalize:fr,denormalize:Fl};class fn{constructor(e=0,n=0){fn.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(wa(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 Tn{constructor(e,n,r,i,a,o,l,c,u){Tn.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(Dk.makeScale(e,n)),this}rotate(e){return this.premultiply(Dk.makeRotation(-e)),this}translate(e,n){return this.premultiply(Dk.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,r,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Dk=new Tn;function Zee(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function ZS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function e5e(){const t=ZS("canvas");return t.style.display="block",t}const c7={};function s0(t){t in c7||(c7[t]=!0,console.warn(t))}const u7=new Tn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),d7=new Tn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),aw={[Su]:{transfer:qS,primaries:KS,toReference:t=>t,fromReference:t=>t},[_a]:{transfer:Pr,primaries:KS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[pE]:{transfer:qS,primaries:XS,toReference:t=>t.applyMatrix3(d7),fromReference:t=>t.applyMatrix3(u7)},[gL]:{transfer:Pr,primaries:XS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(d7),fromReference:t=>t.applyMatrix3(u7).convertLinearToSRGB()}},t5e=new Set([Su,pE]),mr={enabled:!0,_workingColorSpace:Su,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=aw[e].toReference,i=aw[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 aw[t].primaries},getTransfer:function(t){return t===Eo?qS:aw[t].transfer}};function ug(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ok(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let yp;class Qee{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{yp===void 0&&(yp=ZS("canvas")),yp.width=e.width,yp.height=e.height;const r=yp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=yp}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=ZS("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]=ug(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(ug(n[r]/255)*255):n[r]=ug(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 Jee{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:n5e++}),this.uuid=cu(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(Lk(i[o].image)):a.push(Lk(i[o]))}else a=Lk(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function Lk(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?Qee.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 Ms extends pm{constructor(e=Ms.DEFAULT_IMAGE,n=Ms.DEFAULT_MAPPING,r=tl,i=tl,a=Mo,o=J0,l=No,c=Gd,u=Ms.DEFAULT_ANISOTROPY,d=Eo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:r5e++}),this.uuid=cu(),this.name="",this.source=new Jee(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 fn(0,0),this.repeat=new fn(1,1),this.center=new fn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(s0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===jf?_a:Eo),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Uee)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ER:e.x=e.x-Math.floor(e.x);break;case tl:e.x=e.x<0?0:1;break;case AR: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 ER:e.y=e.y-Math.floor(e.y);break;case tl:e.y=e.y<0?0:1;break;case AR:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return s0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===_a?jf:qee}set encoding(e){s0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===jf?_a:Eo}}Ms.DEFAULT_IMAGE=null;Ms.DEFAULT_MAPPING=Uee;Ms.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,D=(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=D/i):T<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(T),r=E/a,i=D/a),this.set(r,i,a,n),this}let S=Math.sqrt((x-b)*(x-b)+(f-y)*(f-y)+(m-d)*(m-d));return Math.abs(S)<.001&&(S=1),this.x=(x-b)/S,this.y=(f-y)/S,this.z=(m-d)/S,this.w=Math.acos((u+p+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class i5e extends pm{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&&(s0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===jf?_a:Eo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Mo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new Ms(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps,this.texture.internalFormat=r.internalFormat,this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}setSize(e,n,r=1){(this.width!==e||this.height!==n||this.depth!==r)&&(this.width=e,this.height=n,this.depth=r,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new Jee(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 rm extends i5e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class ete extends Ms{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=va,this.minFilter=va,this.wrapR=tl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class a5e extends Ms{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=va,this.minFilter=va,this.wrapR=tl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class im{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(wa(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=a,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-n;return this._w=p*o+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,m=Math.sin(n*d)/u;return this._w=o*f+this._w*m,this._x=r*f+this._x*m,this._y=i*f+this._y*m,this._z=a*f+this._z*m,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Be{constructor(e=0,n=0,r=0){Be.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(h7.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(h7.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Ik.copy(this).projectOnVector(e),this.sub(Ik)}reflect(e){return this.sub(Ik.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(wa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ik=new Be,h7=new im;class ko{constructor(e=new Be(1/0,1/0,1/0),n=new Be(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(Ko.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ko.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=Ko.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,Ko):Ko.fromBufferAttribute(a,o),Ko.applyMatrix4(e.matrixWorld),this.expandByPoint(Ko);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),sw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),sw.copy(r.boundingBox)),sw.applyMatrix4(e.matrixWorld),this.union(sw)}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,Ko),Ko.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Eb),ow.subVectors(this.max,Eb),vp.subVectors(e.a,Eb),_p.subVectors(e.b,Eb),wp.subVectors(e.c,Eb),od.subVectors(_p,vp),ld.subVectors(wp,_p),Gh.subVectors(vp,wp);let n=[0,-od.z,od.y,0,-ld.z,ld.y,0,-Gh.z,Gh.y,od.z,0,-od.x,ld.z,0,-ld.x,Gh.z,0,-Gh.x,-od.y,od.x,0,-ld.y,ld.x,0,-Gh.y,Gh.x,0];return!Fk(n,vp,_p,wp,ow)||(n=[1,0,0,0,1,0,0,0,1],!Fk(n,vp,_p,wp,ow))?!1:(lw.crossVectors(od,ld),n=[lw.x,lw.y,lw.z],Fk(n,vp,_p,wp,ow))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ko).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ko).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Oc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Oc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Oc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Oc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Oc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Oc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Oc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Oc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Oc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Oc=[new Be,new Be,new Be,new Be,new Be,new Be,new Be,new Be],Ko=new Be,sw=new ko,vp=new Be,_p=new Be,wp=new Be,od=new Be,ld=new Be,Gh=new Be,Eb=new Be,ow=new Be,lw=new Be,Wh=new Be;function Fk(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Wh.fromArray(t,a);const l=i.x*Math.abs(Wh.x)+i.y*Math.abs(Wh.y)+i.z*Math.abs(Wh.z),c=e.dot(Wh),u=n.dot(Wh),d=r.dot(Wh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const s5e=new ko,Ab=new Be,Uk=new Be;class Xl{constructor(e=new Be,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):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;Ab.subVectors(e,this.center);const n=Ab.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Ab,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Uk.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ab.copy(e.center).add(Uk)),this.expandByPoint(Ab.copy(e.center).sub(Uk))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Lc=new Be,zk=new Be,cw=new Be,cd=new Be,Bk=new Be,uw=new Be,$k=new Be;class bL{constructor(e=new Be,n=new Be(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Lc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Lc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Lc.copy(this.origin).addScaledVector(this.direction,n),Lc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){zk.copy(e).add(n).multiplyScalar(.5),cw.copy(n).sub(e).normalize(),cd.copy(this.origin).sub(zk);const a=e.distanceTo(n)*.5,o=-this.direction.dot(cw),l=cd.dot(this.direction),c=-cd.dot(cw),u=cd.lengthSq(),d=Math.abs(1-o*o);let f,m,p,b;if(d>0)if(f=o*c-l,m=o*l-c,b=a*d,f>=0)if(m>=-b)if(m<=b){const y=1/d;f*=y,m*=y,p=f*(f+o*m+2*l)+m*(o*f+m+2*c)+u}else m=a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m=-a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;else m<=-b?(f=Math.max(0,-(-o*a+l)),m=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u):m<=b?(f=0,m=Math.min(Math.max(-a,-c),a),p=m*(m+2*c)+u):(f=Math.max(0,-(o*a+l)),m=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+m*(m+2*c)+u);else m=o>0?-a:a,f=Math.max(0,-(o*m+l)),p=-f*f+m*(m+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(zk).addScaledVector(cw,m),p}intersectSphere(e,n){Lc.subVectors(e.center,this.origin);const r=Lc.dot(this.direction),i=Lc.dot(Lc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,m=this.origin;return u>=0?(r=(e.min.x-m.x)*u,i=(e.max.x-m.x)*u):(r=(e.max.x-m.x)*u,i=(e.min.x-m.x)*u),d>=0?(a=(e.min.y-m.y)*d,o=(e.max.y-m.y)*d):(a=(e.max.y-m.y)*d,o=(e.min.y-m.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-m.z)*f,c=(e.max.z-m.z)*f):(l=(e.max.z-m.z)*f,c=(e.min.z-m.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Lc)!==null}intersectTriangle(e,n,r,i,a){Bk.subVectors(n,e),uw.subVectors(r,e),$k.crossVectors(Bk,uw);let o=this.direction.dot($k),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;cd.subVectors(this.origin,e);const c=l*this.direction.dot(uw.crossVectors(cd,uw));if(c<0)return null;const u=l*this.direction.dot(Bk.cross(cd));if(u<0||c+u>o)return null;const d=-l*cd.dot($k);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ar{constructor(e,n,r,i,a,o,l,c,u,d,f,m,p,b,y,x){Ar.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 Ar().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/Sp.setFromMatrixColumn(e,0).length(),a=1/Sp.setFromMatrixColumn(e,1).length(),o=1/Sp.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 Fs.subVectors(e,n),Fs.lengthSq()===0&&(Fs.z=1),Fs.normalize(),ud.crossVectors(r,Fs),ud.lengthSq()===0&&(Math.abs(r.z)===1?Fs.x+=1e-4:Fs.z+=1e-4,Fs.normalize(),ud.crossVectors(r,Fs)),ud.normalize(),dw.crossVectors(Fs,ud),i[0]=ud.x,i[4]=dw.x,i[8]=Fs.x,i[1]=ud.y,i[5]=dw.y,i[9]=Fs.y,i[2]=ud.z,i[6]=dw.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],D=i[8],C=i[12],R=i[1],U=i[5],O=i[9],q=i[13],j=i[2],W=i[6],K=i[10],G=i[14],Q=i[3],te=i[7],J=i[11],z=i[15];return a[0]=o*k+l*R+c*j+u*Q,a[4]=o*E+l*U+c*W+u*te,a[8]=o*D+l*O+c*K+u*J,a[12]=o*C+l*q+c*G+u*z,a[1]=d*k+f*R+m*j+p*Q,a[5]=d*E+f*U+m*W+p*te,a[9]=d*D+f*O+m*K+p*J,a[13]=d*C+f*q+m*G+p*z,a[2]=b*k+y*R+x*j+v*Q,a[6]=b*E+y*U+x*W+v*te,a[10]=b*D+y*O+x*K+v*J,a[14]=b*C+y*q+x*G+v*z,a[3]=S*k+M*R+A*j+T*Q,a[7]=S*E+M*U+A*W+T*te,a[11]=S*D+M*O+A*K+T*J,a[15]=S*C+M*q+A*G+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=Sp.set(i[0],i[1],i[2]).length();const o=Sp.set(i[4],i[5],i[6]).length(),l=Sp.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],Xo.copy(this);const u=1/a,d=1/o,f=1/l;return Xo.elements[0]*=u,Xo.elements[1]*=u,Xo.elements[2]*=u,Xo.elements[4]*=d,Xo.elements[5]*=d,Xo.elements[6]*=d,Xo.elements[8]*=f,Xo.elements[9]*=f,Xo.elements[10]*=f,n.setFromRotationMatrix(Xo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Vl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),m=(r+i)/(r-i);let p,b;if(l===Vl)p=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===ty)p=-o/(o-a),b=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Vl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),m=(n+e)*u,p=(r+i)*d;let b,y;if(l===Vl)b=(o+a)*f,y=-2*f;else if(l===ty)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 Sp=new Be,Xo=new Ar,o5e=new Be(0,0,0),l5e=new Be(1,1,1),ud=new Be,dw=new Be,Fs=new Be,f7=new Ar,m7=new im;class Ky{constructor(e=0,n=0,r=0,i=Ky.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(wa(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(-wa(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(wa(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(-wa(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(wa(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(-wa(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(m,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return f7.makeRotationFromQuaternion(e),this.setFromRotationMatrix(f7,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return m7.setFromEuler(this),this.setFromQuaternion(m7,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ky.DEFAULT_ORDER="XYZ";class tte{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 p7=new Be,Mp=new im,Ic=new Ar,hw=new Be,Tb=new Be,u5e=new Be,d5e=new im,g7=new Be(1,0,0),x7=new Be(0,1,0),b7=new Be(0,0,1),h5e={type:"added"},f5e={type:"removed"};class es extends pm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:c5e++}),this.uuid=cu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=es.DEFAULT_UP.clone();const e=new Be,n=new Ky,r=new im,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 Ar},normalMatrix:{value:new Tn}}),this.matrix=new Ar,this.matrixWorld=new Ar,this.matrixAutoUpdate=es.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new tte,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 Mp.setFromAxisAngle(e,n),this.quaternion.multiply(Mp),this}rotateOnWorldAxis(e,n){return Mp.setFromAxisAngle(e,n),this.quaternion.premultiply(Mp),this}rotateX(e){return this.rotateOnAxis(g7,e)}rotateY(e){return this.rotateOnAxis(x7,e)}rotateZ(e){return this.rotateOnAxis(b7,e)}translateOnAxis(e,n){return p7.copy(e).applyQuaternion(this.quaternion),this.position.add(p7.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(g7,e)}translateY(e){return this.translateOnAxis(x7,e)}translateZ(e){return this.translateOnAxis(b7,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ic.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?hw.copy(e):hw.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Tb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ic.lookAt(Tb,hw,this.up):Ic.lookAt(hw,Tb,this.up),this.quaternion.setFromRotationMatrix(Ic),i&&(Ic.extractRotation(i.matrixWorld),Mp.setFromRotationMatrix(Ic),this.quaternion.premultiply(Mp.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),Ic.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ic.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ic),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tb,e,u5e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Tb,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}}es.DEFAULT_UP=new Be(0,1,0);es.DEFAULT_MATRIX_AUTO_UPDATE=!0;es.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Yo=new Be,Fc=new Be,Hk=new Be,Uc=new Be,Np=new Be,Ep=new Be,y7=new Be,Vk=new Be,Gk=new Be,Wk=new Be;let fw=!1;class Zo{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),Yo.subVectors(e,n),i.cross(Yo);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){Yo.subVectors(i,n),Fc.subVectors(r,n),Hk.subVectors(e,n);const o=Yo.dot(Yo),l=Yo.dot(Fc),c=Yo.dot(Hk),u=Fc.dot(Fc),d=Fc.dot(Hk),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const m=1/f,p=(u*c-l*d)*m,b=(o*d-l*c)*m;return a.set(1-p-b,b,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Uc),Uc.x>=0&&Uc.y>=0&&Uc.x+Uc.y<=1}static getUV(e,n,r,i,a,o,l,c){return fw===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fw=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Uc),c.setScalar(0),c.addScaledVector(a,Uc.x),c.addScaledVector(o,Uc.y),c.addScaledVector(l,Uc.z),c}static isFrontFacing(e,n,r,i){return Yo.subVectors(r,n),Fc.subVectors(e,n),Yo.cross(Fc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Yo.subVectors(this.c,this.b),Fc.subVectors(this.a,this.b),Yo.cross(Fc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Zo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return fw===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fw=!0),Zo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Zo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Zo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zo.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;Np.subVectors(i,r),Ep.subVectors(a,r),Vk.subVectors(e,r);const c=Np.dot(Vk),u=Ep.dot(Vk);if(c<=0&&u<=0)return n.copy(r);Gk.subVectors(e,i);const d=Np.dot(Gk),f=Ep.dot(Gk);if(d>=0&&f<=d)return n.copy(i);const m=c*f-d*u;if(m<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Np,o);Wk.subVectors(e,a);const p=Np.dot(Wk),b=Ep.dot(Wk);if(b>=0&&p<=b)return n.copy(a);const y=p*u-c*b;if(y<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Ep,l);const x=d*b-p*f;if(x<=0&&f-d>=0&&p-b>=0)return y7.subVectors(a,i),l=(f-d)/(f-d+(p-b)),n.copy(i).addScaledVector(y7,l);const v=1/(x+y+m);return o=y*v,l=m*v,n.copy(r).addScaledVector(Np,o).addScaledVector(Ep,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const nte={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},dd={h:0,s:0,l:0},mw={h:0,s:0,l:0};function qk(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let an=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=_a){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=xL(e,1),n=wa(n,0,1),r=wa(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=qk(o,a,e+1/3),this.g=qk(o,a,e),this.b=qk(o,a,e-1/3)}return mr.toWorkingColorSpace(this,i),this}setStyle(e,n=_a){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=_a){const r=nte[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=ug(e.r),this.g=ug(e.g),this.b=ug(e.b),this}copyLinearToSRGB(e){return this.r=Ok(e.r),this.g=Ok(e.g),this.b=Ok(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_a){return mr.fromWorkingColorSpace(Da.copy(this),e),Math.round(wa(Da.r*255,0,255))*65536+Math.round(wa(Da.g*255,0,255))*256+Math.round(wa(Da.b*255,0,255))}getHexString(e=_a){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=mr.workingColorSpace){mr.fromWorkingColorSpace(Da.copy(this),n);const r=Da.r,i=Da.g,a=Da.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(Da.copy(this),n),e.r=Da.r,e.g=Da.g,e.b=Da.b,e}getStyle(e=_a){mr.fromWorkingColorSpace(Da.copy(this),e);const n=Da.r,r=Da.g,i=Da.b;return e!==_a?`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(dd),this.setHSL(dd.h+e,dd.s+n,dd.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(dd),e.getHSL(mw);const r=a0(dd.h,mw.h,n),i=a0(dd.s,mw.s,n),a=a0(dd.l,mw.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 Da=new an;an.NAMES=nte;let m5e=0;class dx extends pm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:m5e++}),this.uuid=cu(),this.name="",this.type="Material",this.blending=cg,this.side=ih,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wR,this.blendDst=SR,this.blendEquation=af,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new an(0,0,0),this.blendAlpha=0,this.depthFunc=WS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=s7,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=bp,this.stencilZFail=bp,this.stencilZPass=bp,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!==cg&&(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!==wR&&(r.blendSrc=this.blendSrc),this.blendDst!==SR&&(r.blendDst=this.blendDst),this.blendEquation!==af&&(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!==WS&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==s7&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==bp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==bp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==bp&&(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 rte extends dx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new an(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=mL,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Si=new Be,pw=new fn;class Xs{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=TR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=tu,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)pw.fromBufferAttribute(this,n),pw.applyMatrix3(e),this.setXY(n,pw.x,pw.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=Fl(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=Fl(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=Fl(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=Fl(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=Fl(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!==TR&&(e.usage=this.usage),e}}class ite extends Xs{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class ate extends Xs{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class gi extends Xs{constructor(e,n,r){super(new Float32Array(e),n,r)}}let p5e=0;const mo=new Ar,Kk=new es,Ap=new Be,Us=new ko,Cb=new ko,Wi=new Be;class Ha extends pm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:p5e++}),this.uuid=cu(),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(Zee(e)?ate:ite)(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 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 Kk.lookAt(e),Kk.updateMatrix(),this.applyMatrix4(Kk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ap).negate(),this.translate(Ap.x,Ap.y,Ap.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 gi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ko);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Be(-1/0,-1/0,-1/0),new Be(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];Us.setFromBufferAttribute(a),this.morphTargetsRelative?(Wi.addVectors(this.boundingBox.min,Us.min),this.boundingBox.expandByPoint(Wi),Wi.addVectors(this.boundingBox.max,Us.max),this.boundingBox.expandByPoint(Wi)):(this.boundingBox.expandByPoint(Us.min),this.boundingBox.expandByPoint(Us.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xl);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Be,1/0);return}if(e){const r=this.boundingSphere.center;if(Us.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Cb.setFromBufferAttribute(l),this.morphTargetsRelative?(Wi.addVectors(Us.min,Cb.min),Us.expandByPoint(Wi),Wi.addVectors(Us.max,Cb.max),Us.expandByPoint(Wi)):(Us.expandByPoint(Cb.min),Us.expandByPoint(Cb.max))}Us.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Wi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Wi));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Wi.fromBufferAttribute(l,u),c&&(Ap.fromBufferAttribute(e,u),Wi.add(Ap)),i=Math.max(i,r.distanceToSquared(Wi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Xs(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new Be,d[R]=new Be;const f=new Be,m=new Be,p=new Be,b=new fn,y=new fn,x=new fn,v=new Be,S=new Be;function M(R,U,O){f.fromArray(i,R*3),m.fromArray(i,U*3),p.fromArray(i,O*3),b.fromArray(o,R*2),y.fromArray(o,U*2),x.fromArray(o,O*2),m.sub(f),p.sub(f),y.sub(b),x.sub(b);const q=1/(y.x*x.y-x.x*y.y);isFinite(q)&&(v.copy(m).multiplyScalar(x.y).addScaledVector(p,-y.y).multiplyScalar(q),S.copy(p).multiplyScalar(y.x).addScaledVector(m,-x.x).multiplyScalar(q),u[R].add(v),u[U].add(v),u[O].add(v),d[R].add(S),d[U].add(S),d[O].add(S))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let R=0,U=A.length;R<U;++R){const O=A[R],q=O.start,j=O.count;for(let W=q,K=q+j;W<K;W+=3)M(r[W+0],r[W+1],r[W+2])}const T=new Be,k=new Be,E=new Be,D=new Be;function C(R){E.fromArray(a,R*3),D.copy(E);const U=u[R];T.copy(U),T.sub(E.multiplyScalar(E.dot(U))).normalize(),k.crossVectors(D,U);const q=k.dot(d[R])<0?-1:1;c[R*4]=T.x,c[R*4+1]=T.y,c[R*4+2]=T.z,c[R*4+3]=q}for(let R=0,U=A.length;R<U;++R){const O=A[R],q=O.start,j=O.count;for(let W=q,K=q+j;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 Xs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let m=0,p=r.count;m<p;m++)r.setXYZ(m,0,0,0);const i=new Be,a=new Be,o=new Be,l=new Be,c=new Be,u=new Be,d=new Be,f=new Be;if(e)for(let m=0,p=e.count;m<p;m+=3){const b=e.getX(m+0),y=e.getX(m+1),x=e.getX(m+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let m=0,p=n.count;m<p;m+=3)i.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),o.fromBufferAttribute(n,m+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(m+0,d.x,d.y,d.z),r.setXYZ(m+1,d.x,d.y,d.z),r.setXYZ(m+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Wi.fromBufferAttribute(e,n),Wi.normalize(),e.setXYZ(n,Wi.x,Wi.y,Wi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,m=new u.constructor(c.length*d);let p=0,b=0;for(let y=0,x=c.length;y<x;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)m[b++]=u[p++]}return new Xs(m,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ha,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const m=u[d],p=e(m,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,m=u.length;f<m;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let m=0,p=f.length;m<p;m++)d.push(f[m].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const v7=new Ar,qh=new bL,gw=new Xl,_7=new Be,Tp=new Be,Cp=new Be,kp=new Be,Xk=new Be,xw=new Be,bw=new fn,yw=new fn,vw=new fn,w7=new Be,S7=new Be,M7=new Be,_w=new Be,ww=new Be;class il extends es{constructor(e=new Ha,n=new rte){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){xw.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?xw.addScaledVector(Xk,d):xw.addScaledVector(Xk.sub(n),d))}n.add(xw)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),gw.copy(r.boundingSphere),gw.applyMatrix4(a),qh.copy(e.ray).recast(e.near),!(gw.containsPoint(qh.origin)===!1&&(qh.intersectSphere(gw,_7)===null||qh.origin.distanceToSquared(_7)>(e.far-e.near)**2))&&(v7.copy(a).invert(),qh.copy(e.ray).applyMatrix4(v7),!(r.boundingBox!==null&&qh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,qh)))}_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),D=l.getX(A+2);i=Sw(this,v,e,r,u,d,f,k,E,D),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=Sw(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,D=A+2;i=Sw(this,v,e,r,u,d,f,k,E,D),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=Sw(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===Ss?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===ih,l),c===null)return null;ww.copy(l),ww.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(ww);return u<n.near||u>n.far?null:{distance:u,point:ww.clone(),object:t}}function Sw(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,Tp),t.getVertexPosition(c,Cp),t.getVertexPosition(u,kp);const d=g5e(t,e,n,r,Tp,Cp,kp,_w);if(d){i&&(bw.fromBufferAttribute(i,l),yw.fromBufferAttribute(i,c),vw.fromBufferAttribute(i,u),d.uv=Zo.getInterpolation(_w,Tp,Cp,kp,bw,yw,vw,new fn)),a&&(bw.fromBufferAttribute(a,l),yw.fromBufferAttribute(a,c),vw.fromBufferAttribute(a,u),d.uv1=Zo.getInterpolation(_w,Tp,Cp,kp,bw,yw,vw,new fn),d.uv2=d.uv1),o&&(w7.fromBufferAttribute(o,l),S7.fromBufferAttribute(o,c),M7.fromBufferAttribute(o,u),d.normal=Zo.getInterpolation(_w,Tp,Cp,kp,w7,S7,M7,new Be),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Be,materialIndex:0};Zo.getNormal(Tp,Cp,kp,f.normal),d.face=f}return d}class Xy extends Ha{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let m=0,p=0;b("z","y","x",-1,-1,r,n,e,o,a,0),b("z","y","x",1,-1,r,n,-e,o,a,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new gi(u,3)),this.setAttribute("normal",new gi(d,3)),this.setAttribute("uv",new gi(f,2));function b(y,x,v,S,M,A,T,k,E,D,C){const R=A/E,U=T/D,O=A/2,q=T/2,j=k/2,W=E+1,K=D+1;let G=0,Q=0;const te=new Be;for(let J=0;J<K;J++){const z=J*U-q;for(let V=0;V<W;V++){const ne=V*R-O;te[y]=ne*S,te[x]=z*M,te[v]=j,u.push(te.x,te.y,te.z),te[y]=0,te[x]=0,te[v]=k>0?1:-1,d.push(te.x,te.y,te.z),f.push(V/E),f.push(1-J/D),G+=1}}for(let J=0;J<D;J++)for(let z=0;z<E;z++){const V=m+z+W*J,ne=m+z+W*(J+1),ae=m+(z+1)+W*(J+1),he=m+(z+1)+W*J;c.push(V,ne,he),c.push(ne,ae,he),Q+=6}l.addGroup(p,Q,C),p+=Q,m+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Og(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function Ka(t){const e={};for(let n=0;n<t.length;n++){const r=Og(t[n]);for(const i in r)e[i]=r[i]}return e}function x5e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function ste(t){return t.getRenderTarget()===null?t.outputColorSpace:mr.workingColorSpace}const yL={clone:Og,merge:Ka};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 ah extends dx{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=Og(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 ote extends es{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ar,this.projectionMatrix=new Ar,this.projectionMatrixInverse=new Ar,this.coordinateSystem=Vl}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class zs extends ote{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=ny*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(i0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ny*2*Math.atan(Math.tan(i0*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,r,i,a,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(i0*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const jp=-90,Pp=1;class v5e extends es{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new zs(jp,Pp,e,n);i.layers=this.layers,this.add(i);const a=new zs(jp,Pp,e,n);a.layers=this.layers,this.add(a);const o=new zs(jp,Pp,e,n);o.layers=this.layers,this.add(o);const l=new zs(jp,Pp,e,n);l.layers=this.layers,this.add(l);const c=new zs(jp,Pp,e,n);c.layers=this.layers,this.add(c);const u=new zs(jp,Pp,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===ty)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 lte extends Ms{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Pg,super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class _5e extends rm{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(s0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===jf?_a:Eo),this.texture=new lte(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Mo}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new Xy(5,5,5),a=new ah({name:"CubemapFromEquirect",uniforms:Og(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ss,blending:Hd});a.uniforms.tEquirect.value=n;const o=new il(i,a),l=n.minFilter;return n.minFilter===J0&&(n.minFilter=Mo),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 Yk=new Be,w5e=new Be,S5e=new Tn;class vd{constructor(e=new Be(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=Yk.subVectors(r,n).cross(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(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||S5e.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 Kh=new Xl,Mw=new Be;class gE{constructor(e=new vd,n=new vd,r=new vd,i=new vd,a=new vd,o=new vd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Vl){const r=this.planes,i=e.elements,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],m=i[7],p=i[8],b=i[9],y=i[10],x=i[11],v=i[12],S=i[13],M=i[14],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===Vl)r[5].setComponents(c+l,m+f,x+y,A+M).normalize();else if(n===ty)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(),Kh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Kh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Kh)}intersectsSprite(e){return Kh.center.set(0,0,0),Kh.radius=.7071067811865476,Kh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Kh)}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(Mw.x=i.normal.x>0?e.max.x:e.min.x,Mw.y=i.normal.y>0?e.max.y:e.min.y,Mw.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Mw)<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 cte(){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 vL extends Ha{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,m=n/c,p=[],b=[],y=[],x=[];for(let v=0;v<d;v++){const S=v*m-o;for(let M=0;M<u;M++){const 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 gi(b,3)),this.setAttribute("normal",new gi(y,3)),this.setAttribute("uv",new gi(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vL(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>
- }`,Sn={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 an(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},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},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 fn(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 an(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 an(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 an(16777215)},opacity:{value:1},center:{value:new fn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Tn},alphaMap:{value:null},alphaMapTransform:{value:new Tn},alphaTest:{value:0}}},xs={basic:{uniforms:Ka([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:Sn.meshbasic_vert,fragmentShader:Sn.meshbasic_frag},lambert:{uniforms:Ka([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 an(0)}}]),vertexShader:Sn.meshlambert_vert,fragmentShader:Sn.meshlambert_frag},phong:{uniforms:Ka([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 an(0)},specular:{value:new an(1118481)},shininess:{value:30}}]),vertexShader:Sn.meshphong_vert,fragmentShader:Sn.meshphong_frag},standard:{uniforms:Ka([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 an(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag},toon:{uniforms:Ka([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new an(0)}}]),vertexShader:Sn.meshtoon_vert,fragmentShader:Sn.meshtoon_frag},matcap:{uniforms:Ka([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:Sn.meshmatcap_vert,fragmentShader:Sn.meshmatcap_frag},points:{uniforms:Ka([Dt.points,Dt.fog]),vertexShader:Sn.points_vert,fragmentShader:Sn.points_frag},dashed:{uniforms:Ka([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Sn.linedashed_vert,fragmentShader:Sn.linedashed_frag},depth:{uniforms:Ka([Dt.common,Dt.displacementmap]),vertexShader:Sn.depth_vert,fragmentShader:Sn.depth_frag},normal:{uniforms:Ka([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:Sn.meshnormal_vert,fragmentShader:Sn.meshnormal_frag},sprite:{uniforms:Ka([Dt.sprite,Dt.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}},vertexShader:Sn.backgroundCube_vert,fragmentShader:Sn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Sn.cube_vert,fragmentShader:Sn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Sn.equirect_vert,fragmentShader:Sn.equirect_frag},distanceRGBA:{uniforms:Ka([Dt.common,Dt.displacementmap,{referencePosition:{value:new Be},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Sn.distanceRGBA_vert,fragmentShader:Sn.distanceRGBA_frag},shadow:{uniforms:Ka([Dt.lights,Dt.fog,{color:{value:new an(0)},opacity:{value:1}}]),vertexShader:Sn.shadow_vert,fragmentShader:Sn.shadow_frag}};xs.physical={uniforms:Ka([xs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Tn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Tn},clearcoatNormalScale:{value:new fn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Tn},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 an(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 fn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Tn},attenuationDistance:{value:0},attenuationColor:{value:new an(0)},specularColor:{value:new an(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Tn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Tn},anisotropyVector:{value:new fn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Tn}}]),vertexShader:Sn.meshphysical_vert,fragmentShader:Sn.meshphysical_frag};const Nw={r:0,b:0,g:0};function iBe(t,e,n,r,i,a,o){const l=new an(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===mE)?(d===void 0&&(d=new il(new Xy(1,1,1),new ah({name:"BackgroundCubeMaterial",uniforms:Og(xs.backgroundCube.uniforms),vertexShader:xs.backgroundCube.vertexShader,fragmentShader:xs.backgroundCube.fragmentShader,side:Ss,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(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)!==Pr,(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 il(new vL(2,2),new ah({name:"BackgroundMaterial",uniforms:Og(xs.background.uniforms),vertexShader:xs.background.vertexShader,fragmentShader:xs.background.fragmentShader,side:ih,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)!==Pr,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(Nw,ste(t)),r.buffers.color.setClear(Nw.r,Nw.g,Nw.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(j,W,K,G,Q){let te=!1;if(o){const J=y(G,K,W);u!==J&&(u=J,p(u.object)),te=v(j,G,K,Q),te&&S(j,G,K,Q)}else{const J=W.wireframe===!0;(u.geometry!==G.id||u.program!==K.id||u.wireframe!==J)&&(u.geometry=G.id,u.program=K.id,u.wireframe=J,te=!0)}Q!==null&&n.update(Q,t.ELEMENT_ARRAY_BUFFER),(te||d)&&(d=!1,D(j,W,K,G),Q!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Q).buffer))}function m(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(j){return r.isWebGL2?t.bindVertexArray(j):a.bindVertexArrayOES(j)}function b(j){return r.isWebGL2?t.deleteVertexArray(j):a.deleteVertexArrayOES(j)}function y(j,W,K){const G=K.wireframe===!0;let Q=l[j.id];Q===void 0&&(Q={},l[j.id]=Q);let te=Q[W.id];te===void 0&&(te={},Q[W.id]=te);let J=te[G];return J===void 0&&(J=x(m()),te[G]=J),J}function x(j){const W=[],K=[],G=[];for(let Q=0;Q<i;Q++)W[Q]=0,K[Q]=0,G[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:K,attributeDivisors:G,object:j,attributes:{},index:null}}function v(j,W,K,G){const Q=u.attributes,te=W.attributes;let J=0;const z=K.getAttributes();for(const V in z)if(z[V].location>=0){const ae=Q[V];let he=te[V];if(he===void 0&&(V==="instanceMatrix"&&j.instanceMatrix&&(he=j.instanceMatrix),V==="instanceColor"&&j.instanceColor&&(he=j.instanceColor)),ae===void 0||ae.attribute!==he||he&&ae.data!==he.data)return!0;J++}return u.attributesNum!==J||u.index!==G}function S(j,W,K,G){const Q={},te=W.attributes;let J=0;const z=K.getAttributes();for(const V in z)if(z[V].location>=0){let ae=te[V];ae===void 0&&(V==="instanceMatrix"&&j.instanceMatrix&&(ae=j.instanceMatrix),V==="instanceColor"&&j.instanceColor&&(ae=j.instanceColor));const he={};he.attribute=ae,ae&&ae.data&&(he.data=ae.data),Q[V]=he,J++}u.attributes=Q,u.attributesNum=J,u.index=G}function M(){const j=u.newAttributes;for(let W=0,K=j.length;W<K;W++)j[W]=0}function A(j){T(j,0)}function T(j,W){const K=u.newAttributes,G=u.enabledAttributes,Q=u.attributeDivisors;K[j]=1,G[j]===0&&(t.enableVertexAttribArray(j),G[j]=1),Q[j]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,W),Q[j]=W)}function k(){const j=u.newAttributes,W=u.enabledAttributes;for(let K=0,G=W.length;K<G;K++)W[K]!==j[K]&&(t.disableVertexAttribArray(K),W[K]=0)}function E(j,W,K,G,Q,te,J){J===!0?t.vertexAttribIPointer(j,W,K,Q,te):t.vertexAttribPointer(j,W,K,G,Q,te)}function D(j,W,K,G){if(r.isWebGL2===!1&&(j.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;M();const Q=G.attributes,te=K.getAttributes(),J=W.defaultAttributeValues;for(const z in te){const V=te[z];if(V.location>=0){let ne=Q[z];if(ne===void 0&&(z==="instanceMatrix"&&j.instanceMatrix&&(ne=j.instanceMatrix),z==="instanceColor"&&j.instanceColor&&(ne=j.instanceColor)),ne!==void 0){const ae=ne.normalized,he=ne.itemSize,pe=n.get(ne);if(pe===void 0)continue;const ie=pe.buffer,Ee=pe.type,xe=pe.bytesPerElement,Ne=r.isWebGL2===!0&&(Ee===t.INT||Ee===t.UNSIGNED_INT||ne.gpuType===zee);if(ne.isInterleavedBufferAttribute){const _e=ne.data,le=_e.stride,Ve=ne.offset;if(_e.isInstancedInterleavedBuffer){for(let H=0;H<V.locationSize;H++)T(V.location+H,_e.meshPerAttribute);j.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=_e.meshPerAttribute*_e.count)}else for(let H=0;H<V.locationSize;H++)A(V.location+H);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let H=0;H<V.locationSize;H++)E(V.location+H,he/V.locationSize,Ee,ae,le*xe,(Ve+he/V.locationSize*H)*xe,Ne)}else{if(ne.isInstancedBufferAttribute){for(let _e=0;_e<V.locationSize;_e++)T(V.location+_e,ne.meshPerAttribute);j.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let _e=0;_e<V.locationSize;_e++)A(V.location+_e);t.bindBuffer(t.ARRAY_BUFFER,ie);for(let _e=0;_e<V.locationSize;_e++)E(V.location+_e,he/V.locationSize,Ee,ae,he*xe,he/V.locationSize*_e*xe,Ne)}}else if(J!==void 0){const ae=J[z];if(ae!==void 0)switch(ae.length){case 2:t.vertexAttrib2fv(V.location,ae);break;case 3:t.vertexAttrib3fv(V.location,ae);break;case 4:t.vertexAttrib4fv(V.location,ae);break;default:t.vertexAttrib1fv(V.location,ae)}}}}k()}function C(){O();for(const j in l){const W=l[j];for(const K in W){const G=W[K];for(const Q in G)b(G[Q].object),delete G[Q];delete W[K]}delete l[j]}}function R(j){if(l[j.id]===void 0)return;const W=l[j.id];for(const K in W){const G=W[K];for(const Q in G)b(G[Q].object),delete G[Q];delete W[K]}delete l[j.id]}function U(j){for(const W in l){const K=l[W];if(K[j.id]===void 0)continue;const G=K[j.id];for(const Q in G)b(G[Q].object),delete G[Q];delete K[j.id]}}function O(){q(),d=!0,u!==c&&(u=c,p(u.object))}function q(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:O,resetDefaultState:q,dispose:C,releaseStatesOfGeometry:R,releaseStatesOfProgram:U,initAttributes:M,enableAttribute: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 vd,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 cBe(t){let e=new WeakMap;function n(o,l){return l===MR?o.mapping=Pg:l===NR&&(o.mapping=Rg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===MR||l===NR)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 ote{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 Qp=4,N7=[.125,.215,.35,.446,.526,.582],sf=20,Zk=new uBe,E7=new an;let Qk=null,Jk=0,ej=0;const tf=(1+Math.sqrt(5))/2,Rp=1/tf,A7=[new Be(1,1,1),new Be(-1,1,1),new Be(1,1,-1),new Be(-1,1,-1),new Be(0,tf,Rp),new Be(0,tf,-Rp),new Be(Rp,0,tf),new Be(-Rp,0,tf),new Be(tf,Rp,0),new Be(-tf,Rp,0)];class T7{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,r=.1,i=100){Qk=this._renderer.getRenderTarget(),Jk=this._renderer.getActiveCubeFace(),ej=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=j7(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=k7(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Qk,Jk,ej),e.scissorTest=!1,Ew(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Pg||e.mapping===Rg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Qk=this._renderer.getRenderTarget(),Jk=this._renderer.getActiveCubeFace(),ej=this._renderer.getActiveMipmapLevel();const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:Mo,minFilter:Mo,generateMipmaps:!1,type:ey,format:No,colorSpace:Su,depthBuffer:!1},i=C7(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=C7(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=dBe(a)),this._blurMaterial=hBe(a,e,n)}return i}_compileMaterial(e){const n=new il(this._lodPlanes[0],e);this._renderer.compile(n,Zk)}_sceneToCubeUV(e,n,r,i){const l=new zs(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,m=d.toneMapping;d.getClearColor(E7),d.toneMapping=Vd,d.autoClear=!1;const p=new rte({name:"PMREM.Background",side:Ss,depthWrite:!1,depthTest:!1}),b=new il(new Xy,p);let y=!1;const x=e.background;x?x.isColor&&(p.color.copy(x),e.background=null,y=!0):(p.color.copy(E7),y=!0);for(let v=0;v<6;v++){const S=v%3;S===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):S===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const M=this._cubeSize;Ew(i,S*M,v>2?M:0,M,M),d.setRenderTarget(i),y&&d.render(b,l),d.render(e,l)}b.geometry.dispose(),b.material.dispose(),d.toneMapping=m,d.autoClear=f,e.background=x}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Pg||e.mapping===Rg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=j7()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=k7());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new il(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Ew(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Zk)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=A7[(i-1)%A7.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new il(this._lodPlanes[i],u),m=u.uniforms,p=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*sf-1),y=a/b,x=isFinite(a)?1+Math.floor(d*y):sf;x>sf&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${sf}`);const v=[];let S=0;for(let E=0;E<sf;++E){const D=E/y,C=Math.exp(-D*D/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-Qp?i-M+Qp:0),k=4*(this._cubeSize-A);Ew(n,T,k,3*A,2*A),c.setRenderTarget(n),c.render(f,Zk)}}function dBe(t){const e=[],n=[],r=[];let i=t;const a=t-Qp+1+N7.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Qp?c=N7[o-t+Qp-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,D=k>2?0:-1,C=[E,D,0,E+2/3,D,0,E+2/3,D+1,0,E,D,0,E+2/3,D+1,0,E,D+1,0];S.set(C,y*b*k),M.set(m,x*b*k);const R=[k,k,k,k,k,k];A.set(R,v*b*k)}const T=new Ha;T.setAttribute("position",new Xs(S,y)),T.setAttribute("uv",new Xs(M,x)),T.setAttribute("faceIndex",new Xs(A,v)),e.push(T),i>Qp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function C7(t,e,n){const r=new rm(t,e,n);return r.texture.mapping=mE,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Ew(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(sf),i=new Be(0,1,0);return new ah({name:"SphericalGaussianBlur",defines:{n:sf,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:_L(),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:Hd,depthTest:!1,depthWrite:!1})}function k7(){return new ah({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_L(),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:Hd,depthTest:!1,depthWrite:!1})}function j7(){return new ah({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_L(),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:Hd,depthTest:!1,depthWrite:!1})}function _L(){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===MR||c===NR,d=c===Pg||c===Rg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new T7(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new T7(t));const m=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,m),l.addEventListener("dispose",a),m.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function 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(Zee(m)?ate:ite)(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||[],D=d.morphAttributes.color||[];let C=0;M===!0&&(C=1),A===!0&&(C=2),T===!0&&(C=3);let R=d.attributes.position.count*C,U=1;R>e.maxTextureSize&&(U=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const O=new Float32Array(R*U*4*y),q=new ete(O,R,U,y);q.type=tu,q.needsUpdate=!0;const j=C*4;for(let K=0;K<y;K++){const G=k[K],Q=E[K],te=D[K],J=R*U*4*K;for(let z=0;z<G.count;z++){const V=z*j;M===!0&&(o.fromBufferAttribute(G,z),O[J+V+0]=o.x,O[J+V+1]=o.y,O[J+V+2]=o.z,O[J+V+3]=0),A===!0&&(o.fromBufferAttribute(Q,z),O[J+V+4]=o.x,O[J+V+5]=o.y,O[J+V+6]=o.z,O[J+V+7]=0),T===!0&&(o.fromBufferAttribute(te,z),O[J+V+8]=o.x,O[J+V+9]=o.y,O[J+V+10]=o.z,O[J+V+11]=te.itemSize===4?o.w:1)}}x={count:y,texture:q,size:new fn(R,U)},a.set(d,x),d.addEventListener("dispose",W)}let v=0;for(let M=0;M<m.length;M++)v+=m[M];const S=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",x.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",x.size)}else{const b=m===void 0?0:m.length;let y=r[d.id];if(y===void 0||y.length!==b){y=[];for(let 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 ute extends Ms{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:kf,d!==kf&&d!==Dg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===kf&&(r=Pd),r===void 0&&d===Dg&&(r=Cf),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:va,this.minFilter=c!==void 0?c:va,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 dte=new Ms,hte=new ute(1,1);hte.compareFunction=Xee;const fte=new ete,mte=new a5e,pte=new lte,P7=[],R7=[],D7=new Float32Array(16),O7=new Float32Array(9),L7=new Float32Array(4);function hx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=P7[i];if(a===void 0&&(a=new Float32Array(i),P7[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ii(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 Fi(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function xE(t,e){let n=R7[e];n===void 0&&(n=new Int32Array(e),R7[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function 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(Ii(n,e))return;t.uniform2fv(this.addr,e),Fi(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(Ii(n,e))return;t.uniform3fv(this.addr,e),Fi(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(Ii(n,e))return;t.uniform4fv(this.addr,e),Fi(n,e)}}function EBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ii(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Fi(n,e)}else{if(Ii(n,r))return;L7.set(r),t.uniformMatrix2fv(this.addr,!1,L7),Fi(n,r)}}function ABe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ii(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Fi(n,e)}else{if(Ii(n,r))return;O7.set(r),t.uniformMatrix3fv(this.addr,!1,O7),Fi(n,r)}}function TBe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ii(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Fi(n,e)}else{if(Ii(n,r))return;D7.set(r),t.uniformMatrix4fv(this.addr,!1,D7),Fi(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(Ii(n,e))return;t.uniform2iv(this.addr,e),Fi(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(Ii(n,e))return;t.uniform3iv(this.addr,e),Fi(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(Ii(n,e))return;t.uniform4iv(this.addr,e),Fi(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(Ii(n,e))return;t.uniform2uiv(this.addr,e),Fi(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(Ii(n,e))return;t.uniform3uiv(this.addr,e),Fi(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(Ii(n,e))return;t.uniform4uiv(this.addr,e),Fi(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?hte:dte;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||mte,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||pte,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||fte,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=hx(e,this.size,2);t.uniform2fv(this.addr,n)}function VBe(t,e){const n=hx(e,this.size,3);t.uniform3fv(this.addr,n)}function GBe(t,e){const n=hx(e,this.size,4);t.uniform4fv(this.addr,n)}function WBe(t,e){const n=hx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function qBe(t,e){const n=hx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function KBe(t,e){const n=hx(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=xE(n,i);Ii(r,a)||(t.uniform1iv(this.addr,a),Fi(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||dte,a[o])}function i8e(t,e,n){const r=this.cache,i=e.length,a=xE(n,i);Ii(r,a)||(t.uniform1iv(this.addr,a),Fi(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||mte,a[o])}function a8e(t,e,n){const r=this.cache,i=e.length,a=xE(n,i);Ii(r,a)||(t.uniform1iv(this.addr,a),Fi(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||pte,a[o])}function s8e(t,e,n){const r=this.cache,i=e.length,a=xE(n,i);Ii(r,a)||(t.uniform1iv(this.addr,a),Fi(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||fte,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 tj=/(\w+)(\])?(\[|\.)?/g;function I7(t,e){t.seq.push(e),t.map[e.id]=e}function d8e(t,e,n){const r=t.name,i=r.length;for(tj.lastIndex=0;;){const a=tj.exec(r),o=tj.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){I7(n,u===void 0?new l8e(l,t,e):new c8e(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new u8e(l),I7(n,f)),n=f}}}class v1{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 F7(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===XS&&n===KS?r="LinearDisplayP3ToLinearSRGB":e===KS&&n===XS&&(r="LinearSRGBToLinearDisplayP3"),t){case Su:case pE:return[r,"LinearTransferOETF"];case _a:case gL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function U7(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+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(Gb).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 Gb(t){return t!==""}function z7(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function B7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const _8e=/^[ \t]*#include +<([\w\d./]+)>/gm;function jR(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=Sn[e];if(n===void 0){const r=w8e.get(e);if(r!==void 0)n=Sn[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return jR(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 $7(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 H7(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function E8e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===Fee?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===VIe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Vc&&(e="SHADOWMAP_TYPE_VSM"),e}function A8e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Pg:case Rg:e="ENVMAP_TYPE_CUBE";break;case mE:e="ENVMAP_TYPE_CUBE_UV";break}return e}function T8e(t){let e="ENVMAP_MODE_REFLECTION";return t.envMap&&t.envMapMode===Rg&&(e="ENVMAP_MODE_REFRACTION"),e}function C8e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case mL: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(Gb).join(`
- `),x.length>0&&(x+=`
- `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(Gb).join(`
- `),v.length>0&&(v+=`
- `)):(x=[H7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Gb).join(`
- `),v=[p,H7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Vd?"#define TONE_MAPPING":"",n.toneMapping!==Vd?Sn.tonemapping_pars_fragment:"",n.toneMapping!==Vd?x8e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Sn.colorspace_pars_fragment,g8e("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Gb).join(`
- `)),o=jR(o),o=z7(o,n),o=B7(o,n),l=jR(l),l=z7(l,n),l=B7(l,n),o=$7(o),l=$7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===o7?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===o7?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+v);const M=S+x+o,A=S+v+l,T=F7(i,i.VERTEX_SHADER,M),k=F7(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 O=i.getProgramInfoLog(y).trim(),q=i.getShaderInfoLog(T).trim(),j=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 G=U7(i,T,"vertex"),Q=U7(i,k,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+O+`
- `+G+`
- `+Q)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(q===""||j==="")&&(K=!1);K&&(U.diagnostics={runnable:W,programLog:O,vertexShader:{log:q,prefix:x},fragmentShader:{log:j,prefix:v}})}i.deleteShader(T),i.deleteShader(k),D=new v1(i,y),C=v8e(i,y)}let D;this.getUniforms=function(){return D===void 0&&E(this),D};let C;this.getAttributes=function(){return C===void 0&&E(this),C};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,h8e)),R},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 tte,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,R,U,O,q){const j=O.fog,W=q.geometry,K=C.isMeshStandardMaterial?O.environment:null,G=(C.isMeshStandardMaterial?n:e).get(C.envMap||K),Q=G&&G.mapping===mE?G.image.height:null,te=b[C.type];C.precision!==null&&(p=i.getMaxPrecision(C.precision),p!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",p,"instead."));const J=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,z=J!==void 0?J.length:0;let V=0;W.morphAttributes.position!==void 0&&(V=1),W.morphAttributes.normal!==void 0&&(V=2),W.morphAttributes.color!==void 0&&(V=3);let ne,ae,he,pe;if(te){const ln=xs[te];ne=ln.vertexShader,ae=ln.fragmentShader}else ne=C.vertexShader,ae=C.fragmentShader,c.update(C),he=c.getVertexShaderID(C),pe=c.getFragmentShaderID(C);const ie=t.getRenderTarget(),Ee=q.isInstancedMesh===!0,xe=q.isBatchedMesh===!0,Ne=!!C.map,_e=!!C.matcap,le=!!G,Ve=!!C.aoMap,H=!!C.lightMap,ee=!!C.bumpMap,X=!!C.normalMap,B=!!C.displacementMap,I=!!C.emissiveMap,ue=!!C.metalnessMap,Ae=!!C.roughnessMap,Ie=C.anisotropy>0,ce=C.clearcoat>0,$=C.iridescence>0,L=C.sheen>0,Y=C.transmission>0,be=Ie&&!!C.anisotropyMap,Se=ce&&!!C.clearcoatMap,se=ce&&!!C.clearcoatNormalMap,Pe=ce&&!!C.clearcoatRoughnessMap,Re=$&&!!C.iridescenceMap,Xe=$&&!!C.iridescenceThicknessMap,et=L&&!!C.sheenColorMap,Je=L&&!!C.sheenRoughnessMap,oe=!!C.specularMap,ye=!!C.specularColorMap,je=!!C.specularIntensityMap,$e=Y&&!!C.transmissionMap,ft=Y&&!!C.thicknessMap,re=!!C.gradientMap,ke=!!C.alphaMap,ve=C.alphaTest>0,Fe=!!C.alphaHash,Ue=!!C.extensions,Te=!!W.attributes.uv1,qe=!!W.attributes.uv2,bt=!!W.attributes.uv3;let Pt=Vd;return C.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(Pt=t.toneMapping),{isWebGL2:d,shaderID:te,shaderType:C.type,shaderName:C.name,vertexShader:ne,fragmentShader:ae,defines:C.defines,customVertexShaderID:he,customFragmentShaderID:pe,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:p,batching:xe,instancing:Ee,instancingColor:Ee&&q.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:ie===null?t.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:Su,map:Ne,matcap:_e,envMap:le,envMapMode:le&&G.mapping,envMapCubeUVHeight:Q,aoMap:Ve,lightMap:H,bumpMap:ee,normalMap:X,displacementMap:m&&B,emissiveMap:I,normalMapObjectSpace:X&&C.normalMapType===PFe,normalMapTangentSpace:X&&C.normalMapType===Kee,metalnessMap:ue,roughnessMap:Ae,anisotropy:Ie,anisotropyMap:be,clearcoat:ce,clearcoatMap:Se,clearcoatNormalMap:se,clearcoatRoughnessMap:Pe,iridescence:$,iridescenceMap:Re,iridescenceThicknessMap:Xe,sheen:L,sheenColorMap:et,sheenRoughnessMap:Je,specularMap:oe,specularColorMap:ye,specularIntensityMap:je,transmission:Y,transmissionMap:$e,thicknessMap:ft,gradientMap:re,opaque:C.transparent===!1&&C.blending===cg,alphaMap:ke,alphaTest:ve,alphaHash:Fe,combine:C.combine,mapUv:Ne&&y(C.map.channel),aoMapUv:Ve&&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:ue&&y(C.metalnessMap.channel),roughnessMapUv:Ae&&y(C.roughnessMap.channel),anisotropyMapUv:be&&y(C.anisotropyMap.channel),clearcoatMapUv:Se&&y(C.clearcoatMap.channel),clearcoatNormalMapUv:se&&y(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Pe&&y(C.clearcoatRoughnessMap.channel),iridescenceMapUv:Re&&y(C.iridescenceMap.channel),iridescenceThicknessMapUv:Xe&&y(C.iridescenceThicknessMap.channel),sheenColorMapUv:et&&y(C.sheenColorMap.channel),sheenRoughnessMapUv:Je&&y(C.sheenRoughnessMap.channel),specularMapUv:oe&&y(C.specularMap.channel),specularColorMapUv:ye&&y(C.specularColorMap.channel),specularIntensityMapUv:je&&y(C.specularIntensityMap.channel),transmissionMapUv:$e&&y(C.transmissionMap.channel),thicknessMapUv:ft&&y(C.thicknessMap.channel),alphaMapUv:ke&&y(C.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(X||Ie),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:Te,vertexUv2s:qe,vertexUv3s:bt,pointsUvs:q.isPoints===!0&&!!W.attributes.uv&&(Ne||ke),fog:!!j,useFog:C.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:q.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numSpotLightMaps:R.spotLightMap.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numSpotLightShadowsWithMaps:R.numSpotLightShadowsWithMaps,numLightProbes:R.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:C.dithering,shadowMapEnabled:t.shadowMap.enabled&&U.length>0,shadowMapType:t.shadowMap.type,toneMapping:Pt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ne&&C.map.isVideoTexture===!0&&mr.getTransfer(C.map.colorSpace)===Pr,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===Yc,flipSided:C.side===Ss,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 R=[];if(C.shaderID?R.push(C.shaderID):(R.push(C.customVertexShaderID),R.push(C.customFragmentShaderID)),C.defines!==void 0)for(const U in C.defines)R.push(U),R.push(C.defines[U]);return C.isRawShaderMaterial===!1&&(S(R,C),M(R,C),R.push(t.outputColorSpace)),R.push(C.customProgramCacheKey),R.join()}function S(C,R){C.push(R.precision),C.push(R.outputColorSpace),C.push(R.envMapMode),C.push(R.envMapCubeUVHeight),C.push(R.mapUv),C.push(R.alphaMapUv),C.push(R.lightMapUv),C.push(R.aoMapUv),C.push(R.bumpMapUv),C.push(R.normalMapUv),C.push(R.displacementMapUv),C.push(R.emissiveMapUv),C.push(R.metalnessMapUv),C.push(R.roughnessMapUv),C.push(R.anisotropyMapUv),C.push(R.clearcoatMapUv),C.push(R.clearcoatNormalMapUv),C.push(R.clearcoatRoughnessMapUv),C.push(R.iridescenceMapUv),C.push(R.iridescenceThicknessMapUv),C.push(R.sheenColorMapUv),C.push(R.sheenRoughnessMapUv),C.push(R.specularMapUv),C.push(R.specularColorMapUv),C.push(R.specularIntensityMapUv),C.push(R.transmissionMapUv),C.push(R.thicknessMapUv),C.push(R.combine),C.push(R.fogExp2),C.push(R.sizeAttenuation),C.push(R.morphTargetsCount),C.push(R.morphAttributeCount),C.push(R.numDirLights),C.push(R.numPointLights),C.push(R.numSpotLights),C.push(R.numSpotLightMaps),C.push(R.numHemiLights),C.push(R.numRectAreaLights),C.push(R.numDirLightShadows),C.push(R.numPointLightShadows),C.push(R.numSpotLightShadows),C.push(R.numSpotLightShadowsWithMaps),C.push(R.numLightProbes),C.push(R.shadowMapType),C.push(R.toneMapping),C.push(R.numClippingPlanes),C.push(R.numClipIntersection),C.push(R.depthPacking)}function M(C,R){l.disableAll(),R.isWebGL2&&l.enable(0),R.supportsVertexTextures&&l.enable(1),R.instancing&&l.enable(2),R.instancingColor&&l.enable(3),R.matcap&&l.enable(4),R.envMap&&l.enable(5),R.normalMapObjectSpace&&l.enable(6),R.normalMapTangentSpace&&l.enable(7),R.clearcoat&&l.enable(8),R.iridescence&&l.enable(9),R.alphaTest&&l.enable(10),R.vertexColors&&l.enable(11),R.vertexAlphas&&l.enable(12),R.vertexUv1s&&l.enable(13),R.vertexUv2s&&l.enable(14),R.vertexUv3s&&l.enable(15),R.vertexTangents&&l.enable(16),R.anisotropy&&l.enable(17),R.alphaHash&&l.enable(18),R.batching&&l.enable(19),C.push(l.mask),l.disableAll(),R.fog&&l.enable(0),R.useFog&&l.enable(1),R.flatShading&&l.enable(2),R.logarithmicDepthBuffer&&l.enable(3),R.skinning&&l.enable(4),R.morphTargets&&l.enable(5),R.morphNormals&&l.enable(6),R.morphColors&&l.enable(7),R.premultipliedAlpha&&l.enable(8),R.shadowMapEnabled&&l.enable(9),R.useLegacyLights&&l.enable(10),R.doubleSided&&l.enable(11),R.flipSided&&l.enable(12),R.useDepthPacking&&l.enable(13),R.dithering&&l.enable(14),R.transmission&&l.enable(15),R.sheen&&l.enable(16),R.opaque&&l.enable(17),R.pointsUvs&&l.enable(18),R.decodeVideoTexture&&l.enable(19),C.push(l.mask)}function A(C){const R=b[C.type];let U;if(R){const O=xs[R];U=yL.clone(O.uniforms)}else U=C.uniforms;return U}function T(C,R){let U;for(let O=0,q=u.length;O<q;O++){const j=u[O];if(j.cacheKey===R){U=j,++U.usedTimes;break}}return U===void 0&&(U=new j8e(t,R,C,a),u.push(U)),U}function k(C){if(--C.usedTimes===0){const R=u.indexOf(C);u[R]=u[u.length-1],u.pop(),C.destroy()}}function E(C){c.remove(C)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:v,getUniforms:A,acquireProgram:T,releaseProgram:k,releaseShaderCache:E,programs:u,dispose:D}}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 V7(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function G7(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,m,p,b,y,x){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:m,material:p,groupOrder:b,renderOrder:f.renderOrder,z:y,group:x},t[e]=v):(v.id=f.id,v.object=f,v.geometry=m,v.material=p,v.groupOrder=b,v.renderOrder=f.renderOrder,v.z=y,v.group=x),e++,v}function l(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,m,p,b,y,x){const v=o(f,m,p,b,y,x);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,m){n.length>1&&n.sort(f||I8e),r.length>1&&r.sort(m||V7),i.length>1&&i.sort(m||V7)}function d(){for(let f=e,m=t.length;f<m;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function F8e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new G7,t.set(r,[o])):i>=a.length?(o=new G7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function 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 an};break;case"SpotLight":n={position:new Be,direction:new Be,color:new an,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Be,color:new an,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Be,skyColor:new an,groundColor:new an};break;case"RectAreaLight":n={color:new an,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 fn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fn,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 Ar,l=new Ar;function c(d,f){let m=0,p=0,b=0;for(let O=0;O<9;O++)i.probe[O].set(0,0,0);let y=0,x=0,v=0,S=0,M=0,A=0,T=0,k=0,E=0,D=0,C=0;d.sort($8e);const R=f===!0?Math.PI:1;for(let O=0,q=d.length;O<q;O++){const j=d[O],W=j.color,K=j.intensity,G=j.distance,Q=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)m+=W.r*K*R,p+=W.g*K*R,b+=W.b*K*R;else if(j.isLightProbe){for(let te=0;te<9;te++)i.probe[te].addScaledVector(j.sh.coefficients[te],K);C++}else if(j.isDirectionalLight){const te=n.get(j);if(te.color.copy(j.color).multiplyScalar(j.intensity*R),j.castShadow){const J=j.shadow,z=r.get(j);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]=j.shadow.matrix,A++}i.directional[y]=te,y++}else if(j.isSpotLight){const te=n.get(j);te.position.setFromMatrixPosition(j.matrixWorld),te.color.copy(W).multiplyScalar(K*R),te.distance=G,te.coneCos=Math.cos(j.angle),te.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),te.decay=j.decay,i.spot[v]=te;const J=j.shadow;if(j.map&&(i.spotLightMap[E]=j.map,E++,J.updateMatrices(j),j.castShadow&&D++),i.spotLightMatrix[v]=J.matrix,j.castShadow){const z=r.get(j);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(j.isRectAreaLight){const te=n.get(j);te.color.copy(W).multiplyScalar(K),te.halfWidth.set(j.width*.5,0,0),te.halfHeight.set(0,j.height*.5,0),i.rectArea[S]=te,S++}else if(j.isPointLight){const te=n.get(j);if(te.color.copy(j.color).multiplyScalar(j.intensity*R),te.distance=j.distance,te.decay=j.decay,j.castShadow){const J=j.shadow,z=r.get(j);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]=j.shadow.matrix,T++}i.point[x]=te,x++}else if(j.isHemisphereLight){const te=n.get(j);te.skyColor.copy(j.color).multiplyScalar(K*R),te.groundColor.copy(j.groundColor).multiplyScalar(K*R),i.hemi[M]=te,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-D,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=D,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 W7(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 W7(t,e),n.set(a,[c])):o>=l.length?(c=new W7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class G8e extends dx{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 dx{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const 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 gE;const i=new fn,a=new fn,o=new gr,l=new G8e({depthPacking:jFe}),c=new W8e,u={},d=n.maxTextureSize,f={[ih]:Ss,[Ss]:ih,[Yc]:Yc},m=new ah({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new fn},radius:{value:4}},vertexShader:q8e,fragmentShader:K8e}),p=m.clone();p.defines.HORIZONTAL_PASS=1;const b=new Ha;b.setAttribute("position",new Xs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new il(b,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Fee;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 D=t.getRenderTarget(),C=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),U=t.state;U.setBlending(Hd),U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const O=v!==Vc&&this.type===Vc,q=v===Vc&&this.type!==Vc;for(let j=0,W=T.length;j<W;j++){const K=T[j],G=K.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Q=G.getFrameExtents();if(i.multiply(Q),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,G.mapSize.y=a.y)),G.map===null||O===!0||q===!0){const J=this.type!==Vc?{minFilter:va,magFilter:va}:{};G.map!==null&&G.map.dispose(),G.map=new rm(i.x,i.y,J),G.map.texture.name=K.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const te=G.getViewportCount();for(let J=0;J<te;J++){const z=G.getViewport(J);o.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),U.viewport(o),G.updateMatrices(K,J),r=G.getFrustum(),A(k,E,G.camera,K,this.type)}G.isPointLightShadow!==!0&&this.type===Vc&&S(G,E),G.needsUpdate=!1}v=this.type,x.needsUpdate=!1,t.setRenderTarget(D,C,R)};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 rm(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,D){let C=null;const R=E.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(R!==void 0)C=R;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,O=k.uuid;let q=u[U];q===void 0&&(q={},u[U]=q);let j=q[O];j===void 0&&(j=C.clone(),q[O]=j),C=j}if(C.visible=k.visible,C.wireframe=k.wireframe,D===Vc?C.side=k.shadowSide!==null?k.shadowSide:k.side:C.side=k.shadowSide!==null?k.shadowSide:f[k.side],C.alphaMap=k.alphaMap,C.alphaTest=k.alphaTest,C.map=k.map,C.clipShadows=k.clipShadows,C.clippingPlanes=k.clippingPlanes,C.clipIntersection=k.clipIntersection,C.displacementMap=k.displacementMap,C.displacementScale=k.displacementScale,C.displacementBias=k.displacementBias,C.wireframeLinewidth=k.wireframeLinewidth,C.linewidth=k.linewidth,E.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const U=t.properties.get(C);U.light=E}return C}function A(T,k,E,D,C){if(T.visible===!1)return;if(T.layers.test(k.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&C===Vc)&&(!T.frustumCulled||r.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,T.matrixWorld);const O=e.update(T),q=T.material;if(Array.isArray(q)){const j=O.groups;for(let W=0,K=j.length;W<K;W++){const G=j[W],Q=q[G.materialIndex];if(Q&&Q.visible){const te=M(T,Q,D,C);T.onBeforeShadow(t,T,k,E,O,te,G),t.renderBufferDirect(E,null,O,te,T,G),T.onAfterShadow(t,T,k,E,O,te,G)}}}else if(q.visible){const j=M(T,q,D,C);T.onBeforeShadow(t,T,k,E,O,j,null),t.renderBufferDirect(E,null,O,j,T,null),T.onAfterShadow(t,T,k,E,O,j,null)}}const U=T.children;for(let O=0,q=U.length;O<q;O++)A(U[O],k,E,D,C)}}function Y8e(t,e,n){const r=n.isWebGL2;function i(){let ve=!1;const Fe=new gr;let Ue=null;const Te=new gr(0,0,0,0);return{setMask:function(qe){Ue!==qe&&!ve&&(t.colorMask(qe,qe,qe,qe),Ue=qe)},setLocked:function(qe){ve=qe},setClear:function(qe,bt,Pt,Ot,ln){ln===!0&&(qe*=Ot,bt*=Ot,Pt*=Ot),Fe.set(qe,bt,Pt,Ot),Te.equals(Fe)===!1&&(t.clearColor(qe,bt,Pt,Ot),Te.copy(Fe))},reset:function(){ve=!1,Ue=null,Te.set(-1,0,0,0)}}}function a(){let ve=!1,Fe=null,Ue=null,Te=null;return{setTest:function(qe){qe?xe(t.DEPTH_TEST):Ne(t.DEPTH_TEST)},setMask:function(qe){Fe!==qe&&!ve&&(t.depthMask(qe),Fe=qe)},setFunc:function(qe){if(Ue!==qe){switch(qe){case oFe:t.depthFunc(t.NEVER);break;case lFe:t.depthFunc(t.ALWAYS);break;case cFe:t.depthFunc(t.LESS);break;case WS: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=qe}},setLocked:function(qe){ve=qe},setClear:function(qe){Te!==qe&&(t.clearDepth(qe),Te=qe)},reset:function(){ve=!1,Fe=null,Ue=null,Te=null}}}function o(){let ve=!1,Fe=null,Ue=null,Te=null,qe=null,bt=null,Pt=null,Ot=null,ln=null;return{setTest:function(Gt){ve||(Gt?xe(t.STENCIL_TEST):Ne(t.STENCIL_TEST))},setMask:function(Gt){Fe!==Gt&&!ve&&(t.stencilMask(Gt),Fe=Gt)},setFunc:function(Gt,vn,gt){(Ue!==Gt||Te!==vn||qe!==gt)&&(t.stencilFunc(Gt,vn,gt),Ue=Gt,Te=vn,qe=gt)},setOp:function(Gt,vn,gt){(bt!==Gt||Pt!==vn||Ot!==gt)&&(t.stencilOp(Gt,vn,gt),bt=Gt,Pt=vn,Ot=gt)},setLocked:function(Gt){ve=Gt},setClear:function(Gt){ln!==Gt&&(t.clearStencil(Gt),ln=Gt)},reset:function(){ve=!1,Fe=null,Ue=null,Te=null,qe=null,bt=null,Pt=null,Ot=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,D=null,C=new an(0,0,0),R=0,U=!1,O=null,q=null,j=null,W=null,K=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Q=!1,te=0;const J=t.getParameter(t.VERSION);J.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(J)[1]),Q=te>=1):J.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),Q=te>=2);let z=null,V={};const ne=t.getParameter(t.SCISSOR_BOX),ae=t.getParameter(t.VIEWPORT),he=new gr().fromArray(ne),pe=new gr().fromArray(ae);function ie(ve,Fe,Ue,Te){const qe=new Uint8Array(4),bt=t.createTexture();t.bindTexture(ve,bt),t.texParameteri(ve,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ve,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Pt=0;Pt<Ue;Pt++)r&&(ve===t.TEXTURE_3D||ve===t.TEXTURE_2D_ARRAY)?t.texImage3D(Fe,0,t.RGBA,1,1,Te,0,t.RGBA,t.UNSIGNED_BYTE,qe):t.texImage2D(Fe+Pt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,qe);return bt}const Ee={};Ee[t.TEXTURE_2D]=ie(t.TEXTURE_2D,t.TEXTURE_2D,1),Ee[t.TEXTURE_CUBE_MAP]=ie(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ee[t.TEXTURE_2D_ARRAY]=ie(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ee[t.TEXTURE_3D]=ie(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),xe(t.DEPTH_TEST),c.setFunc(WS),I(!1),ue(TG),xe(t.CULL_FACE),X(Hd);function xe(ve){m[ve]!==!0&&(t.enable(ve),m[ve]=!0)}function Ne(ve){m[ve]!==!1&&(t.disable(ve),m[ve]=!1)}function _e(ve,Fe){return p[ve]!==Fe?(t.bindFramebuffer(ve,Fe),p[ve]=Fe,r&&(ve===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=Fe),ve===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=Fe)),!0):!1}function le(ve,Fe){let Ue=y,Te=!1;if(ve)if(Ue=b.get(Fe),Ue===void 0&&(Ue=[],b.set(Fe,Ue)),ve.isWebGLMultipleRenderTargets){const qe=ve.texture;if(Ue.length!==qe.length||Ue[0]!==t.COLOR_ATTACHMENT0){for(let bt=0,Pt=qe.length;bt<Pt;bt++)Ue[bt]=t.COLOR_ATTACHMENT0+bt;Ue.length=qe.length,Te=!0}}else Ue[0]!==t.COLOR_ATTACHMENT0&&(Ue[0]=t.COLOR_ATTACHMENT0,Te=!0);else Ue[0]!==t.BACK&&(Ue[0]=t.BACK,Te=!0);Te&&(n.isWebGL2?t.drawBuffers(Ue):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ue))}function Ve(ve){return x!==ve?(t.useProgram(ve),x=ve,!0):!1}const H={[af]:t.FUNC_ADD,[WIe]:t.FUNC_SUBTRACT,[qIe]:t.FUNC_REVERSE_SUBTRACT};if(r)H[PG]=t.MIN,H[RG]=t.MAX;else{const ve=e.get("EXT_blend_minmax");ve!==null&&(H[PG]=ve.MIN_EXT,H[RG]=ve.MAX_EXT)}const ee={[KIe]:t.ZERO,[XIe]:t.ONE,[YIe]:t.SRC_COLOR,[wR]:t.SRC_ALPHA,[nFe]:t.SRC_ALPHA_SATURATE,[eFe]:t.DST_COLOR,[QIe]:t.DST_ALPHA,[ZIe]:t.ONE_MINUS_SRC_COLOR,[SR]: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(ve,Fe,Ue,Te,qe,bt,Pt,Ot,ln,Gt){if(ve===Hd){v===!0&&(Ne(t.BLEND),v=!1);return}if(v===!1&&(xe(t.BLEND),v=!0),ve!==GIe){if(ve!==S||Gt!==U){if((M!==af||k!==af)&&(t.blendEquation(t.FUNC_ADD),M=af,k=af),Gt)switch(ve){case cg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case CG:t.blendFunc(t.ONE,t.ONE);break;case kG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case jG:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}else switch(ve){case cg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case CG:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case kG:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case jG:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}A=null,T=null,E=null,D=null,C.set(0,0,0),R=0,S=ve,U=Gt}return}qe=qe||Fe,bt=bt||Ue,Pt=Pt||Te,(Fe!==M||qe!==k)&&(t.blendEquationSeparate(H[Fe],H[qe]),M=Fe,k=qe),(Ue!==A||Te!==T||bt!==E||Pt!==D)&&(t.blendFuncSeparate(ee[Ue],ee[Te],ee[bt],ee[Pt]),A=Ue,T=Te,E=bt,D=Pt),(Ot.equals(C)===!1||ln!==R)&&(t.blendColor(Ot.r,Ot.g,Ot.b,ln),C.copy(Ot),R=ln),S=ve,U=!1}function B(ve,Fe){ve.side===Yc?Ne(t.CULL_FACE):xe(t.CULL_FACE);let Ue=ve.side===Ss;Fe&&(Ue=!Ue),I(Ue),ve.blending===cg&&ve.transparent===!1?X(Hd):X(ve.blending,ve.blendEquation,ve.blendSrc,ve.blendDst,ve.blendEquationAlpha,ve.blendSrcAlpha,ve.blendDstAlpha,ve.blendColor,ve.blendAlpha,ve.premultipliedAlpha),c.setFunc(ve.depthFunc),c.setTest(ve.depthTest),c.setMask(ve.depthWrite),l.setMask(ve.colorWrite);const Te=ve.stencilWrite;u.setTest(Te),Te&&(u.setMask(ve.stencilWriteMask),u.setFunc(ve.stencilFunc,ve.stencilRef,ve.stencilFuncMask),u.setOp(ve.stencilFail,ve.stencilZFail,ve.stencilZPass)),Ie(ve.polygonOffset,ve.polygonOffsetFactor,ve.polygonOffsetUnits),ve.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):Ne(t.SAMPLE_ALPHA_TO_COVERAGE)}function I(ve){O!==ve&&(ve?t.frontFace(t.CW):t.frontFace(t.CCW),O=ve)}function ue(ve){ve!==$Ie?(xe(t.CULL_FACE),ve!==q&&(ve===TG?t.cullFace(t.BACK):ve===HIe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ne(t.CULL_FACE),q=ve}function Ae(ve){ve!==j&&(Q&&t.lineWidth(ve),j=ve)}function Ie(ve,Fe,Ue){ve?(xe(t.POLYGON_OFFSET_FILL),(W!==Fe||K!==Ue)&&(t.polygonOffset(Fe,Ue),W=Fe,K=Ue)):Ne(t.POLYGON_OFFSET_FILL)}function ce(ve){ve?xe(t.SCISSOR_TEST):Ne(t.SCISSOR_TEST)}function $(ve){ve===void 0&&(ve=t.TEXTURE0+G-1),z!==ve&&(t.activeTexture(ve),z=ve)}function L(ve,Fe,Ue){Ue===void 0&&(z===null?Ue=t.TEXTURE0+G-1:Ue=z);let Te=V[Ue];Te===void 0&&(Te={type:void 0,texture:void 0},V[Ue]=Te),(Te.type!==ve||Te.texture!==Fe)&&(z!==Ue&&(t.activeTexture(Ue),z=Ue),t.bindTexture(ve,Fe||Ee[ve]),Te.type=ve,Te.texture=Fe)}function Y(){const ve=V[z];ve!==void 0&&ve.type!==void 0&&(t.bindTexture(ve.type,null),ve.type=void 0,ve.texture=void 0)}function be(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Se(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function se(){try{t.texSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Pe(){try{t.texSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Re(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Xe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function et(){try{t.texStorage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Je(){try{t.texStorage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function oe(){try{t.texImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ye(){try{t.texImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function je(ve){he.equals(ve)===!1&&(t.scissor(ve.x,ve.y,ve.z,ve.w),he.copy(ve))}function $e(ve){pe.equals(ve)===!1&&(t.viewport(ve.x,ve.y,ve.z,ve.w),pe.copy(ve))}function ft(ve,Fe){let Ue=f.get(Fe);Ue===void 0&&(Ue=new WeakMap,f.set(Fe,Ue));let Te=Ue.get(ve);Te===void 0&&(Te=t.getUniformBlockIndex(Fe,ve.name),Ue.set(ve,Te))}function re(ve,Fe){const Te=f.get(Fe).get(ve);d.get(Fe)!==Te&&(t.uniformBlockBinding(Fe,Te,ve.__bindingPointIndex),d.set(Fe,Te))}function ke(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),m={},z=null,V={},p={},b=new WeakMap,y=[],x=null,v=!1,S=null,M=null,A=null,T=null,k=null,E=null,D=null,C=new an(0,0,0),R=0,U=!1,O=null,q=null,j=null,W=null,K=null,he.set(0,0,t.canvas.width,t.canvas.height),pe.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:xe,disable:Ne,bindFramebuffer:_e,drawBuffers:le,useProgram:Ve,setBlending:X,setMaterial:B,setFlipSided:I,setCullFace:ue,setLineWidth:Ae,setPolygonOffset:Ie,setScissorTest:ce,activeTexture:$,bindTexture:L,unbindTexture:Y,compressedTexImage2D:be,compressedTexImage3D:Se,texImage2D:oe,texImage3D:ye,updateUBOMapping:ft,uniformBlockBinding:re,texStorage2D:et,texStorage3D:Je,texSubImage2D:se,texSubImage3D:Pe,compressedTexSubImage2D:Re,compressedTexSubImage3D:Xe,scissor:je,viewport:$e,reset:ke}}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($,L){return v?new OffscreenCanvas($,L):ZS("canvas")}function M($,L,Y,be){let Se=1;if(($.width>be||$.height>be)&&(Se=be/Math.max($.width,$.height)),Se<1||L===!0)if(typeof HTMLImageElement<"u"&&$ instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&$ instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&$ instanceof ImageBitmap){const se=L?YS:Math.floor,Pe=se(Se*$.width),Re=se(Se*$.height);y===void 0&&(y=S(Pe,Re));const Xe=Y?S(Pe,Re):y;return Xe.width=Pe,Xe.height=Re,Xe.getContext("2d").drawImage($,0,0,Pe,Re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+Pe+"x"+Re+")."),Xe}else return"data"in $&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),$;return $}function A($){return kR($.width)&&kR($.height)}function T($){return l?!1:$.wrapS!==tl||$.wrapT!==tl||$.minFilter!==va&&$.minFilter!==Mo}function k($,L){return $.generateMipmaps&&L&&$.minFilter!==va&&$.minFilter!==Mo}function E($){t.generateMipmap($)}function D($,L,Y,be,Se=!1){if(l===!1)return L;if($!==null){if(t[$]!==void 0)return t[$];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+$+"'")}let se=L;if(L===t.RED&&(Y===t.FLOAT&&(se=t.R32F),Y===t.HALF_FLOAT&&(se=t.R16F),Y===t.UNSIGNED_BYTE&&(se=t.R8)),L===t.RED_INTEGER&&(Y===t.UNSIGNED_BYTE&&(se=t.R8UI),Y===t.UNSIGNED_SHORT&&(se=t.R16UI),Y===t.UNSIGNED_INT&&(se=t.R32UI),Y===t.BYTE&&(se=t.R8I),Y===t.SHORT&&(se=t.R16I),Y===t.INT&&(se=t.R32I)),L===t.RG&&(Y===t.FLOAT&&(se=t.RG32F),Y===t.HALF_FLOAT&&(se=t.RG16F),Y===t.UNSIGNED_BYTE&&(se=t.RG8)),L===t.RGBA){const Pe=Se?qS:mr.getTransfer(be);Y===t.FLOAT&&(se=t.RGBA32F),Y===t.HALF_FLOAT&&(se=t.RGBA16F),Y===t.UNSIGNED_BYTE&&(se=Pe===Pr?t.SRGB8_ALPHA8:t.RGBA8),Y===t.UNSIGNED_SHORT_4_4_4_4&&(se=t.RGBA4),Y===t.UNSIGNED_SHORT_5_5_5_1&&(se=t.RGB5_A1)}return(se===t.R16F||se===t.R32F||se===t.RG16F||se===t.RG32F||se===t.RGBA16F||se===t.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function C($,L,Y){return k($,Y)===!0||$.isFramebufferTexture&&$.minFilter!==va&&$.minFilter!==Mo?Math.log2(Math.max(L.width,L.height))+1:$.mipmaps!==void 0&&$.mipmaps.length>0?$.mipmaps.length:$.isCompressedTexture&&Array.isArray($.image)?L.mipmaps.length:1}function R($){return $===va||$===DG||$===Tk?t.NEAREST:t.LINEAR}function U($){const L=$.target;L.removeEventListener("dispose",U),q(L),L.isVideoTexture&&b.delete(L)}function O($){const L=$.target;L.removeEventListener("dispose",O),W(L)}function q($){const L=r.get($);if(L.__webglInit===void 0)return;const Y=$.source,be=x.get(Y);if(be){const Se=be[L.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&j($),Object.keys(be).length===0&&x.delete(Y)}r.remove($)}function j($){const L=r.get($);t.deleteTexture(L.__webglTexture);const Y=$.source,be=x.get(Y);delete be[L.__cacheKey],o.memory.textures--}function W($){const L=$.texture,Y=r.get($),be=r.get(L);if(be.__webglTexture!==void 0&&(t.deleteTexture(be.__webglTexture),o.memory.textures--),$.depthTexture&&$.depthTexture.dispose(),$.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(Y.__webglFramebuffer[Se]))for(let se=0;se<Y.__webglFramebuffer[Se].length;se++)t.deleteFramebuffer(Y.__webglFramebuffer[Se][se]);else t.deleteFramebuffer(Y.__webglFramebuffer[Se]);Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer[Se])}else{if(Array.isArray(Y.__webglFramebuffer))for(let Se=0;Se<Y.__webglFramebuffer.length;Se++)t.deleteFramebuffer(Y.__webglFramebuffer[Se]);else t.deleteFramebuffer(Y.__webglFramebuffer);if(Y.__webglDepthbuffer&&t.deleteRenderbuffer(Y.__webglDepthbuffer),Y.__webglMultisampledFramebuffer&&t.deleteFramebuffer(Y.__webglMultisampledFramebuffer),Y.__webglColorRenderbuffer)for(let Se=0;Se<Y.__webglColorRenderbuffer.length;Se++)Y.__webglColorRenderbuffer[Se]&&t.deleteRenderbuffer(Y.__webglColorRenderbuffer[Se]);Y.__webglDepthRenderbuffer&&t.deleteRenderbuffer(Y.__webglDepthRenderbuffer)}if($.isWebGLMultipleRenderTargets)for(let Se=0,se=L.length;Se<se;Se++){const Pe=r.get(L[Se]);Pe.__webglTexture&&(t.deleteTexture(Pe.__webglTexture),o.memory.textures--),r.remove(L[Se])}r.remove(L),r.remove($)}let K=0;function G(){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 te($){const L=[];return L.push($.wrapS),L.push($.wrapT),L.push($.wrapR||0),L.push($.magFilter),L.push($.minFilter),L.push($.anisotropy),L.push($.internalFormat),L.push($.format),L.push($.type),L.push($.generateMipmaps),L.push($.premultiplyAlpha),L.push($.flipY),L.push($.unpackAlignment),L.push($.colorSpace),L.join()}function J($,L){const Y=r.get($);if($.isVideoTexture&&Ie($),$.isRenderTargetTexture===!1&&$.version>0&&Y.__version!==$.version){const be=$.image;if(be===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(be.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{xe(Y,$,L);return}}n.bindTexture(t.TEXTURE_2D,Y.__webglTexture,t.TEXTURE0+L)}function z($,L){const Y=r.get($);if($.version>0&&Y.__version!==$.version){xe(Y,$,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,Y.__webglTexture,t.TEXTURE0+L)}function V($,L){const Y=r.get($);if($.version>0&&Y.__version!==$.version){xe(Y,$,L);return}n.bindTexture(t.TEXTURE_3D,Y.__webglTexture,t.TEXTURE0+L)}function ne($,L){const Y=r.get($);if($.version>0&&Y.__version!==$.version){Ne(Y,$,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,Y.__webglTexture,t.TEXTURE0+L)}const ae={[ER]:t.REPEAT,[tl]:t.CLAMP_TO_EDGE,[AR]:t.MIRRORED_REPEAT},he={[va]:t.NEAREST,[DG]:t.NEAREST_MIPMAP_NEAREST,[Tk]:t.NEAREST_MIPMAP_LINEAR,[Mo]:t.LINEAR,[_Fe]:t.LINEAR_MIPMAP_NEAREST,[J0]:t.LINEAR_MIPMAP_LINEAR},pe={[RFe]:t.NEVER,[UFe]:t.ALWAYS,[DFe]:t.LESS,[Xee]:t.LEQUAL,[OFe]:t.EQUAL,[FFe]:t.GEQUAL,[LFe]:t.GREATER,[IFe]:t.NOTEQUAL};function ie($,L,Y){if(Y?(t.texParameteri($,t.TEXTURE_WRAP_S,ae[L.wrapS]),t.texParameteri($,t.TEXTURE_WRAP_T,ae[L.wrapT]),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,ae[L.wrapR]),t.texParameteri($,t.TEXTURE_MAG_FILTER,he[L.magFilter]),t.texParameteri($,t.TEXTURE_MIN_FILTER,he[L.minFilter])):(t.texParameteri($,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri($,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),($===t.TEXTURE_3D||$===t.TEXTURE_2D_ARRAY)&&t.texParameteri($,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==tl||L.wrapT!==tl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri($,t.TEXTURE_MAG_FILTER,R(L.magFilter)),t.texParameteri($,t.TEXTURE_MIN_FILTER,R(L.minFilter)),L.minFilter!==va&&L.minFilter!==Mo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri($,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri($,t.TEXTURE_COMPARE_FUNC,pe[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const be=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===va||L.minFilter!==Tk&&L.minFilter!==J0||L.type===tu&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===ey&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(t.texParameterf($,be.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,i.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function Ee($,L){let Y=!1;$.__webglInit===void 0&&($.__webglInit=!0,L.addEventListener("dispose",U));const be=L.source;let Se=x.get(be);Se===void 0&&(Se={},x.set(be,Se));const se=te(L);if(se!==$.__cacheKey){Se[se]===void 0&&(Se[se]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,Y=!0),Se[se].usedTimes++;const Pe=Se[$.__cacheKey];Pe!==void 0&&(Se[$.__cacheKey].usedTimes--,Pe.usedTimes===0&&j(L)),$.__cacheKey=se,$.__webglTexture=Se[se].texture}return Y}function xe($,L,Y){let be=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(be=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(be=t.TEXTURE_3D);const Se=Ee($,L),se=L.source;n.bindTexture(be,$.__webglTexture,t.TEXTURE0+Y);const Pe=r.get(se);if(se.version!==Pe.__version||Se===!0){n.activeTexture(t.TEXTURE0+Y);const Re=mr.getPrimaries(mr.workingColorSpace),Xe=L.colorSpace===Eo?null:mr.getPrimaries(L.colorSpace),et=L.colorSpace===Eo||Re===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,et);const Je=T(L)&&A(L.image)===!1;let oe=M(L.image,Je,!1,d);oe=ce(L,oe);const ye=A(oe)||l,je=a.convert(L.format,L.colorSpace);let $e=a.convert(L.type),ft=D(L.internalFormat,je,$e,L.colorSpace,L.isVideoTexture);ie(be,L,ye);let re;const ke=L.mipmaps,ve=l&&L.isVideoTexture!==!0&&ft!==Wee,Fe=Pe.__version===void 0||Se===!0,Ue=C(L,oe,ye);if(L.isDepthTexture)ft=t.DEPTH_COMPONENT,l?L.type===tu?ft=t.DEPTH_COMPONENT32F:L.type===Pd?ft=t.DEPTH_COMPONENT24:L.type===Cf?ft=t.DEPTH24_STENCIL8:ft=t.DEPTH_COMPONENT16:L.type===tu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===kf&&ft===t.DEPTH_COMPONENT&&L.type!==pL&&L.type!==Pd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=Pd,$e=a.convert(L.type)),L.format===Dg&&ft===t.DEPTH_COMPONENT&&(ft=t.DEPTH_STENCIL,L.type!==Cf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Cf,$e=a.convert(L.type))),Fe&&(ve?n.texStorage2D(t.TEXTURE_2D,1,ft,oe.width,oe.height):n.texImage2D(t.TEXTURE_2D,0,ft,oe.width,oe.height,0,je,$e,null));else if(L.isDataTexture)if(ke.length>0&&ye){ve&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,ft,ke[0].width,ke[0].height);for(let Te=0,qe=ke.length;Te<qe;Te++)re=ke[Te],ve?n.texSubImage2D(t.TEXTURE_2D,Te,0,0,re.width,re.height,je,$e,re.data):n.texImage2D(t.TEXTURE_2D,Te,ft,re.width,re.height,0,je,$e,re.data);L.generateMipmaps=!1}else ve?(Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,ft,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,oe.width,oe.height,je,$e,oe.data)):n.texImage2D(t.TEXTURE_2D,0,ft,oe.width,oe.height,0,je,$e,oe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){ve&&Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,ft,ke[0].width,ke[0].height,oe.depth);for(let Te=0,qe=ke.length;Te<qe;Te++)re=ke[Te],L.format!==No?je!==null?ve?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,0,re.width,re.height,oe.depth,je,re.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Te,ft,re.width,re.height,oe.depth,0,re.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Te,0,0,0,re.width,re.height,oe.depth,je,$e,re.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Te,ft,re.width,re.height,oe.depth,0,je,$e,re.data)}else{ve&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,ft,ke[0].width,ke[0].height);for(let Te=0,qe=ke.length;Te<qe;Te++)re=ke[Te],L.format!==No?je!==null?ve?n.compressedTexSubImage2D(t.TEXTURE_2D,Te,0,0,re.width,re.height,je,re.data):n.compressedTexImage2D(t.TEXTURE_2D,Te,ft,re.width,re.height,0,re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage2D(t.TEXTURE_2D,Te,0,0,re.width,re.height,je,$e,re.data):n.texImage2D(t.TEXTURE_2D,Te,ft,re.width,re.height,0,je,$e,re.data)}else if(L.isDataArrayTexture)ve?(Fe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,ft,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,oe.width,oe.height,oe.depth,je,$e,oe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ft,oe.width,oe.height,oe.depth,0,je,$e,oe.data);else if(L.isData3DTexture)ve?(Fe&&n.texStorage3D(t.TEXTURE_3D,Ue,ft,oe.width,oe.height,oe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,oe.width,oe.height,oe.depth,je,$e,oe.data)):n.texImage3D(t.TEXTURE_3D,0,ft,oe.width,oe.height,oe.depth,0,je,$e,oe.data);else if(L.isFramebufferTexture){if(Fe)if(ve)n.texStorage2D(t.TEXTURE_2D,Ue,ft,oe.width,oe.height);else{let Te=oe.width,qe=oe.height;for(let bt=0;bt<Ue;bt++)n.texImage2D(t.TEXTURE_2D,bt,ft,Te,qe,0,je,$e,null),Te>>=1,qe>>=1}}else if(ke.length>0&&ye){ve&&Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,ft,ke[0].width,ke[0].height);for(let Te=0,qe=ke.length;Te<qe;Te++)re=ke[Te],ve?n.texSubImage2D(t.TEXTURE_2D,Te,0,0,je,$e,re):n.texImage2D(t.TEXTURE_2D,Te,ft,je,$e,re);L.generateMipmaps=!1}else ve?(Fe&&n.texStorage2D(t.TEXTURE_2D,Ue,ft,oe.width,oe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,je,$e,oe)):n.texImage2D(t.TEXTURE_2D,0,ft,je,$e,oe);k(L,ye)&&E(be),Pe.__version=se.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function Ne($,L,Y){if(L.image.length!==6)return;const be=Ee($,L),Se=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,$.__webglTexture,t.TEXTURE0+Y);const se=r.get(Se);if(Se.version!==se.__version||be===!0){n.activeTexture(t.TEXTURE0+Y);const Pe=mr.getPrimaries(mr.workingColorSpace),Re=L.colorSpace===Eo?null:mr.getPrimaries(L.colorSpace),Xe=L.colorSpace===Eo||Pe===Re?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const et=L.isCompressedTexture||L.image[0].isCompressedTexture,Je=L.image[0]&&L.image[0].isDataTexture,oe=[];for(let Te=0;Te<6;Te++)!et&&!Je?oe[Te]=M(L.image[Te],!1,!0,u):oe[Te]=Je?L.image[Te].image:L.image[Te],oe[Te]=ce(L,oe[Te]);const ye=oe[0],je=A(ye)||l,$e=a.convert(L.format,L.colorSpace),ft=a.convert(L.type),re=D(L.internalFormat,$e,ft,L.colorSpace),ke=l&&L.isVideoTexture!==!0,ve=se.__version===void 0||be===!0;let Fe=C(L,ye,je);ie(t.TEXTURE_CUBE_MAP,L,je);let Ue;if(et){ke&&ve&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,re,ye.width,ye.height);for(let Te=0;Te<6;Te++){Ue=oe[Te].mipmaps;for(let qe=0;qe<Ue.length;qe++){const bt=Ue[qe];L.format!==No?$e!==null?ke?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,0,0,bt.width,bt.height,$e,bt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,re,bt.width,bt.height,0,bt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,0,0,bt.width,bt.height,$e,ft,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe,re,bt.width,bt.height,0,$e,ft,bt.data)}}}else{Ue=L.mipmaps,ke&&ve&&(Ue.length>0&&Fe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Fe,re,oe[0].width,oe[0].height));for(let Te=0;Te<6;Te++)if(Je){ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,oe[Te].width,oe[Te].height,$e,ft,oe[Te].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,re,oe[Te].width,oe[Te].height,0,$e,ft,oe[Te].data);for(let qe=0;qe<Ue.length;qe++){const Pt=Ue[qe].image[Te].image;ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,0,0,Pt.width,Pt.height,$e,ft,Pt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,re,Pt.width,Pt.height,0,$e,ft,Pt.data)}}else{ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,0,0,$e,ft,oe[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,re,$e,ft,oe[Te]);for(let qe=0;qe<Ue.length;qe++){const bt=Ue[qe];ke?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,0,0,$e,ft,bt.image[Te]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Te,qe+1,re,$e,ft,bt.image[Te])}}}k(L,je)&&E(t.TEXTURE_CUBE_MAP),se.__version=Se.version,L.onUpdate&&L.onUpdate(L)}$.__version=L.version}function _e($,L,Y,be,Se,se){const Pe=a.convert(Y.format,Y.colorSpace),Re=a.convert(Y.type),Xe=D(Y.internalFormat,Pe,Re,Y.colorSpace);if(!r.get(L).__hasExternalTextures){const Je=Math.max(1,L.width>>se),oe=Math.max(1,L.height>>se);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,se,Xe,Je,oe,L.depth,0,Pe,Re,null):n.texImage2D(Se,se,Xe,Je,oe,0,Pe,Re,null)}n.bindFramebuffer(t.FRAMEBUFFER,$),Ae(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,Se,r.get(Y).__webglTexture,0,ue(L)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,be,Se,r.get(Y).__webglTexture,se),n.bindFramebuffer(t.FRAMEBUFFER,null)}function le($,L,Y){if(t.bindRenderbuffer(t.RENDERBUFFER,$),L.depthBuffer&&!L.stencilBuffer){let be=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(Y||Ae(L)){const Se=L.depthTexture;Se&&Se.isDepthTexture&&(Se.type===tu?be=t.DEPTH_COMPONENT32F:Se.type===Pd&&(be=t.DEPTH_COMPONENT24));const se=ue(L);Ae(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,se,be,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,se,be,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,be,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,$)}else if(L.depthBuffer&&L.stencilBuffer){const be=ue(L);Y&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,L.width,L.height):Ae(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,be,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,$)}else{const be=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let Se=0;Se<be.length;Se++){const se=be[Se],Pe=a.convert(se.format,se.colorSpace),Re=a.convert(se.type),Xe=D(se.internalFormat,Pe,Re,se.colorSpace),et=ue(L);Y&&Ae(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,et,Xe,L.width,L.height):Ae(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,et,Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ve($,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,$),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),J(L.depthTexture,0);const be=r.get(L.depthTexture).__webglTexture,Se=ue(L);if(L.depthTexture.format===kf)Ae(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,be,0);else if(L.depthTexture.format===Dg)Ae(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,be,0);else throw new Error("Unknown depthTexture format")}function H($){const L=r.get($),Y=$.isWebGLCubeRenderTarget===!0;if($.depthTexture&&!L.__autoAllocateDepthBuffer){if(Y)throw new Error("target.depthTexture not supported in Cube render targets");Ve(L.__webglFramebuffer,$)}else if(Y){L.__webglDepthbuffer=[];for(let be=0;be<6;be++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[be]),L.__webglDepthbuffer[be]=t.createRenderbuffer(),le(L.__webglDepthbuffer[be],$,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),le(L.__webglDepthbuffer,$,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function ee($,L,Y){const be=r.get($);L!==void 0&&_e(be.__webglFramebuffer,$,$.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),Y!==void 0&&H($)}function X($){const L=$.texture,Y=r.get($),be=r.get(L);$.addEventListener("dispose",O),$.isWebGLMultipleRenderTargets!==!0&&(be.__webglTexture===void 0&&(be.__webglTexture=t.createTexture()),be.__version=L.version,o.memory.textures++);const Se=$.isWebGLCubeRenderTarget===!0,se=$.isWebGLMultipleRenderTargets===!0,Pe=A($)||l;if(Se){Y.__webglFramebuffer=[];for(let Re=0;Re<6;Re++)if(l&&L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer[Re]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)Y.__webglFramebuffer[Re][Xe]=t.createFramebuffer()}else Y.__webglFramebuffer[Re]=t.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){Y.__webglFramebuffer=[];for(let Re=0;Re<L.mipmaps.length;Re++)Y.__webglFramebuffer[Re]=t.createFramebuffer()}else Y.__webglFramebuffer=t.createFramebuffer();if(se)if(i.drawBuffers){const Re=$.texture;for(let Xe=0,et=Re.length;Xe<et;Xe++){const Je=r.get(Re[Xe]);Je.__webglTexture===void 0&&(Je.__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&&Ae($)===!1){const Re=se?L:[L];Y.__webglMultisampledFramebuffer=t.createFramebuffer(),Y.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,Y.__webglMultisampledFramebuffer);for(let Xe=0;Xe<Re.length;Xe++){const et=Re[Xe];Y.__webglColorRenderbuffer[Xe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,Y.__webglColorRenderbuffer[Xe]);const Je=a.convert(et.format,et.colorSpace),oe=a.convert(et.type),ye=D(et.internalFormat,Je,oe,et.colorSpace,$.isXRRenderTarget===!0),je=ue($);t.renderbufferStorageMultisample(t.RENDERBUFFER,je,ye,$.width,$.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Xe,t.RENDERBUFFER,Y.__webglColorRenderbuffer[Xe])}t.bindRenderbuffer(t.RENDERBUFFER,null),$.depthBuffer&&(Y.__webglDepthRenderbuffer=t.createRenderbuffer(),le(Y.__webglDepthRenderbuffer,$,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Se){n.bindTexture(t.TEXTURE_CUBE_MAP,be.__webglTexture),ie(t.TEXTURE_CUBE_MAP,L,Pe);for(let Re=0;Re<6;Re++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)_e(Y.__webglFramebuffer[Re][Xe],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,Xe);else _e(Y.__webglFramebuffer[Re],$,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Re,0);k(L,Pe)&&E(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(se){const Re=$.texture;for(let Xe=0,et=Re.length;Xe<et;Xe++){const Je=Re[Xe],oe=r.get(Je);n.bindTexture(t.TEXTURE_2D,oe.__webglTexture),ie(t.TEXTURE_2D,Je,Pe),_e(Y.__webglFramebuffer,$,Je,t.COLOR_ATTACHMENT0+Xe,t.TEXTURE_2D,0),k(Je,Pe)&&E(t.TEXTURE_2D)}n.unbindTexture()}else{let Re=t.TEXTURE_2D;if(($.isWebGL3DRenderTarget||$.isWebGLArrayRenderTarget)&&(l?Re=$.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Re,be.__webglTexture),ie(Re,L,Pe),l&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)_e(Y.__webglFramebuffer[Xe],$,L,t.COLOR_ATTACHMENT0,Re,Xe);else _e(Y.__webglFramebuffer,$,L,t.COLOR_ATTACHMENT0,Re,0);k(L,Pe)&&E(Re),n.unbindTexture()}$.depthBuffer&&H($)}function B($){const L=A($)||l,Y=$.isWebGLMultipleRenderTargets===!0?$.texture:[$.texture];for(let be=0,Se=Y.length;be<Se;be++){const se=Y[be];if(k(se,L)){const Pe=$.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Re=r.get(se).__webglTexture;n.bindTexture(Pe,Re),E(Pe),n.unbindTexture()}}}function I($){if(l&&$.samples>0&&Ae($)===!1){const L=$.isWebGLMultipleRenderTargets?$.texture:[$.texture],Y=$.width,be=$.height;let Se=t.COLOR_BUFFER_BIT;const se=[],Pe=$.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Re=r.get($),Xe=$.isWebGLMultipleRenderTargets===!0;if(Xe)for(let et=0;et<L.length;et++)n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Re.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Re.__webglFramebuffer);for(let et=0;et<L.length;et++){se.push(t.COLOR_ATTACHMENT0+et),$.depthBuffer&&se.push(Pe);const Je=Re.__ignoreDepthValues!==void 0?Re.__ignoreDepthValues:!1;if(Je===!1&&($.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),$.stencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Xe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Re.__webglColorRenderbuffer[et]),Je===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Pe]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Pe])),Xe){const oe=r.get(L[et]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,oe,0)}t.blitFramebuffer(0,0,Y,be,0,0,Y,be,Se,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,se)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Xe)for(let et=0;et<L.length;et++){n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.RENDERBUFFER,Re.__webglColorRenderbuffer[et]);const Je=r.get(L[et]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Re.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+et,t.TEXTURE_2D,Je,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Re.__webglMultisampledFramebuffer)}}function ue($){return Math.min(f,$.samples)}function Ae($){const L=r.get($);return l&&$.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ie($){const L=o.render.frame;b.get($)!==L&&(b.set($,L),$.update())}function ce($,L){const Y=$.colorSpace,be=$.format,Se=$.type;return $.isCompressedTexture===!0||$.isVideoTexture===!0||$.format===CR||Y!==Su&&Y!==Eo&&(mr.getTransfer(Y)===Pr?l===!1?e.has("EXT_sRGB")===!0&&be===No?($.format=CR,$.minFilter=Mo,$.generateMipmaps=!1):L=Qee.sRGBToLinear(L):(be!==No||Se!==Gd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Y)),L}this.allocateTextureUnit=Q,this.resetTextureUnits=G,this.setTexture2D=J,this.setTexture2DArray=z,this.setTexture3D=V,this.setTextureCube=ne,this.rebindTextures=ee,this.setupRenderTarget=X,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=I,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=_e,this.useMultisampledRTT=Ae}function Q8e(t,e,n){const r=n.isWebGL2;function i(a,o=Eo){let l;const c=mr.getTransfer(o);if(a===Gd)return t.UNSIGNED_BYTE;if(a===Bee)return t.UNSIGNED_SHORT_4_4_4_4;if(a===$ee)return t.UNSIGNED_SHORT_5_5_5_1;if(a===wFe)return t.BYTE;if(a===SFe)return t.SHORT;if(a===pL)return t.UNSIGNED_SHORT;if(a===zee)return t.INT;if(a===Pd)return t.UNSIGNED_INT;if(a===tu)return t.FLOAT;if(a===ey)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===No)return t.RGBA;if(a===NFe)return t.LUMINANCE;if(a===EFe)return t.LUMINANCE_ALPHA;if(a===kf)return t.DEPTH_COMPONENT;if(a===Dg)return t.DEPTH_STENCIL;if(a===CR)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===AFe)return t.RED;if(a===Hee)return t.RED_INTEGER;if(a===TFe)return t.RG;if(a===Vee)return t.RG_INTEGER;if(a===Gee)return t.RGBA_INTEGER;if(a===Ck||a===kk||a===jk||a===Pk)if(c===Pr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===Ck)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===kk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===jk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Pk)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===Ck)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===kk)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===jk)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Pk)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===OG||a===LG||a===IG||a===FG)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===OG)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===LG)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===IG)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===FG)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===Wee)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===UG||a===zG)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===UG)return c===Pr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===zG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===BG||a===$G||a===HG||a===VG||a===GG||a===WG||a===qG||a===KG||a===XG||a===YG||a===ZG||a===QG||a===JG||a===e7)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===BG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===$G)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===HG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===VG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===GG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===WG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===qG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===KG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===XG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===YG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===ZG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===QG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===JG)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===e7)return c===Pr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Rk||a===t7||a===n7)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===Rk)return c===Pr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===t7)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===n7)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===CFe||a===r7||a===i7||a===a7)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===Rk)return l.COMPRESSED_RED_RGTC1_EXT;if(a===r7)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===i7)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===a7)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Cf?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 zs{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Wb extends es{constructor(){super(),this.isGroup=!0,this.type="Group"}}const e6e={type:"move"};class nj{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Wb,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Wb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Be,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Be),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Wb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Be,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Be),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const x=n.getJointPose(y,r),v=this._getHandJoint(u,y);x!==null&&(v.matrix.fromArray(x.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=x.radius),v.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],m=d.position.distanceTo(f.position),p=.02,b=.005;u.inputState.pinching&&m>p+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&m<=p-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(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 Wb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class t6e extends pm{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 fn;let T=null;const k=new zs;k.layers.enable(1),k.viewport=new gr;const E=new zs;E.layers.enable(2),E.viewport=new gr;const D=[k,E],C=new J8e;C.layers.enable(1),C.layers.enable(2);let R=null,U=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let ae=S[ne];return ae===void 0&&(ae=new nj,S[ne]=ae),ae.getTargetRaySpace()},this.getControllerGrip=function(ne){let ae=S[ne];return ae===void 0&&(ae=new nj,S[ne]=ae),ae.getGripSpace()},this.getHand=function(ne){let ae=S[ne];return ae===void 0&&(ae=new nj,S[ne]=ae),ae.getHandSpace()};function O(ne){const ae=M.indexOf(ne.inputSource);if(ae===-1)return;const he=S[ae];he!==void 0&&(he.update(ne.inputSource,ne.frame,u||o),he.dispatchEvent({type:ne.type,data:ne.inputSource}))}function q(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",j);for(let ne=0;ne<S.length;ne++){const ae=M[ne];ae!==null&&(M[ne]=null,S[ne].disconnect(ae))}R=null,U=null,e.setRenderTarget(x),p=null,m=null,f=null,i=null,v=null,V.stop(),r.isPresenting=!1,e.setPixelRatio(T),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){a=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ne){u=ne},this.getBaseLayer=function(){return m!==null?m:p},this.getBinding=function(){return f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",q),i.addEventListener("inputsourceschange",j),y.xrCompatible!==!0&&await n.makeXRCompatible(),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 rm(p.framebufferWidth,p.framebufferHeight,{format:No,type:Gd,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let ae=null,he=null,pe=null;y.depth&&(pe=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ae=y.stencil?Dg:kf,he=y.stencil?Cf:Pd);const ie={colorFormat:n.RGBA8,depthFormat:pe,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 rm(m.textureWidth,m.textureHeight,{format:No,type:Gd,depthTexture:new ute(m.textureWidth,m.textureHeight,he,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 Ee=e.properties.get(v);Ee.__ignoreDepthValues=m.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),V.setContext(i),V.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function j(ne){for(let ae=0;ae<ne.removed.length;ae++){const he=ne.removed[ae],pe=M.indexOf(he);pe>=0&&(M[pe]=null,S[pe].disconnect(he))}for(let ae=0;ae<ne.added.length;ae++){const he=ne.added[ae];let pe=M.indexOf(he);if(pe===-1){for(let Ee=0;Ee<S.length;Ee++)if(Ee>=M.length){M.push(he),pe=Ee;break}else if(M[Ee]===null){M[Ee]=he,pe=Ee;break}if(pe===-1)break}const ie=S[pe];ie&&ie.connect(he)}}const W=new Be,K=new Be;function G(ne,ae,he){W.setFromMatrixPosition(ae.matrixWorld),K.setFromMatrixPosition(he.matrixWorld);const pe=W.distanceTo(K),ie=ae.projectionMatrix.elements,Ee=he.projectionMatrix.elements,xe=ie[14]/(ie[10]-1),Ne=ie[14]/(ie[10]+1),_e=(ie[9]+1)/ie[5],le=(ie[9]-1)/ie[5],Ve=(ie[8]-1)/ie[0],H=(Ee[8]+1)/Ee[0],ee=xe*Ve,X=xe*H,B=pe/(-Ve+H),I=B*-Ve;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 ue=xe+B,Ae=Ne+B,Ie=ee-I,ce=X+(pe-I),$=_e*Ne/Ae*ue,L=le*Ne/Ae*ue;ne.projectionMatrix.makePerspective(Ie,ce,$,L,ue,Ae),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,(R!==C.near||U!==C.far)&&(i.updateRenderState({depthNear:C.near,depthFar:C.far}),R=C.near,U=C.far);const ae=ne.parent,he=C.cameras;Q(C,ae);for(let pe=0;pe<he.length;pe++)Q(he[pe],ae);he.length===2?G(C,k,E):C.projectionMatrix.copy(k.projectionMatrix),te(ne,C,ae)};function te(ne,ae,he){he===null?ne.matrix.copy(ae.matrixWorld):(ne.matrix.copy(he.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=ny*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 he=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let pe=!1;he.length!==C.cameras.length&&(C.cameras.length=0,pe=!0);for(let ie=0;ie<he.length;ie++){const Ee=he[ie];let xe=null;if(p!==null)xe=p.getViewport(Ee);else{const _e=f.getViewSubImage(m,Ee);xe=_e.viewport,ie===0&&(e.setRenderTargetTextures(v,_e.colorTexture,m.ignoreDepthValues?void 0:_e.depthStencilTexture),e.setRenderTarget(v))}let Ne=D[ie];Ne===void 0&&(Ne=new zs,Ne.layers.enable(ie),Ne.viewport=new gr,D[ie]=Ne),Ne.matrix.fromArray(Ee.transform.matrix),Ne.matrix.decompose(Ne.position,Ne.quaternion,Ne.scale),Ne.projectionMatrix.fromArray(Ee.projectionMatrix),Ne.projectionMatrixInverse.copy(Ne.projectionMatrix).invert(),Ne.viewport.set(xe.x,xe.y,xe.width,xe.height),ie===0&&(C.matrix.copy(Ne.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),pe===!0&&C.cameras.push(Ne)}}for(let he=0;he<S.length;he++){const pe=M[he],ie=S[he];pe!==null&&ie!==void 0&&ie.update(pe,ae,u||o)}J&&J(ne,ae),ae.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ae}),b=null}const V=new cte;V.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,ste(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===Ss&&(x.bumpScale.value*=-1)),v.normalMap&&(x.normalMap.value=v.normalMap,n(v.normalMap,x.normalMapTransform),x.normalScale.value.copy(v.normalScale),v.side===Ss&&x.normalScale.value.negate()),v.displacementMap&&(x.displacementMap.value=v.displacementMap,n(v.displacementMap,x.displacementMapTransform),x.displacementScale.value=v.displacementScale,x.displacementBias.value=v.displacementBias),v.emissiveMap&&(x.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,x.emissiveMapTransform)),v.specularMap&&(x.specularMap.value=v.specularMap,n(v.specularMap,x.specularMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest);const S=e.get(v).envMap;if(S&&(x.envMap.value=S,x.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=v.reflectivity,x.ior.value=v.ior,x.refractionRatio.value=v.refractionRatio),v.lightMap){x.lightMap.value=v.lightMap;const M=t._useLegacyLights===!0?Math.PI:1;x.lightMapIntensity.value=v.lightMapIntensity*M,n(v.lightMap,x.lightMapTransform)}v.aoMap&&(x.aoMap.value=v.aoMap,x.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,x.aoMapTransform))}function o(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform))}function l(x,v){x.dashSize.value=v.dashSize,x.totalSize.value=v.dashSize+v.gapSize,x.scale.value=v.scale}function c(x,v,S,M){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.size.value=v.size*S,x.scale.value=M*.5,v.map&&(x.map.value=v.map,n(v.map,x.uvTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function u(x,v){x.diffuse.value.copy(v.color),x.opacity.value=v.opacity,x.rotation.value=v.rotation,v.map&&(x.map.value=v.map,n(v.map,x.mapTransform)),v.alphaMap&&(x.alphaMap.value=v.alphaMap,n(v.alphaMap,x.alphaMapTransform)),v.alphaTest>0&&(x.alphaTest.value=v.alphaTest)}function d(x,v){x.specular.value.copy(v.specular),x.shininess.value=Math.max(v.shininess,1e-4)}function f(x,v){v.gradientMap&&(x.gradientMap.value=v.gradientMap)}function m(x,v){x.metalness.value=v.metalness,v.metalnessMap&&(x.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,x.metalnessMapTransform)),x.roughness.value=v.roughness,v.roughnessMap&&(x.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,x.roughnessMapTransform)),e.get(v).envMap&&(x.envMapIntensity.value=v.envMapIntensity)}function p(x,v,S){x.ior.value=v.ior,v.sheen>0&&(x.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),x.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(x.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,x.sheenColorMapTransform)),v.sheenRoughnessMap&&(x.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,x.sheenRoughnessMapTransform))),v.clearcoat>0&&(x.clearcoat.value=v.clearcoat,x.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(x.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,x.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(x.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===Ss&&x.clearcoatNormalScale.value.negate())),v.iridescence>0&&(x.iridescence.value=v.iridescence,x.iridescenceIOR.value=v.iridescenceIOR,x.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(x.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,x.iridescenceMapTransform)),v.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),v.transmission>0&&(x.transmission.value=v.transmission,x.transmissionSamplerMap.value=S.texture,x.transmissionSamplerSize.value.set(S.width,S.height),v.transmissionMap&&(x.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,x.transmissionMapTransform)),x.thickness.value=v.thickness,v.thicknessMap&&(x.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=v.attenuationDistance,x.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(x.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(x.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=v.specularIntensity,x.specularColor.value.copy(v.specularColor),v.specularColorMap&&(x.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,x.specularColorMapTransform)),v.specularIntensityMap&&(x.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,v){v.matcap&&(x.matcap.value=v.matcap)}function y(x,v){const S=e.get(v).light;x.referencePosition.value.setFromMatrixPosition(S.matrixWorld),x.nearDistance.value=S.shadow.camera.near,x.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function 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 D=A[k];if(p(D,k,T)===!0){const C=D.__offset,R=Array.isArray(D.value)?D.value:[D.value];let U=0;for(let O=0;O<R.length;O++){const q=R[O],j=y(q);typeof q=="number"?(D.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,C+U,D.__data)):q.isMatrix3?(D.__data[0]=q.elements[0],D.__data[1]=q.elements[1],D.__data[2]=q.elements[2],D.__data[3]=q.elements[0],D.__data[4]=q.elements[3],D.__data[5]=q.elements[4],D.__data[6]=q.elements[5],D.__data[7]=q.elements[0],D.__data[8]=q.elements[6],D.__data[9]=q.elements[7],D.__data[10]=q.elements[8],D.__data[11]=q.elements[0]):(q.toArray(D.__data,U),U+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,C,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(S,M,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 D=0;D<k.length;D++)E.push(k[D].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 D=0;D<k.length;D++){const C=k[D];if(C.equals(E[D])===!1)return C.copy(E[D]),!0}}return!1}function b(S){const M=S.uniforms;let A=0;const T=16;let k=0;for(let E=0,D=M.length;E<D;E++){const C=M[E],R={boundary:0,storage:0},U=Array.isArray(C.value)?C.value:[C.value];for(let O=0,q=U.length;O<q;O++){const j=U[O],W=y(j);R.boundary+=W.boundary,R.storage+=W.storage}if(C.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),C.__offset=A,E>0){k=A%T;const O=T-k;k!==0&&O-R.boundary<0&&(A+=T-k,C.__offset=A)}A+=R.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 PR{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=_a,this._useLegacyLights=!1,this.toneMapping=Vd,this.toneMappingExposure=1;const M=this;let A=!1,T=0,k=0,E=null,D=-1,C=null;const R=new gr,U=new gr;let O=null;const q=new an(0);let j=0,W=n.width,K=n.height,G=1,Q=null,te=null;const J=new gr(0,0,W,K),z=new gr(0,0,W,K);let V=!1;const ne=new gE;let ae=!1,he=!1,pe=null;const ie=new Ar,Ee=new fn,xe=new Be,Ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function _e(){return E===null?G:1}let le=r;function Ve(we,Ye){for(let at=0;at<we.length;at++){const ct=we[at],st=n.getContext(ct,Ye);if(st!==null)return st}return null}try{const we={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${fE}`),n.addEventListener("webglcontextlost",ke,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",Fe,!1),le===null){const Ye=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&Ye.shift(),le=Ve(Ye,we),le===null)throw Ve(Ye)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&le instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),le.getShaderPrecisionFormat===void 0&&(le.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(we){throw console.error("THREE.WebGLRenderer: "+we.message),we}let H,ee,X,B,I,ue,Ae,Ie,ce,$,L,Y,be,Se,se,Pe,Re,Xe,et,Je,oe,ye,je,$e;function ft(){H=new mBe(le),ee=new oBe(le,H,e),H.init(ee),ye=new Q8e(le,H,ee),X=new Y8e(le,H,ee),B=new xBe(le),I=new L8e,ue=new Z8e(le,H,X,I,ee,ye,B),Ae=new cBe(M),Ie=new fBe(M),ce=new M5e(le,ee),je=new aBe(le,H,ce,ee),$=new pBe(le,ce,B,je),L=new _Be(le,$,ce,B),et=new vBe(le,ee,ue),Pe=new lBe(I),Y=new O8e(M,Ae,Ie,H,ee,je,Pe),be=new n6e(M,I),Se=new F8e,se=new V8e(H,ee),Xe=new iBe(M,Ae,Ie,X,L,m,c),Re=new X8e(M,L,ee),$e=new r6e(le,B,ee,X),Je=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=Se,M.shadowMap=Re,M.state=X,M.info=B}ft();const re=new t6e(M,le);this.xr=re,this.getContext=function(){return le},this.getContextAttributes=function(){return le.getContextAttributes()},this.forceContextLoss=function(){const we=H.get("WEBGL_lose_context");we&&we.loseContext()},this.forceContextRestore=function(){const we=H.get("WEBGL_lose_context");we&&we.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(we){we!==void 0&&(G=we,this.setSize(W,K,!1))},this.getSize=function(we){return we.set(W,K)},this.setSize=function(we,Ye,at=!0){if(re.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=we,K=Ye,n.width=Math.floor(we*G),n.height=Math.floor(Ye*G),at===!0&&(n.style.width=we+"px",n.style.height=Ye+"px"),this.setViewport(0,0,we,Ye)},this.getDrawingBufferSize=function(we){return we.set(W*G,K*G).floor()},this.setDrawingBufferSize=function(we,Ye,at){W=we,K=Ye,G=at,n.width=Math.floor(we*at),n.height=Math.floor(Ye*at),this.setViewport(0,0,we,Ye)},this.getCurrentViewport=function(we){return we.copy(R)},this.getViewport=function(we){return we.copy(J)},this.setViewport=function(we,Ye,at,ct){we.isVector4?J.set(we.x,we.y,we.z,we.w):J.set(we,Ye,at,ct),X.viewport(R.copy(J).multiplyScalar(G).floor())},this.getScissor=function(we){return we.copy(z)},this.setScissor=function(we,Ye,at,ct){we.isVector4?z.set(we.x,we.y,we.z,we.w):z.set(we,Ye,at,ct),X.scissor(U.copy(z).multiplyScalar(G).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(we){X.setScissorTest(V=we)},this.setOpaqueSort=function(we){Q=we},this.setTransparentSort=function(we){te=we},this.getClearColor=function(we){return we.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor.apply(Xe,arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha.apply(Xe,arguments)},this.clear=function(we=!0,Ye=!0,at=!0){let ct=0;if(we){let st=!1;if(E!==null){const Ct=E.texture.format;st=Ct===Gee||Ct===Vee||Ct===Hee}if(st){const Ct=E.texture.type,Ft=Ct===Gd||Ct===Pd||Ct===pL||Ct===Cf||Ct===Bee||Ct===$ee,Yt=Xe.getClearColor(),Zt=Xe.getClearAlpha(),de=Yt.r,De=Yt.g,We=Yt.b;Ft?(p[0]=de,p[1]=De,p[2]=We,p[3]=Zt,le.clearBufferuiv(le.COLOR,0,p)):(b[0]=de,b[1]=De,b[2]=We,b[3]=Zt,le.clearBufferiv(le.COLOR,0,b))}else ct|=le.COLOR_BUFFER_BIT}Ye&&(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",ke,!1),n.removeEventListener("webglcontextrestored",ve,!1),n.removeEventListener("webglcontextcreationerror",Fe,!1),Se.dispose(),se.dispose(),I.dispose(),Ae.dispose(),Ie.dispose(),L.dispose(),je.dispose(),$e.dispose(),Y.dispose(),re.dispose(),re.removeEventListener("sessionstart",ln),re.removeEventListener("sessionend",Gt),pe&&(pe.dispose(),pe=null),vn.stop()};function ke(we){we.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const we=B.autoReset,Ye=Re.enabled,at=Re.autoUpdate,ct=Re.needsUpdate,st=Re.type;ft(),B.autoReset=we,Re.enabled=Ye,Re.autoUpdate=at,Re.needsUpdate=ct,Re.type=st}function Fe(we){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",we.statusMessage)}function Ue(we){const Ye=we.target;Ye.removeEventListener("dispose",Ue),Te(Ye)}function Te(we){qe(we),I.remove(we)}function qe(we){const Ye=I.get(we).programs;Ye!==void 0&&(Ye.forEach(function(at){Y.releaseProgram(at)}),we.isShaderMaterial&&Y.releaseShaderCache(we))}this.renderBufferDirect=function(we,Ye,at,ct,st,Ct){Ye===null&&(Ye=Ne);const Ft=st.isMesh&&st.matrixWorld.determinant()<0,Yt=yr(we,Ye,at,ct,st);X.setMaterial(ct,Ft);let Zt=at.index,de=1;if(ct.wireframe===!0){if(Zt=$.getWireframeAttribute(at),Zt===void 0)return;de=2}const De=at.drawRange,We=at.attributes.position;let Ze=De.start*de,Ge=(De.start+De.count)*de;Ct!==null&&(Ze=Math.max(Ze,Ct.start*de),Ge=Math.min(Ge,(Ct.start+Ct.count)*de)),Zt!==null?(Ze=Math.max(Ze,0),Ge=Math.min(Ge,Zt.count)):We!=null&&(Ze=Math.max(Ze,0),Ge=Math.min(Ge,We.count));const lt=Ge-Ze;if(lt<0||lt===1/0)return;je.setup(st,ct,Yt,at,Zt);let kt,wt=Je;if(Zt!==null&&(kt=ce.get(Zt),wt=oe,wt.setIndex(kt)),st.isMesh)ct.wireframe===!0?(X.setLineWidth(ct.wireframeLinewidth*_e()),wt.setMode(le.LINES)):wt.setMode(le.TRIANGLES);else if(st.isLine){let _t=ct.linewidth;_t===void 0&&(_t=1),X.setLineWidth(_t*_e()),st.isLineSegments?wt.setMode(le.LINES):st.isLineLoop?wt.setMode(le.LINE_LOOP):wt.setMode(le.LINE_STRIP)}else st.isPoints?wt.setMode(le.POINTS):st.isSprite&&wt.setMode(le.TRIANGLES);if(st.isBatchedMesh)wt.renderMultiDraw(st._multiDrawStarts,st._multiDrawCounts,st._multiDrawCount);else if(st.isInstancedMesh)wt.renderInstances(Ze,lt,st.count);else if(at.isInstancedBufferGeometry){const _t=at._maxInstanceCount!==void 0?at._maxInstanceCount:1/0,Ut=Math.min(at.instanceCount,_t);wt.renderInstances(Ze,lt,Ut)}else wt.render(Ze,lt)};function bt(we,Ye,at){we.transparent===!0&&we.side===Yc&&we.forceSinglePass===!1?(we.side=Ss,we.needsUpdate=!0,Nr(we,Ye,at),we.side=ih,we.needsUpdate=!0,Nr(we,Ye,at),we.side=Yc):Nr(we,Ye,at)}this.compile=function(we,Ye,at=null){at===null&&(at=we),x=se.get(at),x.init(),S.push(x),at.traverseVisible(function(st){st.isLight&&st.layers.test(Ye.layers)&&(x.pushLight(st),st.castShadow&&x.pushShadow(st))}),we!==at&&we.traverseVisible(function(st){st.isLight&&st.layers.test(Ye.layers)&&(x.pushLight(st),st.castShadow&&x.pushShadow(st))}),x.setupLights(M._useLegacyLights);const ct=new Set;return we.traverse(function(st){const Ct=st.material;if(Ct)if(Array.isArray(Ct))for(let Ft=0;Ft<Ct.length;Ft++){const Yt=Ct[Ft];bt(Yt,at,st),ct.add(Yt)}else bt(Ct,at,st),ct.add(Ct)}),S.pop(),x=null,ct},this.compileAsync=function(we,Ye,at=null){const ct=this.compile(we,Ye,at);return new Promise(st=>{function Ct(){if(ct.forEach(function(Ft){I.get(Ft).currentProgram.isReady()&&ct.delete(Ft)}),ct.size===0){st(we);return}setTimeout(Ct,10)}H.get("KHR_parallel_shader_compile")!==null?Ct():setTimeout(Ct,10)})};let Pt=null;function Ot(we){Pt&&Pt(we)}function ln(){vn.stop()}function Gt(){vn.start()}const vn=new cte;vn.setAnimationLoop(Ot),typeof self<"u"&&vn.setContext(self),this.setAnimationLoop=function(we){Pt=we,re.setAnimationLoop(we),we===null?vn.stop():vn.start()},re.addEventListener("sessionstart",ln),re.addEventListener("sessionend",Gt),this.render=function(we,Ye){if(Ye!==void 0&&Ye.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;we.matrixWorldAutoUpdate===!0&&we.updateMatrixWorld(),Ye.parent===null&&Ye.matrixWorldAutoUpdate===!0&&Ye.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(re.cameraAutoUpdate===!0&&re.updateCamera(Ye),Ye=re.getCamera()),we.isScene===!0&&we.onBeforeRender(M,we,Ye,E),x=se.get(we,S.length),x.init(),S.push(x),ie.multiplyMatrices(Ye.projectionMatrix,Ye.matrixWorldInverse),ne.setFromProjectionMatrix(ie),he=this.localClippingEnabled,ae=Pe.init(this.clippingPlanes,he),y=Se.get(we,v.length),y.init(),v.push(y),gt(we,Ye,0,M.sortObjects),y.finish(),M.sortObjects===!0&&y.sort(Q,te),this.info.render.frame++,ae===!0&&Pe.beginShadows();const at=x.state.shadowsArray;if(Re.render(at,we,Ye),ae===!0&&Pe.endShadows(),this.info.autoReset===!0&&this.info.reset(),Xe.render(y,we),x.setupLights(M._useLegacyLights),Ye.isArrayCamera){const ct=Ye.cameras;for(let st=0,Ct=ct.length;st<Ct;st++){const Ft=ct[st];Kt(y,we,Ft,Ft.viewport)}}else Kt(y,we,Ye);E!==null&&(ue.updateMultisampleRenderTarget(E),ue.updateRenderTargetMipmap(E)),we.isScene===!0&&we.onAfterRender(M,we,Ye),je.resetDefaultState(),D=-1,C=null,S.pop(),S.length>0?x=S[S.length-1]:x=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function gt(we,Ye,at,ct){if(we.visible===!1)return;if(we.layers.test(Ye.layers)){if(we.isGroup)at=we.renderOrder;else if(we.isLOD)we.autoUpdate===!0&&we.update(Ye);else if(we.isLight)x.pushLight(we),we.castShadow&&x.pushShadow(we);else if(we.isSprite){if(!we.frustumCulled||ne.intersectsSprite(we)){ct&&xe.setFromMatrixPosition(we.matrixWorld).applyMatrix4(ie);const Ft=L.update(we),Yt=we.material;Yt.visible&&y.push(we,Ft,Yt,at,xe.z,null)}}else if((we.isMesh||we.isLine||we.isPoints)&&(!we.frustumCulled||ne.intersectsObject(we))){const Ft=L.update(we),Yt=we.material;if(ct&&(we.boundingSphere!==void 0?(we.boundingSphere===null&&we.computeBoundingSphere(),xe.copy(we.boundingSphere.center)):(Ft.boundingSphere===null&&Ft.computeBoundingSphere(),xe.copy(Ft.boundingSphere.center)),xe.applyMatrix4(we.matrixWorld).applyMatrix4(ie)),Array.isArray(Yt)){const Zt=Ft.groups;for(let de=0,De=Zt.length;de<De;de++){const We=Zt[de],Ze=Yt[We.materialIndex];Ze&&Ze.visible&&y.push(we,Ft,Ze,at,xe.z,We)}}else Yt.visible&&y.push(we,Ft,Yt,at,xe.z,null)}}const Ct=we.children;for(let Ft=0,Yt=Ct.length;Ft<Yt;Ft++)gt(Ct[Ft],Ye,at,ct)}function Kt(we,Ye,at,ct){const st=we.opaque,Ct=we.transmissive,Ft=we.transparent;x.setupLightsView(at),ae===!0&&Pe.setGlobalState(M.clippingPlanes,at),Ct.length>0&&pn(st,Ct,Ye,at),ct&&X.viewport(R.copy(ct)),st.length>0&&Et(st,Ye,at),Ct.length>0&&Et(Ct,Ye,at),Ft.length>0&&Et(Ft,Ye,at),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function pn(we,Ye,at,ct){if((at.isScene===!0?at.overrideMaterial:null)!==null)return;const Ct=ee.isWebGL2;pe===null&&(pe=new rm(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?ey:Gd,minFilter:J0,samples:Ct?4:0})),M.getDrawingBufferSize(Ee),Ct?pe.setSize(Ee.x,Ee.y):pe.setSize(YS(Ee.x),YS(Ee.y));const Ft=M.getRenderTarget();M.setRenderTarget(pe),M.getClearColor(q),j=M.getClearAlpha(),j<1&&M.setClearColor(16777215,.5),M.clear();const Yt=M.toneMapping;M.toneMapping=Vd,Et(we,at,ct),ue.updateMultisampleRenderTarget(pe),ue.updateRenderTargetMipmap(pe);let Zt=!1;for(let de=0,De=Ye.length;de<De;de++){const We=Ye[de],Ze=We.object,Ge=We.geometry,lt=We.material,kt=We.group;if(lt.side===Yc&&Ze.layers.test(ct.layers)){const wt=lt.side;lt.side=Ss,lt.needsUpdate=!0,Ln(Ze,at,ct,Ge,lt,kt),lt.side=wt,lt.needsUpdate=!0,Zt=!0}}Zt===!0&&(ue.updateMultisampleRenderTarget(pe),ue.updateRenderTargetMipmap(pe)),M.setRenderTarget(Ft),M.setClearColor(q,j),M.toneMapping=Yt}function Et(we,Ye,at){const ct=Ye.isScene===!0?Ye.overrideMaterial:null;for(let st=0,Ct=we.length;st<Ct;st++){const Ft=we[st],Yt=Ft.object,Zt=Ft.geometry,de=ct===null?Ft.material:ct,De=Ft.group;Yt.layers.test(at.layers)&&Ln(Yt,Ye,at,Zt,de,De)}}function Ln(we,Ye,at,ct,st,Ct){we.onBeforeRender(M,Ye,at,ct,st,Ct),we.modelViewMatrix.multiplyMatrices(at.matrixWorldInverse,we.matrixWorld),we.normalMatrix.getNormalMatrix(we.modelViewMatrix),st.onBeforeRender(M,Ye,at,ct,we,Ct),st.transparent===!0&&st.side===Yc&&st.forceSinglePass===!1?(st.side=Ss,st.needsUpdate=!0,M.renderBufferDirect(at,Ye,ct,st,we,Ct),st.side=ih,st.needsUpdate=!0,M.renderBufferDirect(at,Ye,ct,st,we,Ct),st.side=Yc):M.renderBufferDirect(at,Ye,ct,st,we,Ct),we.onAfterRender(M,Ye,at,ct,st,Ct)}function Nr(we,Ye,at){Ye.isScene!==!0&&(Ye=Ne);const ct=I.get(we),st=x.state.lights,Ct=x.state.shadowsArray,Ft=st.state.version,Yt=Y.getParameters(we,st.state,Ct,Ye,at),Zt=Y.getProgramCacheKey(Yt);let de=ct.programs;ct.environment=we.isMeshStandardMaterial?Ye.environment:null,ct.fog=Ye.fog,ct.envMap=(we.isMeshStandardMaterial?Ie:Ae).get(we.envMap||ct.environment),de===void 0&&(we.addEventListener("dispose",Ue),de=new Map,ct.programs=de);let De=de.get(Zt);if(De!==void 0){if(ct.currentProgram===De&&ct.lightsStateVersion===Ft)return tn(we,Yt),De}else Yt.uniforms=Y.getUniforms(we),we.onBuild(at,Yt,M),we.onBeforeCompile(Yt,M),De=Y.acquireProgram(Yt,Zt),de.set(Zt,De),ct.uniforms=Yt.uniforms;const We=ct.uniforms;return(!we.isShaderMaterial&&!we.isRawShaderMaterial||we.clipping===!0)&&(We.clippingPlanes=Pe.uniform),tn(we,Yt),ct.needsLights=lr(we),ct.lightsStateVersion=Ft,ct.needsLights&&(We.ambientLightColor.value=st.state.ambient,We.lightProbe.value=st.state.probe,We.directionalLights.value=st.state.directional,We.directionalLightShadows.value=st.state.directionalShadow,We.spotLights.value=st.state.spot,We.spotLightShadows.value=st.state.spotShadow,We.rectAreaLights.value=st.state.rectArea,We.ltc_1.value=st.state.rectAreaLTC1,We.ltc_2.value=st.state.rectAreaLTC2,We.pointLights.value=st.state.point,We.pointLightShadows.value=st.state.pointShadow,We.hemisphereLights.value=st.state.hemi,We.directionalShadowMap.value=st.state.directionalShadowMap,We.directionalShadowMatrix.value=st.state.directionalShadowMatrix,We.spotShadowMap.value=st.state.spotShadowMap,We.spotLightMatrix.value=st.state.spotLightMatrix,We.spotLightMap.value=st.state.spotLightMap,We.pointShadowMap.value=st.state.pointShadowMap,We.pointShadowMatrix.value=st.state.pointShadowMatrix),ct.currentProgram=De,ct.uniformsList=null,De}function Or(we){if(we.uniformsList===null){const Ye=we.currentProgram.getUniforms();we.uniformsList=v1.seqWithValue(Ye.seq,we.uniforms)}return we.uniformsList}function tn(we,Ye){const at=I.get(we);at.outputColorSpace=Ye.outputColorSpace,at.batching=Ye.batching,at.instancing=Ye.instancing,at.instancingColor=Ye.instancingColor,at.skinning=Ye.skinning,at.morphTargets=Ye.morphTargets,at.morphNormals=Ye.morphNormals,at.morphColors=Ye.morphColors,at.morphTargetsCount=Ye.morphTargetsCount,at.numClippingPlanes=Ye.numClippingPlanes,at.numIntersection=Ye.numClipIntersection,at.vertexAlphas=Ye.vertexAlphas,at.vertexTangents=Ye.vertexTangents,at.toneMapping=Ye.toneMapping}function yr(we,Ye,at,ct,st){Ye.isScene!==!0&&(Ye=Ne),ue.resetTextureUnits();const Ct=Ye.fog,Ft=ct.isMeshStandardMaterial?Ye.environment:null,Yt=E===null?M.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Su,Zt=(ct.isMeshStandardMaterial?Ie:Ae).get(ct.envMap||Ft),de=ct.vertexColors===!0&&!!at.attributes.color&&at.attributes.color.itemSize===4,De=!!at.attributes.tangent&&(!!ct.normalMap||ct.anisotropy>0),We=!!at.morphAttributes.position,Ze=!!at.morphAttributes.normal,Ge=!!at.morphAttributes.color;let lt=Vd;ct.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(lt=M.toneMapping);const kt=at.morphAttributes.position||at.morphAttributes.normal||at.morphAttributes.color,wt=kt!==void 0?kt.length:0,_t=I.get(ct),Ut=x.state.lights;if(ae===!0&&(he===!0||we!==C)){const Bt=we===C&&ct.id===D;Pe.setState(ct,we,Bt)}let Le=!1;ct.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==Ut.state.version||_t.outputColorSpace!==Yt||st.isBatchedMesh&&_t.batching===!1||!st.isBatchedMesh&&_t.batching===!0||st.isInstancedMesh&&_t.instancing===!1||!st.isInstancedMesh&&_t.instancing===!0||st.isSkinnedMesh&&_t.skinning===!1||!st.isSkinnedMesh&&_t.skinning===!0||st.isInstancedMesh&&_t.instancingColor===!0&&st.instanceColor===null||st.isInstancedMesh&&_t.instancingColor===!1&&st.instanceColor!==null||_t.envMap!==Zt||ct.fog===!0&&_t.fog!==Ct||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==Pe.numPlanes||_t.numIntersection!==Pe.numIntersection)||_t.vertexAlphas!==de||_t.vertexTangents!==De||_t.morphTargets!==We||_t.morphNormals!==Ze||_t.morphColors!==Ge||_t.toneMapping!==lt||ee.isWebGL2===!0&&_t.morphTargetsCount!==wt)&&(Le=!0):(Le=!0,_t.__version=ct.version);let pt=_t.currentProgram;Le===!0&&(pt=Nr(ct,Ye,st));let me=!1,He=!1,Lt=!1;const jt=pt.getUniforms(),Wt=_t.uniforms;if(X.useProgram(pt.program)&&(me=!0,He=!0,Lt=!0),ct.id!==D&&(D=ct.id,He=!0),me||C!==we){jt.setValue(le,"projectionMatrix",we.projectionMatrix),jt.setValue(le,"viewMatrix",we.matrixWorldInverse);const Bt=jt.map.cameraPosition;Bt!==void 0&&Bt.setValue(le,xe.setFromMatrixPosition(we.matrixWorld)),ee.logarithmicDepthBuffer&&jt.setValue(le,"logDepthBufFC",2/(Math.log(we.far+1)/Math.LN2)),(ct.isMeshPhongMaterial||ct.isMeshToonMaterial||ct.isMeshLambertMaterial||ct.isMeshBasicMaterial||ct.isMeshStandardMaterial||ct.isShaderMaterial)&&jt.setValue(le,"isOrthographic",we.isOrthographicCamera===!0),C!==we&&(C=we,He=!0,Lt=!0)}if(st.isSkinnedMesh){jt.setOptional(le,st,"bindMatrix"),jt.setOptional(le,st,"bindMatrixInverse");const Bt=st.skeleton;Bt&&(ee.floatVertexTextures?(Bt.boneTexture===null&&Bt.computeBoneTexture(),jt.setValue(le,"boneTexture",Bt.boneTexture,ue)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}st.isBatchedMesh&&(jt.setOptional(le,st,"batchingTexture"),jt.setValue(le,"batchingTexture",st._matricesTexture,ue));const Rt=at.morphAttributes;if((Rt.position!==void 0||Rt.normal!==void 0||Rt.color!==void 0&&ee.isWebGL2===!0)&&et.update(st,at,pt),(He||_t.receiveShadow!==st.receiveShadow)&&(_t.receiveShadow=st.receiveShadow,jt.setValue(le,"receiveShadow",st.receiveShadow)),ct.isMeshGouraudMaterial&&ct.envMap!==null&&(Wt.envMap.value=Zt,Wt.flipEnvMap.value=Zt.isCubeTexture&&Zt.isRenderTargetTexture===!1?-1:1),He&&(jt.setValue(le,"toneMappingExposure",M.toneMappingExposure),_t.needsLights&&xi(Wt,Lt),Ct&&ct.fog===!0&&be.refreshFogUniforms(Wt,Ct),be.refreshMaterialUniforms(Wt,ct,G,K,pe),v1.upload(le,Or(_t),Wt,ue)),ct.isShaderMaterial&&ct.uniformsNeedUpdate===!0&&(v1.upload(le,Or(_t),Wt,ue),ct.uniformsNeedUpdate=!1),ct.isSpriteMaterial&&jt.setValue(le,"center",st.center),jt.setValue(le,"modelViewMatrix",st.modelViewMatrix),jt.setValue(le,"normalMatrix",st.normalMatrix),jt.setValue(le,"modelMatrix",st.matrixWorld),ct.isShaderMaterial||ct.isRawShaderMaterial){const Bt=ct.uniformsGroups;for(let At=0,nn=Bt.length;At<nn;At++)if(ee.isWebGL2){const Zr=Bt[At];$e.update(Zr,pt),$e.bind(Zr,pt)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return pt}function xi(we,Ye){we.ambientLightColor.needsUpdate=Ye,we.lightProbe.needsUpdate=Ye,we.directionalLights.needsUpdate=Ye,we.directionalLightShadows.needsUpdate=Ye,we.pointLights.needsUpdate=Ye,we.pointLightShadows.needsUpdate=Ye,we.spotLights.needsUpdate=Ye,we.spotLightShadows.needsUpdate=Ye,we.rectAreaLights.needsUpdate=Ye,we.hemisphereLights.needsUpdate=Ye}function lr(we){return we.isMeshLambertMaterial||we.isMeshToonMaterial||we.isMeshPhongMaterial||we.isMeshStandardMaterial||we.isShadowMaterial||we.isShaderMaterial&&we.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(we,Ye,at){I.get(we.texture).__webglTexture=Ye,I.get(we.depthTexture).__webglTexture=at;const ct=I.get(we);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(we,Ye){const at=I.get(we);at.__webglFramebuffer=Ye,at.__useDefaultFramebuffer=Ye===void 0},this.setRenderTarget=function(we,Ye=0,at=0){E=we,T=Ye,k=at;let ct=!0,st=null,Ct=!1,Ft=!1;if(we){const Zt=I.get(we);Zt.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(le.FRAMEBUFFER,null),ct=!1):Zt.__webglFramebuffer===void 0?ue.setupRenderTarget(we):Zt.__hasExternalTextures&&ue.rebindTextures(we,I.get(we.texture).__webglTexture,I.get(we.depthTexture).__webglTexture);const de=we.texture;(de.isData3DTexture||de.isDataArrayTexture||de.isCompressedArrayTexture)&&(Ft=!0);const De=I.get(we).__webglFramebuffer;we.isWebGLCubeRenderTarget?(Array.isArray(De[Ye])?st=De[Ye][at]:st=De[Ye],Ct=!0):ee.isWebGL2&&we.samples>0&&ue.useMultisampledRTT(we)===!1?st=I.get(we).__webglMultisampledFramebuffer:Array.isArray(De)?st=De[at]:st=De,R.copy(we.viewport),U.copy(we.scissor),O=we.scissorTest}else R.copy(J).multiplyScalar(G).floor(),U.copy(z).multiplyScalar(G).floor(),O=V;if(X.bindFramebuffer(le.FRAMEBUFFER,st)&&ee.drawBuffers&&ct&&X.drawBuffers(we,st),X.viewport(R),X.scissor(U),X.setScissorTest(O),Ct){const Zt=I.get(we.texture);le.framebufferTexture2D(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,le.TEXTURE_CUBE_MAP_POSITIVE_X+Ye,Zt.__webglTexture,at)}else if(Ft){const Zt=I.get(we.texture),de=Ye||0;le.framebufferTextureLayer(le.FRAMEBUFFER,le.COLOR_ATTACHMENT0,Zt.__webglTexture,at||0,de)}D=-1},this.readRenderTargetPixels=function(we,Ye,at,ct,st,Ct,Ft){if(!(we&&we.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Yt=I.get(we).__webglFramebuffer;if(we.isWebGLCubeRenderTarget&&Ft!==void 0&&(Yt=Yt[Ft]),Yt){X.bindFramebuffer(le.FRAMEBUFFER,Yt);try{const Zt=we.texture,de=Zt.format,De=Zt.type;if(de!==No&&ye.convert(de)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const We=De===ey&&(H.has("EXT_color_buffer_half_float")||ee.isWebGL2&&H.has("EXT_color_buffer_float"));if(De!==Gd&&ye.convert(De)!==le.getParameter(le.IMPLEMENTATION_COLOR_READ_TYPE)&&!(De===tu&&(ee.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!We){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ye>=0&&Ye<=we.width-ct&&at>=0&&at<=we.height-st&&le.readPixels(Ye,at,ct,st,ye.convert(de),ye.convert(De),Ct)}finally{const Zt=E!==null?I.get(E).__webglFramebuffer:null;X.bindFramebuffer(le.FRAMEBUFFER,Zt)}}},this.copyFramebufferToTexture=function(we,Ye,at=0){const ct=Math.pow(2,-at),st=Math.floor(Ye.image.width*ct),Ct=Math.floor(Ye.image.height*ct);ue.setTexture2D(Ye,0),le.copyTexSubImage2D(le.TEXTURE_2D,at,0,0,we.x,we.y,st,Ct),X.unbindTexture()},this.copyTextureToTexture=function(we,Ye,at,ct=0){const st=Ye.image.width,Ct=Ye.image.height,Ft=ye.convert(at.format),Yt=ye.convert(at.type);ue.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),Ye.isDataTexture?le.texSubImage2D(le.TEXTURE_2D,ct,we.x,we.y,st,Ct,Ft,Yt,Ye.image.data):Ye.isCompressedTexture?le.compressedTexSubImage2D(le.TEXTURE_2D,ct,we.x,we.y,Ye.mipmaps[0].width,Ye.mipmaps[0].height,Ft,Ye.mipmaps[0].data):le.texSubImage2D(le.TEXTURE_2D,ct,we.x,we.y,Ft,Yt,Ye.image),ct===0&&at.generateMipmaps&&le.generateMipmap(le.TEXTURE_2D),X.unbindTexture()},this.copyTextureToTexture3D=function(we,Ye,at,ct,st=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ct=we.max.x-we.min.x+1,Ft=we.max.y-we.min.y+1,Yt=we.max.z-we.min.z+1,Zt=ye.convert(ct.format),de=ye.convert(ct.type);let De;if(ct.isData3DTexture)ue.setTexture3D(ct,0),De=le.TEXTURE_3D;else if(ct.isDataArrayTexture)ue.setTexture2DArray(ct,0),De=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 We=le.getParameter(le.UNPACK_ROW_LENGTH),Ze=le.getParameter(le.UNPACK_IMAGE_HEIGHT),Ge=le.getParameter(le.UNPACK_SKIP_PIXELS),lt=le.getParameter(le.UNPACK_SKIP_ROWS),kt=le.getParameter(le.UNPACK_SKIP_IMAGES),wt=at.isCompressedTexture?at.mipmaps[0]:at.image;le.pixelStorei(le.UNPACK_ROW_LENGTH,wt.width),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,wt.height),le.pixelStorei(le.UNPACK_SKIP_PIXELS,we.min.x),le.pixelStorei(le.UNPACK_SKIP_ROWS,we.min.y),le.pixelStorei(le.UNPACK_SKIP_IMAGES,we.min.z),at.isDataTexture||at.isData3DTexture?le.texSubImage3D(De,st,Ye.x,Ye.y,Ye.z,Ct,Ft,Yt,Zt,de,wt.data):at.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),le.compressedTexSubImage3D(De,st,Ye.x,Ye.y,Ye.z,Ct,Ft,Yt,Zt,wt.data)):le.texSubImage3D(De,st,Ye.x,Ye.y,Ye.z,Ct,Ft,Yt,Zt,de,wt),le.pixelStorei(le.UNPACK_ROW_LENGTH,We),le.pixelStorei(le.UNPACK_IMAGE_HEIGHT,Ze),le.pixelStorei(le.UNPACK_SKIP_PIXELS,Ge),le.pixelStorei(le.UNPACK_SKIP_ROWS,lt),le.pixelStorei(le.UNPACK_SKIP_IMAGES,kt),st===0&&ct.generateMipmaps&&le.generateMipmap(De),X.unbindTexture()},this.initTexture=function(we){we.isCubeTexture?ue.setTextureCube(we,0):we.isData3DTexture?ue.setTexture3D(we,0):we.isDataArrayTexture||we.isCompressedArrayTexture?ue.setTexture2DArray(we,0):ue.setTexture2D(we,0),X.unbindTexture()},this.resetState=function(){T=0,k=0,E=null,X.reset(),je.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Vl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===gL?"display-p3":"srgb",n.unpackColorSpace=mr.workingColorSpace===pE?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===_a?jf:qee}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===jf?_a:Su}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 PR{}i6e.prototype.isWebGL1Renderer=!0;class wL{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new an(e),this.near=n,this.far=r}clone(){return new wL(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 es{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n}}class s6e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=TR,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=cu()}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=cu()),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=cu()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Wa=new Be;class Rd{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,r=this.data.count;n<r;n++)Wa.fromBufferAttribute(this,n),Wa.applyMatrix4(e),this.setXYZ(n,Wa.x,Wa.y,Wa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Wa.fromBufferAttribute(this,n),Wa.applyNormalMatrix(e),this.setXYZ(n,Wa.x,Wa.y,Wa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Wa.fromBufferAttribute(this,n),Wa.transformDirection(e),this.setXYZ(n,Wa.x,Wa.y,Wa.z);return this}setX(e,n){return this.normalized&&(n=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=Fl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Fl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Fl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Fl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=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 Xs(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Rd(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 Ms{constructor(e=null,n=1,r=1,i,a,o,l,c,u=va,d=va,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 Dp="batchId",hd=new Ar,q7=new Ar,d6e=new Ar,K7=new Ar,rj=new gE,Aw=new ko,Xh=new Xl,kb=new Be,ij=new u6e,Oa=new il,Tw=[];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 il{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ha,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=n,this._maxIndexCount=r,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const n=new Float32Array(e*e*4),r=new o6e(n,e,e,No,tu);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,m=new u.constructor(r*d),p=new c.constructor(m,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new Xs(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Dp,new Xs(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Dp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Dp}"`);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===Dp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ko);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,hd),this.getBoundingBoxAt(i,Aw).applyMatrix4(hd),n.union(Aw))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xl);const e=this._geometryCount,n=this.boundingSphere,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,hd),this.getBoundingSphereAt(i,Xh).applyMatrix4(hd),n.union(Xh))}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 ko,sphereInitialized:!1,sphere:new Xl});const x=this.geometry.getAttribute(Dp);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===Dp)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(kb.fromBufferAttribute(c,m))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,Aw),Aw.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,m=u.start+u.count;f<m;f++){let p=f;l&&(p=l.getX(p)),kb.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(kb))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Oa.material=this.material,Oa.geometry.index=c.index,Oa.geometry.attributes=c.attributes,Oa.geometry.boundingBox===null&&(Oa.geometry.boundingBox=new ko),Oa.geometry.boundingSphere===null&&(Oa.geometry.boundingSphere=new Xl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Oa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Oa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Oa.geometry.boundingBox),this.getBoundingSphereAt(u,Oa.geometry.boundingSphere),Oa.raycast(e,Tw);for(let f=0,m=Tw.length;f<m;f++){const p=Tw[f];p.object=this,p.batchId=u,n.push(p)}Tw.length=0}Oa.material=null,Oa.geometry.index=null,Oa.geometry.attributes={},Oa.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,m=this.perObjectFrustumCulled;m&&(K7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),rj.setFromProjectionMatrix(K7,e.isWebGPURenderer?ty:Vl));let p=0;if(this.sortObjects){q7.copy(this.matrixWorld).invert(),kb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(q7);for(let x=0,v=c.length;x<v;x++)if(c[x]){this.getMatrixAt(x,hd),this.getBoundingSphereAt(x,Xh).applyMatrix4(hd);let S=!1;if(m&&(S=!rj.intersectsSphere(Xh)),!S){const M=kb.distanceTo(Xh.center);ij.push(f[x],M)}}const b=ij.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++}ij.reset()}else for(let b=0,y=c.length;b<y;b++)if(c[b]){let x=!1;if(m&&(this.getMatrixAt(b,hd),this.getBoundingSphereAt(b,Xh).applyMatrix4(hd),x=!rj.intersectsSphere(Xh)),!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 Yy extends dx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new an(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const X7=new Be,Y7=new Be,Z7=new Ar,aj=new bL,Cw=new Xl;class m6e extends es{constructor(e=new Ha,n=new Yy){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)X7.fromBufferAttribute(n,i-1),Y7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=X7.distanceTo(Y7);e.setAttribute("lineDistance",new gi(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(),Cw.copy(r.boundingSphere),Cw.applyMatrix4(i),Cw.radius+=a,e.ray.intersectsSphere(Cw)===!1)return;Z7.copy(i).invert(),aj.copy(e.ray).applyMatrix4(Z7);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),aj.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(m);D<e.near||D>e.far||n.push({distance:D,point:f.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let M=v,A=S-1;M<A;M+=p){if(u.fromBufferAttribute(x,M),d.fromBufferAttribute(x,M+1),aj.distanceSqToSegment(u,d,m,f)>c)continue;m.applyMatrix4(this.matrixWorld);const k=e.ray.origin.distanceTo(m);k<e.near||k>e.far||n.push({distance:k,point:f.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const Q7=new Be,J7=new Be;class bE 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)Q7.fromBufferAttribute(n,i),J7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+Q7.distanceTo(J7);e.setAttribute("lineDistance",new gi(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class p6e extends Ha{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Be,a=new Be;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],m=f.start,p=f.count;for(let b=m,y=m+p;b<y;b+=3)for(let x=0;x<3;x++){const v=l.getX(b+x),S=l.getX(b+(x+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,S),e9(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(o,d),a.fromBufferAttribute(o,f),e9(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new gi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function e9(t,e,n){const r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}class g6e extends dx{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new an(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new an(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Kee,this.normalScale=new fn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=mL,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 Yy{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 gte extends es{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new an(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}const sj=new Ar,t9=new Be,n9=new Be;class b6e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new fn(512,512),this.map=null,this.mapPass=null,this.matrix=new Ar,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new gE,this._frameExtents=new fn(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;t9.setFromMatrixPosition(e.matrixWorld),n.position.copy(t9),n9.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(n9),n.updateMatrixWorld(),sj.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sj),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(sj)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const r9=new Ar,jb=new Be,oj=new Be;class y6e extends b6e{constructor(){super(new zs(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new fn(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()),jb.setFromMatrixPosition(e.matrixWorld),r.position.copy(jb),oj.copy(r.position),oj.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(oj),r.updateMatrixWorld(),i.makeTranslation(-jb.x,-jb.y,-jb.z),r9.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(r9)}}class v6e extends gte{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 gte{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class w6e extends Ha{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class RR 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 i9{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(wa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const a9=new Be,kw=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){a9.subVectors(e,this.start),kw.subVectors(this.end,this.start);const r=kw.dot(kw);let a=kw.dot(a9)/r;return n&&(a=wa(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 bE{constructor(e=1){const n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ha;i.setAttribute("position",new gi(n,3)),i.setAttribute("color",new gi(r,3));const a=new Yy({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new an,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:fE}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=fE);class Yl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Yl.nextNameID=Yl.nextNameID||0,this.$name.id=`lil-gui-name-${++Yl.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class N6e extends Yl{constructor(e,n,r){super(e,n,r,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function DR(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:DR,toHexString:DR},ry={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=ry.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 ry.toHexString(i)}},T6e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=ry.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 ry.toHexString(i)}},C6e=[E6e,ry,A6e,T6e];function k6e(t){return C6e.find(e=>e.match(t))}class j6e extends Yl{constructor(e,n,r,i){super(e,n,r,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=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=DR(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class lj extends Yl{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class P6e extends Yl{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const M=parseFloat(this.$input.value);isNaN(M)||(this._snapClampSetValue(M+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},a=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,f;const m=5,p=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",y)},b=S=>{if(o){const M=S.clientX-l,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 Yl{constructor(e,n,r,i){super(e,n,r,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class D6e extends Yl{constructor(e,n,r){super(e,n,r,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const 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 s9=!1;class QS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:o=!1,injectStyles:l=!0,touchStyles:c=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",u=>{(u.code==="Enter"||u.code==="Space")&&(u.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!s9&&l&&(L6e(O6e),s9=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,n,r,i,a){if(Object(r)===r)return new 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 lj(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 QS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof lj||r._name in e.controllers&&r.load(e.controllers[r._name])}),n&&e.folders&&this.folders.forEach(r=>{r._title in e.folders&&r.load(e.folders[r._title])}),this}save(e=!0){const n={controllers:{},folders:{}};return this.controllers.forEach(r=>{if(!(r instanceof lj)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function cj(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class SL{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 SL(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 ML{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class o9 extends ML{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class fd extends ML{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class l9{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class JS{constructor(e){this.lines=[],this.preamble=new l9(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],o=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new o9(e,c,u,o);case"t0":return new fd(e,c,o,0);case"t1":return new fd(e,c,o,1);case"t2":return new fd(e,c,o,2);case"t3":return new fd(e,c,o,3);case"t4":return new fd(e,c,o,4);case"t5":return new fd(e,c,o,5);case"t6":return new fd(e,c,o,6);case"t7":return new fd(e,c,o,7);default:return new ML(e,c,u,o)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,a)=>{if(i%2==0)return n;let o=a[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof o9){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new l9(this.layers.length,[],r,o))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=SL.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}}}JS.prototype.parseGcode=JS.prototype.parseGCode;const c9={type:"change"},uj={type:"start"},u9={type:"end"},jw=new bL,d9=new vd,I6e=Math.cos(70*Yee.DEG2RAD);class F6e extends pm{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:gp.ROTATE,MIDDLE:gp.DOLLY,RIGHT:gp.PAN},this.touches={ONE:xp.ROTATE,TWO:xp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.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",_e),this._domElementKeyEvents=ee},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",_e),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(c9),r.update(),a=i.NONE},this.update=(function(){const ee=new Be,X=new im().setFromUnitVectors(e.up,new Be(0,1,0)),B=X.clone().invert(),I=new Be,ue=new im,Ae=new Be,Ie=2*Math.PI;return function(ce=null){const $=r.object.position;ee.copy($).sub(r.target),ee.applyQuaternion(X),l.setFromVector3(ee),r.autoRotate&&a===i.NONE&&R((function(Se){return Se!==null?2*Math.PI/60*r.autoRotateSpeed*Se:2*Math.PI/60/60*r.autoRotateSpeed})(ce)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let L=r.minAzimuthAngle,Y=r.maxAzimuthAngle;isFinite(L)&&isFinite(Y)&&(L<-Math.PI?L+=Ie:L>Math.PI&&(L-=Ie),Y<-Math.PI?Y+=Ie:Y>Math.PI&&(Y-=Ie),l.theta=L<=Y?Math.max(L,Math.min(Y,l.theta)):l.theta>(L+Y)/2?Math.max(L,l.theta):Math.min(Y,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&k||r.object.isOrthographicCamera?l.radius=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 be=!1;if(r.zoomToCursor&&k){let Se=null;if(r.object.isPerspectiveCamera){const se=ee.length();Se=Q(se*u);const Pe=se-Se;r.object.position.addScaledVector(A,Pe),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const se=new Be(T.x,T.y,0);se.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0;const Pe=new Be(T.x,T.y,0);Pe.unproject(r.object),r.object.position.sub(Pe).add(se),r.object.updateMatrixWorld(),Se=ee.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Se!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Se).add(r.object.position):(jw.origin.copy(r.object.position),jw.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(jw.direction))<I6e?e.lookAt(r.target):(d9.setFromNormalAndCoplanarPoint(r.object.up,r.target),jw.intersectPlane(d9,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),be=!0);return u=1,k=!1,!!(be||I.distanceToSquared(r.object.position)>o||8*(1-ue.dot(r.object.quaternion))>o||Ae.distanceToSquared(r.target)>0)&&(r.dispatchEvent(c9),I.copy(r.object.position),ue.copy(r.object.quaternion),Ae.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",le),r.domElement.removeEventListener("pointerdown",ie),r.domElement.removeEventListener("pointercancel",xe),r.domElement.removeEventListener("wheel",Ne),r.domElement.removeEventListener("pointermove",Ee),r.domElement.removeEventListener("pointerup",xe),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",_e),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new i9,c=new i9;let u=1;const d=new Be,f=new fn,m=new fn,p=new fn,b=new fn,y=new fn,x=new fn,v=new fn,S=new fn,M=new fn,A=new Be,T=new fn;let k=!1;const E=[],D={};function C(){return Math.pow(.95,r.zoomSpeed)}function R(ee){c.theta-=ee}function U(ee){c.phi-=ee}const O=(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)}})(),j=(function(){const ee=new Be;return function(X,B){const I=r.domElement;if(r.object.isPerspectiveCamera){const ue=r.object.position;ee.copy(ue).sub(r.target);let Ae=ee.length();Ae*=Math.tan(r.object.fov/2*Math.PI/180),O(2*X*Ae/I.clientHeight,r.object.matrix),q(2*B*Ae/I.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(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 G(ee){if(!r.zoomToCursor)return;k=!0;const X=r.domElement.getBoundingClientRect(),B=ee.clientX-X.left,I=ee.clientY-X.top,ue=X.width,Ae=X.height;T.x=B/ue*2-1,T.y=-I/Ae*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 te(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 V(){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),ue=.5*(ee.pageY+B.y);m.set(I,ue)}p.subVectors(m,f).multiplyScalar(r.rotateSpeed);const X=r.domElement;R(2*Math.PI*p.x/X.clientHeight),U(2*Math.PI*p.y/X.clientHeight),f.copy(m)}function he(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),j(x.x,x.y),b.copy(y)}function pe(ee){const X=H(ee),B=ee.pageX-X.x,I=ee.pageY-X.y,ue=Math.sqrt(B*B+I*I);S.set(0,ue),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",Ee),r.domElement.addEventListener("pointerup",xe)),(function(X){E.push(X)})(ee),ee.pointerType==="touch"?(function(X){switch(Ve(X),E.length){case 1:switch(r.touches.ONE){case xp.ROTATE:if(r.enableRotate===!1)return;z(),a=i.TOUCH_ROTATE;break;case xp.PAN:if(r.enablePan===!1)return;V(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case xp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ne(),r.enablePan&&V(),a=i.TOUCH_DOLLY_PAN;break;case xp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ne(),r.enableRotate&&z(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(uj)})(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 gp.DOLLY:if(r.enableZoom===!1)return;(function(I){G(I),v.set(I.clientX,I.clientY)})(X),a=i.DOLLY;break;case gp.ROTATE:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enablePan===!1)return;J(X),a=i.PAN}else{if(r.enableRotate===!1)return;te(X),a=i.ROTATE}break;case gp.PAN:if(X.ctrlKey||X.metaKey||X.shiftKey){if(r.enableRotate===!1)return;te(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(uj)})(ee))}function Ee(ee){r.enabled!==!1&&(ee.pointerType==="touch"?(function(X){switch(Ve(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;he(X),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(B){r.enableZoom&&pe(B),r.enablePan&&he(B)})(X),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(B){r.enableZoom&&pe(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;R(2*Math.PI*p.x/I.clientHeight),U(2*Math.PI*p.y/I.clientHeight),f.copy(m),r.update()})(X);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(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),j(x.x,x.y),b.copy(y),r.update()})(X)}})(ee))}function xe(ee){(function(X){delete D[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",Ee),r.domElement.removeEventListener("pointerup",xe)),r.dispatchEvent(u9),a=i.NONE}function Ne(ee){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(ee.preventDefault(),r.dispatchEvent(uj),(function(X){G(X),X.deltaY<0?K(C()):X.deltaY>0&&W(C()),r.update()})(ee),r.dispatchEvent(u9))}function _e(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):j(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):j(0,-r.keyPanSpeed),B=!0;break;case r.keys.LEFT:X.ctrlKey||X.metaKey||X.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),B=!0;break;case r.keys.RIGHT:X.ctrlKey||X.metaKey||X.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),B=!0}B&&(X.preventDefault(),r.update())})(ee)}function le(ee){r.enabled!==!1&&ee.preventDefault()}function Ve(ee){let X=D[ee.pointerId];X===void 0&&(X=new fn,D[ee.pointerId]=X),X.set(ee.pageX,ee.pageY)}function H(ee){const X=ee.pointerId===E[0].pointerId?E[1]:E[0];return D[X.pointerId]}r.domElement.addEventListener("contextmenu",le),r.domElement.addEventListener("pointerdown",ie),r.domElement.addEventListener("pointercancel",xe),r.domElement.addEventListener("wheel",Ne,{passive:!1}),this.update()}}Dt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new fn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},xs.line={uniforms:yL.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 xte extends ah{constructor(e){super({type:"LineMaterial",uniforms:yL.clone(xs.line.uniforms),vertexShader:xs.line.vertexShader,fragmentShader:xs.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const h9=new ko,Pw=new Be;class bte 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 gi([-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 gi([-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 RR(n,6,1);return this.setAttribute("instanceStart",new Rd(r,3,0)),this.setAttribute("instanceEnd",new Rd(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 RR(n,6,1);return this.setAttribute("instanceColorStart",new Rd(r,3,0)),this.setAttribute("instanceColorEnd",new Rd(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 ko);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),h9.setFromBufferAttribute(n),this.boundingBox.union(h9))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xl),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Pw.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Pw)),Pw.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(Pw));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}const f9=new Be,m9=new Be,ma=new gr,pa=new gr,Cl=new gr,dj=new Be,hj=new Ar,ga=new S6e,p9=new Be,Rw=new ko,Dw=new Xl,kl=new gr;let jl,of;function g9(t,e,n){return kl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),kl.multiplyScalar(1/kl.w),kl.x=of/n.width,kl.y=of/n.height,kl.applyMatrix4(t.projectionMatrixInverse),kl.multiplyScalar(1/kl.w),Math.abs(Math.max(kl.x,kl.y))}class U6e extends il{constructor(e=new bte,n=new xte({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let o=0,l=0,c=n.count;o<c;o++,l+=2)f9.fromBufferAttribute(n,o),m9.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+f9.distanceTo(m9);const a=new RR(i,2,1);return e.setAttribute("instanceDistanceStart",new Rd(a,1,0)),e.setAttribute("instanceDistanceEnd",new Rd(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;jl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;of=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),Dw.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*of:u=g9(i,Math.max(i.near,Dw.distanceToPoint(jl.origin)),c.resolution),Dw.radius+=u,jl.intersectsSphere(Dw)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),Rw.copy(l.boundingBox).applyMatrix4(o),r?d=.5*of:d=g9(i,Math.max(i.near,Rw.distanceToPoint(jl.origin)),c.resolution),Rw.expandByScalar(d),jl.intersectsBox(Rw)!==!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++){ga.start.fromBufferAttribute(y,v),ga.end.fromBufferAttribute(x,v),ga.applyMatrix4(p);const M=new Be,A=new Be;jl.distanceSqToSegment(ga.start,ga.end,A,M),A.distanceTo(M)<.5*of&&m.push({point:A,pointOnLine:M,distance:jl.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;jl.at(1,Cl),Cl.w=1,Cl.applyMatrix4(m.matrixWorldInverse),Cl.applyMatrix4(b),Cl.multiplyScalar(1/Cl.w),Cl.x*=y.x/2,Cl.y*=y.y/2,Cl.z=0,dj.copy(Cl),hj.multiplyMatrices(m.matrixWorldInverse,x);for(let k=0,E=A;k<E;k++){if(ma.fromBufferAttribute(S,k),pa.fromBufferAttribute(M,k),ma.w=1,pa.w=1,ma.applyMatrix4(hj),pa.applyMatrix4(hj),ma.z>T&&pa.z>T)continue;if(ma.z>T){const O=ma.z-pa.z,q=(ma.z-T)/O;ma.lerp(pa,q)}else if(pa.z>T){const O=pa.z-ma.z,q=(pa.z-T)/O;pa.lerp(ma,q)}ma.applyMatrix4(b),pa.applyMatrix4(b),ma.multiplyScalar(1/ma.w),pa.multiplyScalar(1/pa.w),ma.x*=y.x/2,ma.y*=y.y/2,pa.x*=y.x/2,pa.y*=y.y/2,ga.start.copy(ma),ga.start.z=0,ga.end.copy(pa),ga.end.z=0;const D=ga.closestPointToPointParameter(dj,!0);ga.at(D,p9);const C=Yee.lerp(ma.z,pa.z,D),R=C>=-1&&C<=1,U=dj.distanceTo(p9)<.5*of;if(R&&U){ga.start.fromBufferAttribute(S,k),ga.end.fromBufferAttribute(M,k),ga.start.applyMatrix4(x),ga.end.applyMatrix4(x);const O=new Be,q=new Be;jl.distanceSqToSegment(ga.start,ga.end,q,O),p.push({point:q,pointOnLine:O,distance:jl.origin.distanceTo(q),object:f,face:null,faceIndex:k,uv:null,uv1:null})}}})(this,i,n)))}}class z6e extends bE{constructor(e,n,r,i,a=4473924,o=8947848){a=new an(a),o=new an(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let m=-1*(e=l*n/2);m<=e;m+=n){c.push(m,0,-1*r,m,0,r);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let m=-1*r;m<=r;m+=i){c.push(-1*e,0,m,e,0,m);const p=m===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Ha;f.setAttribute("position",new gi(c,3)),f.setAttribute("color",new gi(u,3)),super(f,new Yy({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 Ha,d=[];return d.push(-o,-l,-c,-o,l,-c,-o,l,-c,o,l,-c,o,l,-c,o,-l,-c,o,-l,-c,-o,-l,-c,-o,-l,c,-o,l,c,-o,l,c,o,l,c,o,l,c,o,-l,c,o,-l,c,-o,-l,c,-o,-l,-c,-o,-l,c,-o,l,-c,-o,l,c,o,l,-c,o,l,c,o,-l,-c,o,-l,c),u.setAttribute("position",new gi(d,3)),u})(t,e,n),a=new bE(i,new x6e({color:new an(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var o0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,o=0,l=n(new o0.Panel("FPS","#0ff","#002")),c=n(new o0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new o0.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(l.update(1e3*o/(d-a),100),a=d,o=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};o0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,m=15*o,p=74*o,b=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var x=y.getContext("2d");return x.font="bold "+9*o+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=n,x.fillRect(0,0,l,c),x.fillStyle=e,x.fillText(t,u,d),x.fillRect(f,m,p,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f,m,p,b),{dom:y,update:function(v,S){r=Math.min(r,v),i=Math.max(i,v),x.fillStyle=n,x.globalAlpha=1,x.fillRect(0,0,l,m),x.fillStyle=e,x.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),x.drawImage(y,f+o,m,p-o,b,f,m,p-o,b),x.fillRect(f+p-o,m,o,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f+p-o,m,o,a((1-v/S)*b))}}};var $6e=o0;class x9{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new QS,this.gui.title("Dev info"),this.setup()}setup(){this.loadOpenFolders(),this.options&&!this.options.renderer||this.setupRedererFolder(),this.options&&!this.options.camera||this.setupCameraFolder(),this.options&&!this.options.parser||this.setupParserFolder(),this.options&&!this.options.buildVolume||this.setupBuildVolumeFolder(),this.options&&!this.options.devHelpers||this.setupDevHelpers()}reset(){this.gui.destroy(),this.gui=new QS,this.gui.title("Dev info"),this.setup()}loadOpenFolders(){this.openFolders=JSON.parse(localStorage.getItem("dev-gui-open")||"{}").open||[]}saveOpenFolders(){this.openFolders=this.gui.foldersRecursive().filter((e=>!e._closed)).map((e=>e._title)),console.log(this.openFolders),localStorage.setItem("dev-gui-open",JSON.stringify({open:this.openFolders}))}setupRedererFolder(){const e=this.gui.addFolder("Render Info");this.openFolders.includes("Render Info")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.renderer.info.render,"triangles").listen(),e.add(this.watchedObject.renderer.info.render,"calls").listen(),e.add(this.watchedObject.renderer.info.render,"lines").listen(),e.add(this.watchedObject.renderer.info.render,"points").listen(),e.add(this.watchedObject.renderer.info.memory,"geometries").listen(),e.add(this.watchedObject.renderer.info.memory,"textures").listen(),e.add(this.watchedObject,"_lastRenderTime").listen()}setupCameraFolder(){const e=this.gui.addFolder("Camera");this.openFolders.includes("Camera")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()}));const n=e.addFolder("Camera position");n.add(this.watchedObject.camera.position,"x").listen(),n.add(this.watchedObject.camera.position,"y").listen(),n.add(this.watchedObject.camera.position,"z").listen();const r=e.addFolder("Camera rotation");r.add(this.watchedObject.camera.rotation,"x").listen(),r.add(this.watchedObject.camera.rotation,"y").listen(),r.add(this.watchedObject.camera.rotation,"z").listen()}setupParserFolder(){const e=this.gui.addFolder("Parser");this.openFolders.includes("Parser")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.parser,"curZ").listen(),e.add(this.watchedObject.parser,"maxZ").listen(),e.add(this.watchedObject.parser,"tolerance").listen(),e.add(this.watchedObject.parser.layers,"length").name("layers.count").listen(),e.add(this.watchedObject.parser.lines,"length").name("lines.count").listen()}setupBuildVolumeFolder(){const e=this.gui.addFolder("Build Volume");this.openFolders.includes("Build Volume")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.buildVolume,"x").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,"y").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,"z").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()}))}setupDevHelpers(){const e=this.gui.addFolder("Dev Helpers");this.openFolders.includes("Dev Helpers")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject,"_wireframe").listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject,"render").listen(),e.add(this.watchedObject,"clear").listen()}}class H6e extends Ha{constructor(e=[new Be],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new Be,o=new Be,l=new fn,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 D=Math.abs(M.x),C=Math.abs(M.y),R=Math.abs(M.z);return D<=E&&(E=D,A.set(1,0,0)),C<=E&&(E=C,A.set(0,1,0)),R<=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 gi(c,3)),this.setAttribute("normal",new gi(u,3)),this.setAttribute("uv",new gi(d,2))}}class l0{static get initial(){const e=new l0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const fj={h:0,s:0,l:0};class dg{constructor(e){var n,r,i,a,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=l0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=dg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new an(14737632),this._travelColor=new an(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 JS(this.minLayerThreshold),this.scene=new a6e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new an(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 an(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new an(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new an(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,b]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new an(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+fE),console.debug("opts",e),this.targetId&&console.warn("`targetId` is deprecated and will removed in the future. Use `canvas` instead."),e.canvas)this.canvas=e.canvas,this.renderer=new PR({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 PR({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new zs(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new wL(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 an(r)}else this._extrusionColor=new an(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?dg.defaultExtrusionColor:this._extrusionColor instanceof an?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:dg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new an(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new an(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new an(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new an(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 Wb;return n.name=e,n.quaternion.setFromEuler(new Ky(-Math.PI/2,0,0)),this.buildVolume?n.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):n.position.set(-100,0,100),n}render(){const e=performance.now();this.group=this.createGroup("allLayers"),this.state=l0.initial,this.initScene();for(let n=0;n<this.layers.length;n++)this.renderLayer(n);this.batchGeometries(),this.scene.add(this.group),this.renderer.render(this.scene,this.camera),this._lastRenderTime=performance.now()-e}renderAnimated(e=1){return cj(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const m of d.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=m;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const p=m,b={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,b,y,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,b,y))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(fj),a=new an().setHSL(fj.h,fj.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:a,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...u,...c],l.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new 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 JS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=l0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,m=r.z;let p=r.r,b=r.i,y=r.j;if(p){const W=d-l,K=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(K/2,2));p=Math.max(p,G);const Q=Math.pow(W,2)+Math.pow(K,2),te=Math.pow(p,2)-Q/4;let J=Math.sqrt(te/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 D=k/E;D*=a?-1:1;const C=[];C.push({x:l,y:c,z:u});const R=(u-m)/E;let U=l,O=c,q=u,j=A;for(let W=0;W<E-1;W++)j+=D,U=v+M*Math.cos(j),O=S+M*Math.sin(j),q+=R,C.push({x:U,y:O,z:q});C.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<C.length-1;W++)o.push(C[W].x,C[W].y,C[W].z,C[W+1].x,C[W+1].y,C[W+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new Ha;i.setAttribute("position",new gi(e,3)),this.disposables.push(i);const a=new Yy({color:n});this.disposables.push(a);const o=new bE(i,a);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new Be(l[0],l[1],l[2]),u=new Be(l[3],l[4],l[5]),d=new Be(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((o=>{var l;const c=new 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 bte;this.disposables.push(i);const a=new xte({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=>cj(this,void 0,void 0,(function*(){var n,r;e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging");const i=((r=(n=e.dataTransfer)===null||n===void 0?void 0:n.files)!==null&&r!==void 0?r:[])[0];this.clear(),yield this._readFromStream(i.stream()),this.render()}))))}batchGeometries(){if(this._geometries)for(const e in this._geometries){const n=this.createBatchMesh(parseInt(e));for(;this._geometries[e].length>0;){const r=this._geometries[e].pop();n.addGeometry(r)}}}createBatchMesh(e){var n;const r=this._geometries[e],i=new 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 cj(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new x9(this):typeof this.devMode=="object"&&(this.devGui=new x9(this,this.devMode))}initStats(){var e;this.stats&&(typeof this.devMode=="object"&&(this.statsContainer=this.devMode.statsContainer),((e=this.statsContainer)!==null&&e!==void 0?e:document.body).appendChild(this.stats.dom),this.stats.dom.classList.add("stats"),this.initGui())}}dg.defaultExtrusionColor=new an("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,D=n?.[0]||"#00ae42",C=new dg({canvas:T,buildVolume:e,backgroundColor:1710618,extrusionColor:E?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=C,fetch(t).then(async U=>{if(!U.ok)throw U.status===404&&(await U.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return U.text()}).then(U=>{const O=new Set,q=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=q.exec(U))!==null;){const J=parseInt(j[2],10);J<=15&&O.add(J)}const W=new Map,K=Array.from(O).sort((J,z)=>J-z);K.forEach((J,z)=>{W.set(J,z%8)});const G=[];K.forEach((J,z)=>{const V=n?.[J]||"#00ae42";G[z%8]=V});const Q=U.split(`
- `).map(J=>{const z=J.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(z){const V=parseInt(z[2],10);if(V>15)return`; FILTERED: ${J.trim()}`;const ne=W.get(V)??0;return`${z[1]}T${ne}${z[3]||""}`}return J}).join(`
- `);G.length>0&&(C.extrusionColor=G),C.processGCode(Q);const te=C.layers?.length||0;v(te),y(te),C.render(),u(!1)}).catch(U=>{U.message!=="not_sliced"&&f(U.message),u(!1)});const R=()=>{if(T.parentElement&&a.current){const U=T.parentElement.getBoundingClientRect();T.width=U.width,T.height=U.height,a.current.resize()}};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,S]);const M=w.useCallback(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(cl,{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(Bf,{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(Zs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[b," / ",x]})]})})]})}function yte({archiveId:t,title:e,onClose:n}){const[r,i]=w.useState(null),[a,o]=w.useState(null),[l,c]=w.useState(!0);w.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),w.useEffect(()=>{fe.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${fe.getArchiveForSlicer(t,d)}`;Xc(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(zr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Ht,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(Bs,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(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?fe.getSource3mfDownloadUrl(t):fe.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(V6e,{gcodeUrl:fe.getArchiveGcode(t),filamentColors:a.filament_colors,className:"w-full h-full"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const b9={"000000":"Black","001489":"Blue","002e96":"Blue","0047bb":"Blue","00482b":"Pine Green","004ea8":"Blue","0056b8":"Cobalt Blue","0069b1":"Lake Blue","0072ce":"Blue","0078bf":"Marine Blue","0085ad":"Light Blue","0086d6":"Cyan","008bda":"Blue","009639":"Green","009bd8":"Cyan","009fa1":"Teal","00a6a0":"Green","00ae42":"Bambu Green","00b1b7":"Turquoise","00bb31":"Green","018814":"Candy Green","042f56":"Dark Blue","0a2989":"Blue","0a2ca5":"Blue","0c2340":"Navy Blue","0c3b95":"Blue",101820:"Black","147bd1":"Blue","164b35":"Green","16b08e":"Malachite Green","1d7c6a":"Oxide Green Metallic","1f79e5":"Lake Blue","2140b4":"Blue","25282a":"Black","2842ad":"Royal Blue","2d2b28":"Onyx Black Sparkle",324585:"Indigo Blue",353533:"Gray","39541a":"Forest Green","39699e":"Cobalt Blue Metallic","3b665e":"Green","3f5443":"Alpine Green Sparkle","3f8e43":"Mistletoe Green",424379:"Nebulae","43403d":"Iron Gray Metallic",482960:"Indigo Purple","483d8b":"Royal Purple Sparkle","489fdf":"Azure","4c241c":"Rosewood","4ce4a0":"Green","4d3324":"Dark Chocolate","4d5054":"Lava Gray","4dafda":"Cyan","4f3f24":"Black Walnut",515151:"Dark Gray","515a6c":"Gray",545454:"Dark Gray",565656:"Titan Gray","56b7e6":"Sky Blue",583061:"Violet Purple","5898dd":"Blue",594177:"Purple","5b492f":"Brown","5b6579":"Blue Gray","5c9748":"Matcha Green","5e43b7":"Purple","5e4b3c":"Copper","5f6367":"Titan Gray","61b0ff":"Translucent Light Blue","61bf36":"Green","61c680":"Grass Green","6667ab":"Lavender Blue","684a43":"Brown",686865:"Black","68724d":"Dark Green",688197:"Blue Gray","69398e":"Iris Purple","6e88bc":"Jeans Blue","6ee53c":"Lime Green","6f5034":"Cocoa Brown","7248bd":"Lavender","748c45":"Translucent Olive",757575:"Nardo Gray","75aed8":"Blue","77edd7":"Translucent Teal","789d4a":"Olive","792b36":"Crimson Red Sparkle","7ac0e9":"Glow Blue","7ae1bf":"Mint","7cd82b":"Lime Green","7d6556":"Dark Brown","8344b0":"Purple","847d48":"Bronze","854ce4":"Purple","8671cb":"Purple",875718:"Peanut Brown","87909a":"Silver","898d8d":"Gray","8a949e":"Gray","8e8e8e":"Translucent Gray","8e9089":"Gray","90ff1a":"Neon Green",918669:"Classic Birch",939393:"Gray",950051:"Plum","951e23":"Burgundy Red",959698:"Silver","96d8af":"Light Jade","96dcb9":"Mint","995f11":"Clay Brown","999d9d":"Gray","9b9ea0":"Ash Gray","9d2235":"Maroon Red","9d432c":"Brown","9e007e":"Purple","9ea2a2":"Gray","9f332a":"Brick Red",a1ffac:"Glow Green",a3d8e1:"Ice Blue",a6a9aa:"Silver",a8a8aa:"Gray",a8c6ee:"Baby Blue",aa6443:"Copper Brown Metallic",ad4e38:"Red Granite",adb1b2:"Gray",ae835b:"Caramel",ae96d4:"Lilac Purple",af1685:"Purple",afb1ae:"Gray",b15533:"Terracotta",b28b33:"Gold",b39b84:"Iridium Gold Metallic",b50011:"Red",b8acd6:"Lavender",b8cde9:"Ice Blue",ba9594:"Rose Gold",bb3d43:"Dark Red",bc0900:"Red",becf00:"Bright Green",c0df16:"Green",c12e1f:"Red",c2e189:"Apple Green",c3e2d6:"Light Cyan",c5ed48:"Lime",c6001a:"Red",c6c6c6:"Gray",c8102e:"Red",c8c8c8:"Silver",c98935:"Ochre Yellow",c9a381:"Translucent Brown",cbc6b8:"Bone White",cdceca:"Gray",cea629:"Classic Gold Sparkle",d02727:"Candy Red",d1d3d5:"Light Gray",d32941:"Red",d3b7a7:"Latte Brown",d6001c:"Red",d6abff:"Translucent Purple",d6cca3:"White Oak",dc3a27:"Orange",dd3c22:"Vermilion Red",de4343:"Scarlet Red",dfd1a7:"Beige",e02928:"Red",e4bd68:"Gold",e5b03d:"Gold",e83100:"Red",e8afcf:"Sakura Pink",e8dbb7:"Desert Tan",eaeae4:"White",eaeceb:"Silver",ec008c:"Magenta",ed0000:"Red",eeb1c1:"Pink",efe255:"Yellow",f0f1a8:"Clear",f17b8f:"Glow Pink",f3cfb2:"Champagne",f3e600:"Yellow",f48438:"Orange",f4a925:"Gold",f4d53f:"Yellow",f4ee2a:"Yellow",f5547c:"Hot Pink",f55a74:"Pink",f5b6cd:"Cherry Pink",f5dbab:"Mellow Yellow",f5f1dd:"White",f68b1b:"Neon Orange",f74e02:"Orange",f75403:"Orange",f7ada6:"Pink",f7d959:"Lemon Yellow",f7e6de:"Beige",f7f3f0:"White Marble",f8ff80:"Glow Yellow",f99963:"Mandarin Orange",f9c1bd:"Translucent Pink",f9dfb9:"Cream",f9ef41:"Yellow",f9f7f2:"Nature",f9f7f4:"White",fce300:"Yellow",fce900:"Yellow",fec600:"Sunflower Yellow",fedb00:"Yellow",ff4800:"Orange",ff671f:"Orange",ff6a13:"Orange",ff7f41:"Orange",ff9016:"Pumpkin Orange",ff911a:"Translucent Orange",ff9d5b:"Glow Orange",ffb549:"Sunflower Yellow",ffc72c:"Tangerine Yellow",ffce00:"Yellow",ffd00b:"Yellow",ffe133:"Yellow",fffaf2:"White",ffffff:"White"};function 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 Lg(t){const e=t.replace("#","").toLowerCase().substring(0,6);return b9[e]?b9[e]:G6e(t)}function eM(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function ea(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function sh(t,e,n=40){const r=ea(t),i=ea(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 vte(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function _te(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 y9(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function NL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=eM(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Lg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:vte(n.id,i.id,r),globalTrayId:_te(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=eM(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Lg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function v9(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=NL(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()&&ea(m.color)===ea(l.color)),u=!c&&n.find(m=>!r.has(m.globalTrayId)&&m.type?.toUpperCase()===l.type?.toUpperCase()&&sh(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=eM(i.tray_color);e.push({type:i.tray_type,color:a,colorName:Lg(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:vte(n.id,i.id,r),globalTrayId:_te(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=eM(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:Lg(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function wte(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=ea(A.color)===ea(u.color)||sh(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()&&ea(M.color)===ea(u.color)),m=!f&&r.find(M=>!c.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&sh(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=ea(x.color)===ea(u.color)||sh(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()&&ea(y.color)===ea(u.color)),m=f?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&sh(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=NL(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()&&ea(b.color)===ea(c.color)),f=d?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()&&sh(b.color,c.color)),m=d||f?void 0:r.find(b=>!i.has(b.globalTrayId)&&b.type?.toUpperCase()===c.type?.toUpperCase()),p=d??f??m;p&&i.add(p.globalTrayId),a.push({slot_id:u,globalTrayId:p?.globalTrayId??-1})}const o=Math.max(...a.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return a.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const _9={useDefault:!0,manualMappings:{},autoConfigured:!1};function Z6e(t,e,n,r,i,a){const o=yue({queries:t.map(b=>({queryKey:["printer-status",b],queryFn:()=>fe.getPrinterStatus(b),enabled:t.length>0,staleTime:5e3}))}),l=w.useMemo(()=>t.map((b,y)=>{const x=o[y],v=x?.data,M=e?.find(R=>R.id===b)?.name||`Printer ${b}`,A=NL(v),T=i[b]||_9,k=v9(n,v),E=T.useDefault?r:T.manualMappings,D=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:D,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]||_9,...y}}))},d=b=>{const y=l.find(S=>S.printerId===b);if(!y||!y.status||!n?.filaments)return;const x=v9(n,y.status);if(!x)return;const v={};x.forEach((S,M)=>{S!==-1&&(v[M+1]=S)}),u(b,{useDefault:!1,manualMappings:v,autoConfigured:!0})},f=()=>{for(const b of t)d(b)},m=b=>l.find(x=>x.printerId===b)?.finalMapping,p=l.every(b=>b.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:f,autoConfigurePrinter:d,getFinalMapping:m,allPrintersReady:p}}function 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 fe.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{a(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let m,p=!1;if(f!==void 0)m=t.loadedFilaments.find(y=>y.globalTrayId===f),p=!0;else{const y=new Set(Object.values(t.config.manualMappings)),x=t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&ea(M.color)===ea(u.color)),v=x?void 0:t.loadedFilaments.find(M=>!y.has(M.globalTrayId)&&M.type?.toUpperCase()===u.type?.toUpperCase()&&sh(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=ea(m.color)===ea(u.color)||sh(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} - ${Lg(u.color)}`,children:s.jsx(mP,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),s.jsxs("span",{className:"text-white truncate",children:[u.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:d?.globalTrayId??"",onChange:b=>o(u.slot_id||0,b.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${m?"ring-1 ring-blue-400/50":""}`,title:m?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(b=>s.jsxs("option",{value:b.globalTrayId,className:"bg-bambu-dark text-white",children:[b.label,": ",b.type," (",b.colorName,")"]},b.globalTrayId))]}),f==="match"?s.jsx(ts,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(An,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(An,{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(aa,{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(Wr,{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(ts,{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(aa,{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(cl,{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(An,{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(cl,{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(ts,{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:()=>fe.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:m,hasTypeMismatch:p,hasColorMismatch:b}=wte(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 fe.refreshPrinterStatus(t),await new Promise(M=>setTimeout(M,500)),await a.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>u(!c),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(mP,{className:"w-4 h-4",fill:x,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),p?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):b?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?s.jsx(fu,{className:"w-4 h-4 ml-auto"}):s.jsx(Di,{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} - ${Lg(M.color)}`,children:s.jsx(mP,{className:"w-3 h-3",fill:M.color,stroke:M.color})}),s.jsxs("span",{className:"text-white truncate",children:[M.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",M.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:M.loaded?.globalTrayId??"",onChange: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(ts,{className:"w-3 h-3 text-bambu-green"}):M.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(An,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(An,{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(hN,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(fu,{className:"w-4 h-4 ml-auto"}):s.jsx(Di,{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(Xn,{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(gK,{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(Mu,{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 Op={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},a$e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function oh({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const l=on(),{showToast:c}=Gn(),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??Op.bed_levelling,flow_cali:i.flow_cali??Op.flow_cali,vibration_cali:i.vibration_cali??Op.vibration_cali,layer_inspect:i.layer_inspect??Op.layer_inspect,timelapse:i.timelapse??Op.timelapse}:Op),[x,v]=w.useState(()=>{if(t==="edit-queue-item"&&i){let $="asap";i.manual_start?$="manual":i.scheduled_time&&!y9(i.scheduled_time)&&($="scheduled");let L="";return i.scheduled_time&&!y9(i.scheduled_time)&&(L=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$,scheduledTime:L,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return 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((L,Y)=>{L!==-1&&($[Y+1]=L)}),$}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),[D,C]=w.useState(!1),[R,U]=w.useState({current:0,total:0}),[O,q]=w.useState(new Set),j=d.length,W=d.length>0?d[0]:null,{data:K}=ut({queryKey:["settings"],queryFn:fe.getSettings}),{data:G,isLoading:Q}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:te,isError:J}=ut({queryKey:["archive-plates",e],queryFn:()=>fe.getArchivePlates(e),enabled:!!e&&!u,retry:!1}),{data:z}=ut({queryKey:["library-file-plates",n],queryFn:()=>fe.getLibraryFilePlates(n),enabled:u&&!!n}),V=u?z:te,{data:ne,isError:ae}=ut({queryKey:["archive-filaments",e,m],queryFn:()=>fe.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!u&&(m!==null||!V?.is_multi_plate),retry:!1}),{data:he}=ut({queryKey:["library-file-filaments",n,m],queryFn:()=>fe.getLibraryFileFilamentRequirements(n,m??void 0),enabled:u&&!!n&&(m!==null||!V?.is_multi_plate)}),pe=!u&&(J||ae),ie=u?he:ne,{data:Ee}=ut({queryKey:["printer-status",W],queryFn:()=>fe.getPrinterStatus(W),enabled:!!W}),{amsMapping:xe}=wte(ie,Ee,S),Ne=Z6e(d,G,ie,S,A,T);w.useEffect(()=>{V?.plates?.length===1&&!m&&p(V.plates[0].index)},[V,m]),w.useEffect(()=>{if(t==="edit-queue-item")return;const $=G?.filter(L=>L.is_active)||[];$.length===1&&d.length===0&&f([$[0].id])},[t,G,d.length]),w.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(d.sort())!==JSON.stringify(k.sort())||m!==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(L=>{if(O.has(L))return!1;const Y=Ne.printerResults.find(be=>be.printerId===L);return Y&&Y.status&&!Y.isLoading});$.length>0&&(q(L=>{const Y=new Set(L);return $.forEach(be=>Y.add(be)),Y}),$.forEach(L=>{Ne.autoConfigurePrinter(L)}))},[K?.per_printer_mapping_expanded,d,O,Ne]),w.useEffect(()=>{const $=L=>{L.key==="Escape"&&!D&&a()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,D]);const _e=V?.is_multi_plate??!1,le=V?.plates??[],Ve=mt({mutationFn:$=>fe.addToQueue($)}),H=mt({mutationFn:$=>fe.updateQueueItem(i.id,$),onSuccess:()=>{l.invalidateQueries({queryKey:["queue"]}),c("Queue item updated"),o?.(),a()},onError:$=>{c($.message||"Failed to update queue item","error")}}),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 L={success:0,failed:0,errors:[]},Y=Se=>{if(d.length>1){const se=A[Se];if(se&&!se.useDefault)return Ne.getFinalMapping(Se)}return xe},be=Se=>({printer_id:Se,archive_id:u?void 0:e,library_file_id:u?n:void 0,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:Y(Se),plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():void 0,...b});for(let Se=0;Se<d.length;Se++){const se=d[Se];U({current:Se+1,total:d.length});try{if(t==="reprint"){const Pe=Y(se);u?await fe.printLibraryFile(n,se,{ams_mapping:Pe,...b}):await fe.reprintArchive(e,se,{plate_id:m??void 0,ams_mapping:Pe,...b})}else if(t==="edit-queue-item"&&Se===0){const Pe=Y(se),Re={printer_id:se,require_previous_success:x.requirePreviousSuccess,auto_off_after:x.autoOffAfter,manual_start:x.scheduleType==="manual",ams_mapping:Pe,plate_id:m,scheduled_time:x.scheduleType==="scheduled"&&x.scheduledTime?new Date(x.scheduledTime).toISOString():null,...b};await H.mutateAsync(Re)}else await Ve.mutateAsync(be(se));L.success++}catch(Pe){L.failed++;const Re=G?.find(Xe=>Xe.id===se)?.name||`Printer ${se}`;L.errors.push(`${Re}: ${Pe.message}`)}}if(C(!1),L.failed===0){const Se=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";L.success===1?c(t==="edit-queue-item"?"Queue item updated":`Print ${Se} printer`):c(`Print ${Se} ${L.success} printers`),l.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else L.success===0?c(`Failed: ${L.errors[0]}`,"error"):(c(`${L.success} succeeded, ${L.failed} failed`,"error"),l.invalidateQueries({queryKey:["queue"]}))},X=D||H.isPending,B=w.useMemo(()=>!(X||d.length===0||!u&&_e&&!m),[d.length,_e,m,X,u]),ue=(()=>{const $=d.length;return t==="reprint"?{title:u?"Print":"Re-print",icon:Wr,submitText:$>1?`Print to ${$} Printers`:"Print",submitIcon:Wr,loadingText:R.total>1?`Sending ${R.current}/${R.total}...`:"Sending..."}:t==="add-to-queue"?{title:"Schedule Print",icon:oi,submitText:$>1?`Queue to ${$} Printers`:"Add to Queue",submitIcon:oi,loadingText:R.total>1?`Adding ${R.current}/${R.total}...`:"Adding..."}:{title:"Edit Queue Item",icon:sa,submitText:"Save",submitIcon:sa,loadingText:R.total>1?`Saving ${R.current}/${R.total}...`:"Saving..."}})(),Ae=ue.icon,Ie=ue.submitIcon,ce=W&&(u||(_e?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:D?void 0:a,children:s.jsx(St,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$=>$.stopPropagation(),children:s.jsxs(Mt,{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(Ae,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:ue.title})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:a,disabled:D,children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit: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:_e,selectedPlate:m,onSelect:p}),s.jsx(J6e,{printers:G||[],selectedPrinterIds:d,onMultiSelect:f,isLoading:Q,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:Ne.printerResults,filamentReqs:ie,onAutoConfigurePrinter:Ne.autoConfigurePrinter,onUpdatePrinterConfig:Ne.updatePrinterConfig}),pe&&s.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[s.jsx(aa,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),ce&&!pe&&d.length===1&&s.jsx(t$e,{printerId:W,filamentReqs:ie,manualMappings:S,onManualMappingChange:M,defaultExpanded:K?.per_printer_mapping_expanded??!1}),(t==="reprint"||j>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(Me,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:D,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!B,className:"flex-1",children:X?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),ue.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Ie,{className:"w-4 h-4"}),ue.submitText]})})]})]})]})})})}function s$e({onClose:t,initialFiles:e}){const n=on(),{showToast:r}=Gn(),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=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[t]);const{data:p}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),b=mt({mutationFn:E=>fe.uploadArchivesBulk(E,u),onSuccess:E=>{m(E),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(D=>D.map(C=>{const R=E.results.find(O=>O.filename===C.file.name),U=E.errors.find(O=>O.filename===C.file.name);return R?{...C,status:"success",archiveId:R.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(D=>({...D,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 D=Array.from(E.dataTransfer.files).filter(C=>C.name.endsWith(".3mf"));D.length>0&&o(C=>[...C,...D.map(R=>({file:R,status:"pending"}))])},[]),S=w.useCallback(E=>{const D=Array.from(E.target.files||[]).filter(C=>C.name.endsWith(".3mf"));D.length>0&&o(C=>[...C,...D.map(R=>({file:R,status:"pending"}))]),i.current&&(i.current.value="")},[]),M=w.useCallback(E=>{o(D=>D.filter((C,R)=>R!==E))},[]),A=()=>{if(a.length===0)return;const E=a.filter(D=>D.status==="pending");E.length!==0&&(o(D=>D.map(C=>C.status==="pending"?{...C,status:"uploading"}:C)),b.mutate(E.map(D=>D.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(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:x,onDrop:v,children:[s.jsx(mi,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),s.jsx(Me,{variant:"secondary",onClick:()=>i.current?.click(),disabled:k,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:S})]})}),s.jsxs("div",{className:"px-4 pb-4",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange: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,D)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(rN,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children: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(D),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:k,children:s.jsx(Ht,{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(On,{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(aa,{className:"w-4 h-4 text-red-400"})]})]},`${E.file.name}-${D}`))})}),f&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Me,{onClick: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(mi,{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 Ste({archive:t,onClose:e,existingTags:n=[]}){w.useEffect(()=>{const ie=Ee=>{Ee.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||""),[D,C]=w.useState(!1),[R,U]=w.useState(!1),O=w.useRef(null),q=w.useRef(null),j=w.useRef(null),{data:W}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:K}=ut({queryKey:["projects"],queryFn:()=>fe.getProjects()}),{data:G}=ut({queryKey:["archives"],queryFn:()=>fe.getArchives(void 0,1e3,0),enabled:n.length===0}),Q=n.length>0?n:[...new Set(G?.flatMap(ie=>ie.tags?.split(",").map(Ee=>Ee.trim())||[]).filter(Boolean)||[])].sort(),te=m.split(",").map(ie=>ie.trim()).filter(Boolean),J=Q.filter(ie=>!te.includes(ie)),z=ie=>{if(!te.includes(ie)){const Ee=[...te,ie].join(", ");p(Ee)}j.current!==null&&clearTimeout(j.current),O.current?.focus()},V=ie=>{const Ee=te.filter(xe=>xe!==ie).join(", ");p(Ee)},ne=mt({mutationFn:ie=>fe.updateArchive(t.id,ie),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),ae=async ie=>{const Ee=ie.target.files?.[0];if(Ee){C(!0);try{const xe=await fe.uploadArchivePhoto(t.id,Ee);T(xe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(xe){console.error("Failed to upload photo:",xe)}finally{C(!1),q.current&&(q.current.value="")}}},he=async ie=>{try{const Ee=await fe.deleteArchivePhoto(t.id,ie);T(Ee.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(Ee){console.error("Failed to delete photo:",Ee)}},pe=ie=>{ie.preventDefault();const Ee={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&&(Ee.status=x),x==="failed"||x==="aborted"?Ee.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(Ee.failure_reason=null),ne.mutate(Ee)};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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:pe,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(Aa,{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(Yg,{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"}),te.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:te.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(xg,{className:"w-3 h-3"}),ie,s.jsx("button",{type:"button",onClick:()=>V(ie),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Ht,{className:"w-3 h-3"})})]},ie))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:O,type:"text",value:m,onChange:ie=>p(ie.target.value),onFocus:()=>{j.current!==null&&clearTimeout(j.current),U(!0)},onBlur:()=>{j.current=window.setTimeout(()=>U(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:te.length>0?"Add more tags...":"Add tags..."}),R&&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(zf,{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:fe.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:()=>he(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(un,{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:D}),D?s.jsx(dt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(er,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:ne.isPending,className:"flex-1",children:[s.jsx(ys,{className:"w-4 h-4"}),ne.isPending?"Saving...":"Save"]})]})]})]})})}function Mte({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,D=A;f(E<k&&D>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(D=>({...D,[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(Zs,{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}=Gn(),[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 fe.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 fe.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(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Me,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:y=>o(y.target.value),onKeyDown:b}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(er,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>s.jsx("button",{onClick:()=>m(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(y=>s.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,s.jsx("button",{onClick:()=>m(y),className:"hover:opacity-70",children:s.jsx(Ht,{className:"w-3 h-3"})})]},y))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Me,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(xg,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function u$e({selectedIds:t,onClose:e}){const n=on(),{showToast:r}=Gn(),{data:i,isLoading:a}=ut({queryKey:["projects"],queryFn:()=>fe.getProjects()});w.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=mt({mutationFn:async d=>(await fe.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(m=>m.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=mt({mutationFn:async()=>{for(const d of t)await fe.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{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(Aa,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),a?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(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(na,{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(Aa,{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(Me,{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=Mi(k.completed_at||k.created_at)||new Date,D=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,C=T.get(D)||[];C.push(k),T.set(D,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(Bf,{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(Zs,{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")}`,D=m.get(E)||[],C=D.length>0,R=T===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),U=E===c,O=D.filter(j=>j.status==="completed").length,q=D.filter(j=>j.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":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":C?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[s.jsx("span",{className:`text-sm font-medium ${R&&!U?"text-bambu-green":""}`,children: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&&O===0?"bg-red-400":q>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:D.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:fe.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,D)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},D))})]})]})]},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 Nte({archiveId:t,archiveName:e,onClose:n}){const r=fe.getArchiveQRCodeUrl(t,300);w.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 flex flex-col items-center",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),s.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:s.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),s.jsxs(Me,{onClick:i,className:"w-full",children:[s.jsx(Hr,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Ete({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=w.useState(0),[l,c]=w.useState(!1);if(w.useEffect(()=>{const p=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&o(y=>Math.max(0,y-1)),b.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),w.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=fe.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},m=()=>{i&&c(!0)};return s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Hr,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Me,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:s.jsx(un,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-6 h-6"})})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&s.jsx("button",{onClick:()=>o(p=>p-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Bf,{className:"w-8 h-8 text-white"})}),s.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&s.jsx("button",{onClick:()=>o(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Zs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,b)=>s.jsx("button",{onClick:()=>o(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:fe.getArchivePhotoUrl(t,p),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&s.jsx(zn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function ba(t){this.content=t}ba.prototype={constructor:ba,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 ba(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 ba(n)},addToStart:function(t,e){return new ba([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ba(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 ba(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=ba.from(t),t.size?new ba(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ba.from(t),t.size?new ba(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ba.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}};ba.from=function(t){if(t instanceof ba)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ba(e)};function Ate(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=Ate(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Tte(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=Tte(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class Nt{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 Nt(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 Nt(r,i)}cutByIndex(e,n){return e==n?Nt.empty:e==0&&n==this.content.length?this:new Nt(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 Nt(i,a)}addToStart(e){return new Nt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Nt(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 Ate(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Tte(this,e,n,r)}findIndex(e){if(e==0)return Ow(0,e);if(e==this.size)return Ow(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?Ow(n+1,a):Ow(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 Nt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Nt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Nt.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 Nt(n||e,r)}static from(e){if(!e)return Nt.empty;if(e instanceof Nt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Nt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Nt.empty=new Nt([],0);const mj={index:0,offset:0};function Ow(t,e){return mj.index=t,mj.offset=e,mj}function tM(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(!tM(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!tM(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let wr=class OR{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&&tM(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 OR.none;if(e instanceof OR)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};wr.none=[];class nM extends Error{}class $t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=kte(this.content,e+this.openStart,n);return r&&new $t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new $t(Cte(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return $t.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new $t(Nt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new $t(e,r,i)}}$t.empty=new $t(Nt.empty,0,0);function Cte(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(Cte(a.content,e-i-1,n-i-1)))}function kte(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=kte(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 nM("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new nM("Inconsistent open depths");return jte(t,e,n,0)}function jte(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=jte(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 Rf(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 Rf(a,Rte(t,o,l,e,r))}else return Rf(a,rM(t,e,r))}function Pte(t,e){if(!e.type.compatibleContent(t.type))throw new nM("Cannot join "+e.type.name+" onto "+t.type.name)}function LR(t,e,n){let r=t.node(n);return Pte(r,e.node(n)),r}function Pf(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function c0(t,e,n,r){let i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Pf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Pf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Pf(e.nodeBefore,r)}function Rf(t,e){return t.type.checkContent(e),t.copy(e)}function Rte(t,e,n,r,i){let a=t.depth>i&&LR(t,e,i+1),o=r.depth>i&&LR(n,r,i+1),l=[];return c0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(Pte(a,o),Pf(Rf(a,Rte(t,e,n,r,i+1)),l)):(a&&Pf(Rf(a,rM(t,e,i+1)),l),c0(e,n,i,l),o&&Pf(Rf(o,rM(n,r,i+1)),l)),c0(r,null,i,l),new Nt(l)}function rM(t,e,n){let r=[];if(c0(null,t,n,r),t.depth>n){let i=LR(t,e,n+1);Pf(Rf(i,rM(t,e,n+1)),r)}return c0(e,null,n,r),new Nt(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(Nt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class iy{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return wr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let a=r.marks;for(var o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!i||!a[o].isInSet(i.marks))&&(a=a[o--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new iM(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 iy(n,r,a)}static resolveCached(e,n){let r=w9.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else w9.set(e,r=new b$e);let i=r.elts[r.i]=iy.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,w9=new WeakMap;class iM{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 Wd=class IR{constructor(e,n,r,i=wr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||Nt.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&&tM(this.attrs,n||e.defaultAttrs||v$e)&&wr.sameSet(this.marks,r||wr.none)}copy(e=null){return e==this.content?this:new IR(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new IR(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return $t.empty;let i=this.resolve(e),a=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,a.pos-l);return new $t(u,i.depth-o,a.depth-o)}replace(e,n,r){return 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 iy.resolveCached(this,e)}resolveNoCache(e){return iy.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()+")"),Dte(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=Nt.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),o=a&&a.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=wr.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!wr.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=Nt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Wd.prototype.text=void 0;class aM extends Wd{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):Dte(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 aM(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new aM(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 Dte(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class am{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new _$e(e,n);if(r.next==null)return am.empty;let i=Ote(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 Nt.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(`
- `)}}am.empty=new am(!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 Ote(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 S9(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=S9(t),r=n;return t.eat(",")&&(t.next!="}"?r=S9(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function 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=Ote(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 Lte(t,e){return e-t}function M9(t,e){let n=[];return r(e),n.sort(Lte);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(M9(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<i.length;d++)i[d][0]==l&&(u=i[d][1]);M9(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new am(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Lte);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 Ite(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 Fte(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 Ute(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 zte(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 N9=class Bte{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=zte(e,r.attrs),this.defaultAttrs=Ite(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==am.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:Fte(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Wd(this,this.computeAttrs(e),Nt.from(n),wr.setFrom(r))}createChecked(e=null,n,r){return n=Nt.from(n),this.checkContent(n),new Wd(this,this.computeAttrs(e),n,wr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Nt.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(Nt.empty,!0);return a?new Wd(this,e,n.append(a),wr.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ute(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:wr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new Bte(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 yE{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=zte(e,i.attrs),this.excluded=null;let a=Ite(this.attrs);this.instance=a?new wr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new wr(this,Fte(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new yE(a,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Ute(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class $te{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=ba.from(e.nodes),n.marks=ba.from(e.marks||{}),this.nodes=N9.compile(this.spec.nodes,this),this.marks=yE.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=am.parse(o,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?E9(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:E9(this,o.split(" "))}this.nodeFromJSON=i=>Wd.fromJSON(this,i),this.markFromJSON=i=>wr.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof N9){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new aM(r,r.defaultAttrs,e,wr.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function E9(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],o=a;if(a)n.push(a);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function P$e(t){return t.tag!=null}function R$e(t){return t.style!=null}let u0=class FR{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 T9(this,n,!1);return r.addAll(e,wr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new T9(this,n,!0);return r.addAll(e,wr.none,n.from,n.to),$t.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(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=C9(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=C9(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new FR(e,FR.schemaRules(e)))}};const Hte={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},Vte={ol:!0,ul:!0},ay=1,UR=2,d0=4;function A9(t,e,n){return e!=null?(e?ay:0)|(e==="full"?UR:0):t&&t.whitespace=="pre"?ay|UR:n&~d0}class Lw{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=wr.none,this.match=a||(o&d0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Nt.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&ay)){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=Nt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Nt.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&&!Hte.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class T9{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=A9(null,n.preserveWhitespace,0)|(r?d0:0);i?a=new Lw(i.type,i.attrs,wr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new Lw(null,null,wr.none,!0,null,o):a=new Lw(e.schema.topNodeType,null,wr.none,!0,null,o),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&UR?"full":this.localPreserveWS||(i.options&ay)>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;Vte.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(Hte.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=wr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):k9(l.type,e.type))&&(o=l.addToSet(o));return a.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=A9(e,a,o.options);o.options&d0&&o.content.length==0&&(l|=d0);let c=wr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):k9(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new Lw(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|=ay)}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&&Vte.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 C9(t){let e={};for(let n in t)e[n]=t[n];return e}function k9(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class gm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=pj(n).createDocumentFragment());let i=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let l=0,c=0;for(;l<a.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=_1(pj(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&_1(pj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return _1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new gm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=j9(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return j9(e.marks)}}function j9(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function pj(t){return t.document||window.document}const P9=new WeakMap;function I$e(t){let e=P9.get(t);return e===void 0&&P9.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 _1(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}=_1(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 Gte=65535,Wte=Math.pow(2,16);function U$e(t,e){return t+e*Wte}function R9(t){return t&Gte}function z$e(t){return(t-(t&Gte))/Wte}const qte=1,Kte=2,w1=4,Xte=8;class zR{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Xte)>0}get deletedBefore(){return(this.delInfo&(qte|w1))>0}get deletedAfter(){return(this.delInfo&(Kte|w1))>0}get deletedAcross(){return(this.delInfo&w1)>0}}class Vs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Vs.empty)return Vs.empty}recover(e){let n=0,r=R9(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+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?Kte:e==f?qte:w1;return(n<0?e!=c:e!=f)&&(y|=Xte),new zR(p,y,b)}i+=d-u}return r?e+i:new zR(e+i,0,null)}touches(e,n){let r=0,i=R9(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+a],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?a:0),c=o+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=d-u}}invert(){return new Vs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Vs.empty:new Vs(e<0?[0,-e,0]:[0,0,e])}}Vs.empty=new Vs([]);class sy{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 sy(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 sy;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 zR(e,i,null)}}const gj=Object.create(null);class Va{getMap(){return Vs.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=gj[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in gj)throw new RangeError("Duplicate use of step JSON ID "+e);return gj[e]=n,n.prototype.jsonID=e,n}}class Ai{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ai(e,null)}static fail(e){return new Ai(null,e)}static fromReplace(e,n,r,i){try{return Ai.ok(e.replace(n,r,i))}catch(a){if(a instanceof nM)return Ai.fail(a.message);throw a}}}function EL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(EL(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return Nt.fromArray(r)}class Dd extends Va{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new $t(EL(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 Ai.fromReplace(e,this.from,this.to,a)}invert(){return new al(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 Dd(n.pos,r.pos,this.mark)}merge(e){return e instanceof Dd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dd(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 Dd(n.from,n.to,e.markFromJSON(n.mark))}}Va.jsonID("addMark",Dd);class al extends Va{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new $t(EL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ai.fromReplace(e,this.from,this.to,r)}invert(){return new Dd(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 al(n.pos,r.pos,this.mark)}merge(e){return e instanceof al&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new al(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 al(n.from,n.to,e.markFromJSON(n.mark))}}Va.jsonID("removeMark",al);class Od extends Va{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ai.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ai.fromReplace(e,this.pos,this.pos+1,new $t(Nt.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 Od(this.pos,n.marks[i]);return new Od(this.pos,this.mark)}}return new sm(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Od(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 Od(n.pos,e.markFromJSON(n.mark))}}Va.jsonID("addNodeMark",Od);class sm extends Va{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ai.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ai.fromReplace(e,this.pos,this.pos+1,new $t(Nt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Od(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new sm(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 sm(n.pos,e.markFromJSON(n.mark))}}Va.jsonID("removeNodeMark",sm);class Qi extends Va{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&BR(e,this.from,this.to)?Ai.fail("Structure replace would overwrite content"):Ai.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Vs([this.from,this.to-this.from,this.slice.size])}invert(e){return new Qi(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 Qi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Qi)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?$t.empty:new $t(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Qi(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?$t.empty:new $t(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Qi(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 Qi(n.from,n.to,$t.fromJSON(e,n.slice),!!n.structure)}}Va.jsonID("replace",Qi);class ra extends Va{constructor(e,n,r,i,a,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=o,this.structure=l}apply(e){if(this.structure&&(BR(e,this.from,this.gapFrom)||BR(e,this.gapTo,this.to)))return Ai.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ai.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ai.fromReplace(e,this.from,this.to,r):Ai.fail("Content does not fit in gap")}getMap(){return new Vs([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new ra(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new ra(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ra(n.from,n.to,n.gapFrom,n.gapTo,$t.fromJSON(e,n.slice),n.insert,!!n.structure)}}Va.jsonID("replaceAround",ra);function BR(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 al(m,p,f[y])));l&&l.to==m?l.to=p:a.push(l=new Dd(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 yE){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],m;for(let p=0;p<i.length;p++){let b=i[p];b.step==a-1&&f.eq(i[p].style)&&(m=b)}m?(m.to=u,m.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new al(o.from,o.to,o.style)))}function AL(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 Qi(l,d,$t.empty));else{r=f;for(let m=0;m<u.marks.length;m++)n.allowsMarkType(u.marks[m].type)||t.step(new al(l,d,u.marks[m]));if(i&&u.isText&&n.whitespace!="pre"){let m,p=/\r?\n|\r/g,b;for(;m=p.exec(u.text);)b||(b=new $t(Nt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Qi(l+m.index,l+m.index+m[0].length,b))}}l=d}if(!r.validEnd){let c=r.fillBefore(Nt.empty,!0);t.replace(l,l,new $t(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function H$e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function fx(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!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=Nt.empty,f=0;for(let b=a,y=!1;b>n;b--)y||r.index(b)>0?(y=!0,d=Nt.from(r.node(b).copy(d)),f++):c--;let m=Nt.empty,p=0;for(let b=a,y=!1;b>n;b--)y||i.after(b+1)<i.end(b)?(y=!0,m=Nt.from(i.node(b).copy(m)),p++):u++;t.step(new ra(c,u,o,l,new $t(d.append(m),f,p),d.size-f,!0))}function TL(t,e,n=null,r=t){let i=G$e(t,e),a=i&&W$e(r,e);return a?i.map(D9).concat({type:e,attrs:n}).concat(a.map(D9)):null}function D9(t){return{type:t,attrs:null}}function 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=Nt.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=Nt.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new ra(i,a,i,a,new $t(r,0,0),n.length,!0))}function 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&&Zte(t,o,l,a),AL(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),m=d.map(l+o.nodeSize,1);return t.step(new ra(f,m,f+1,m-1,new $t(Nt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&Yte(t,o,l,a),!1}})}function Yte(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 Zte(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 ra(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new $t(Nt.from(o),0,0),1,!0))}function uu(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=Nt.empty,o=Nt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=Nt.from(i.node(l).copy(a));let d=r&&r[u];o=Nt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Qi(e,e,new $t(a.append(o),n,n),!0))}function bh(t,e){let n=t.resolve(e),r=n.index();return Qte(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 Qte(t,e){return!!(t&&e&&!t.isLeaf&&Q$e(t,e))}function vE(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,o,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),o=r.node(i+1)),a&&!a.isTextblock&&Qte(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);Zte(t,d.node(),d.before(),l)}o.inlineContent&&AL(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 Qi(u,c.map(e+n,-1),$t.empty,!0)),r===!0){let d=t.doc.resolve(u);Yte(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 Jte(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function _E(t,e,n=e,r=$t.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return ene(i,a,r)?new Qi(e,n,r):new tHe(i,a,r).fit()}function ene(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=Nt.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=Nt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,l=i.depth;for(;o&&l&&a.childCount==1;)a=a.firstChild.content,o--,l--;let c=new $t(a,o,l);return e>-1?new ra(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Qi(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=xj(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(Nt.from(o),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=xj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new $t(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=xj(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new $t(qb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new $t(qb(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let y=0;y<a.length;y++)this.openFrontierNode(a[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:m}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),x=f.matchType(y.type);if(!x)break;u++,(u>1||c==0||y.content.size)&&(f=x,d.push(tne(y.mark(m.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?p:-1)))}let b=u==l.childCount;b||(p=-1),this.placed=Kb(this.placed,n,Nt.from(d)),this.frontier[n].match=f,b&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,x=l;y<p;y++){let v=x.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),x=v.content}this.unplaced=b?e==0?$t.empty:new $t(qb(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new $t(qb(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!bj(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=bj(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=bj(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Kb(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Kb(this.placed,this.depth,Nt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Nt.empty,!0);n.childCount&&(this.placed=Kb(this.placed,this.frontier.length,n))}}function qb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(qb(t.firstChild.content,e-1,n)))}function Kb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Kb(t.lastChild.content,e-1,n)))}function xj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function tne(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,tne(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(Nt.empty,!0)))),t.copy(r)}function bj(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,o);return l&&!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(ene(i,a,r))return t.step(new Qi(e,n,r));let o=rne(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 $t(nne(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 nne(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(nne(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(Nt.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 $t(Nt.from(r),0,0))}function sHe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=rne(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 rne(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 hg extends Va{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ai.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 Ai.fromReplace(e,this.pos,this.pos+1,new $t(Nt.from(i),0,n.isLeaf?0:1))}getMap(){return Vs.empty}invert(e){return new hg(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 hg(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 hg(n.pos,n.attr,n.value)}}Va.jsonID("attr",hg);class oy extends Va{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Ai.ok(r)}getMap(){return Vs.empty}invert(e){return new oy(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 oy(n.attr,n.value)}}Va.jsonID("docAttr",oy);let Ig=class extends Error{};Ig=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Ig.prototype=Object.create(Error.prototype);Ig.prototype.constructor=Ig;Ig.prototype.name="TransformError";class ine{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new sy}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Ig(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((a,o,l,c)=>{e=Math.min(e,l),n=Math.max(n,c)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=$t.empty){let i=_E(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new $t(Nt.from(r),0,0))}delete(e,n){return this.replace(e,n,$t.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return 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 hg(e,n,r)),this}setDocAttribute(e,n){return this.step(new oy(e,n)),this}addNodeMark(e,n){return this.step(new Od(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof wr)n.isInSet(r.marks)&&this.step(new sm(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new sm(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 AL(this,e,n,r),this}}const yj=Object.create(null);class Nn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new 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=$t.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?$t.empty:n),l==0&&I9(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),I9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new hn(e):Vp(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?Vp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Vp(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ys(e.node(0))}static atStart(e){return Vp(e,e,0,0,1)||new Ys(e)}static atEnd(e){return Vp(e,e,e.content.size,e.childCount,-1)||new Ys(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=yj[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in yj)throw new RangeError("Duplicate use of selection JSON ID "+e);return yj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return hn.between(this.$anchor,this.$head).getBookmark()}}Nn.prototype.visible=!0;class oHe{constructor(e,n){this.$from=e,this.$to=n}}let O9=!1;function L9(t){!O9&&!t.parent.inlineContent&&(O9=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class hn extends Nn{constructor(e,n=e){L9(e),L9(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Nn.near(r);let i=e.resolve(n.map(this.anchor));return new hn(i.parent.inlineContent?i:r,r)}replace(e,n=$t.empty){if(super.replace(e,n),n==$t.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof hn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new wE(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new hn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=Nn.findFrom(n,r,!0)||Nn.findFrom(n,-r,!0);if(a)n=a.$head;else return Nn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Nn.findFrom(e,-r,!0)||Nn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new hn(e,n)}}Nn.jsonID("text",hn);class wE{constructor(e,n){this.anchor=e,this.head=n}map(e){return new wE(e.map(this.anchor),e.map(this.head))}resolve(e){return hn.between(e.resolve(this.anchor),e.resolve(this.head))}}class rn extends Nn{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?Nn.near(a):new rn(a)}content(){return new $t(Nt.from(this.node),0,0)}eq(e){return e instanceof rn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new CL(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new rn(e.resolve(n.anchor))}static create(e,n){return new rn(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}rn.prototype.visible=!1;Nn.jsonID("node",rn);class CL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new wE(r,r):new CL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&rn.isSelectable(r)?new rn(n):Nn.near(n)}}class Ys extends Nn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=$t.empty){if(n==$t.empty){e.delete(0,e.doc.content.size);let r=Nn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ys(e)}map(e){return new Ys(e)}eq(e){return e instanceof Ys}getBookmark(){return lHe}}Nn.jsonID("all",Ys);const lHe={map(){return this},resolve(t){return new Ys(t)}};function Vp(t,e,n,r,i,a=!1){if(e.inlineContent)return hn.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&&rn.isSelectable(l))return rn.create(t,n-(i<0?l.nodeSize:0))}else{let c=Vp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function I9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Qi||i instanceof ra))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(Nn.near(t.doc.resolve(o),n))}const F9=1,Iw=2,U9=4;class cHe extends ine{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|F9)&~Iw,this.storedMarks=null,this}get selectionSet(){return(this.updated&F9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Iw,this}ensureMarks(e){return wr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Iw)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Iw,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||wr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Nn.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=U9,this}get scrolledIntoView(){return(this.updated&U9)>0}}function z9(t,e){return!e||!t?t:t.bind(e)}class Xb{constructor(e,n,r){this.name=e,this.init=z9(n.init,r),this.apply=z9(n.apply,r)}}const uHe=[new Xb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Xb("selection",{init(t,e){return t.selection||Nn.atStart(e.doc)},apply(t){return t.selection}}),new Xb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Xb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class vj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=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 Xb(r.key,r.spec.state,r))})}}class Jp{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 Jp(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 vj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Jp(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new vj(this.schema,e.plugins),r=n.fields,i=new Jp(n);for(let a=0;a<r.length;a++){let o=r[a].name;i[o]=this.hasOwnProperty(o)?this[o]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new vj(e.schema,e.plugins),a=new Jp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=Wd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=Nn.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function ane(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ane(i,e,{})),n[r]=i}return n}class Yr{constructor(e){this.spec=e,this.props={},e.props&&ane(e.props,this,this.props),this.key=e.key?e.key.key:sne("plugin")}getState(e){return e[this.key]}}const _j=Object.create(null);function sne(t){return t in _j?t+"$"+ ++_j[t]:(_j[t]=0,t+"$")}class Hi{constructor(e="key"){this.key=sne(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const kL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function one(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const lne=(t,e,n)=>{let r=one(t,n);if(!r)return!1;let i=jL(r);if(!i){let o=r.blockRange(),l=o&&fx(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(xne(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Fg(a,"end")||rn.isSelectable(a)))for(let o=r.depth;;o--){let l=_E(t.doc,r.before(o),r.after(o),$t.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Fg(a,"end")?Nn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):rn.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=one(t,n);if(!r)return!1;let i=jL(r);return i?cne(t,i,e):!1},hHe=(t,e,n)=>{let r=dne(t,n);if(!r)return!1;let i=PL(r);return i?cne(t,i,e):!1};function cne(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=_E(t.doc,a,c,$t.empty);if(!u||u.from!=a||u instanceof Qi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(hn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function Fg(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const une=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=jL(r)}let o=a&&a.nodeBefore;return!o||!rn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(rn.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function jL(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 dne(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const hne=(t,e,n)=>{let r=dne(t,n);if(!r)return!1;let i=PL(r);if(!i)return!1;let a=i.nodeAfter;if(xne(t,i,e,1))return!0;if(r.parent.content.size==0&&(Fg(a,"start")||rn.isSelectable(a))){let o=_E(t.doc,r.before(),r.after(),$t.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Fg(a,"start")?Nn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):rn.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},fne=(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=PL(r)}let o=a&&a.nodeAfter;return!o||!rn.isSelectable(o)?!1:(e&&e(t.tr.setSelection(rn.create(t.doc,a.pos)).scrollIntoView()),!0)};function PL(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 rn,i;if(r){if(n.node.isTextblock||!bh(t.doc,n.from))return!1;i=n.from}else if(i=vE(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(rn.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 rn){if(n.node.isTextblock||!bh(t.doc,n.to))return!1;r=n.to}else if(r=vE(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},pHe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&fx(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},mne=(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 RL(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=RL(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(Nn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},pne=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ys||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=RL(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(hn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},gne=(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(uu(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&fx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function xHe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof rn&&e.selection.node.isBlock)return!r.parentOffset||!uu(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=RL(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 hn||e.selection instanceof Ys)&&d.deleteSelection();let f=d.mapping.map(r.pos),m=uu(d.doc,f,a.length,a);if(m||(a[0]=l?{type:l}:null,m=uu(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(rn.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||bh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function xne(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=Nt.empty;for(let v=o.length-1;v>=0;v--)b=Nt.from(o[v].create(null,b));b=Nt.from(i.copy(b));let y=t.tr.step(new ra(e.pos-1,p,e.pos,p,new $t(b,1,0),o.length,!0)),x=y.doc.resolve(p+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&bh(y.doc,x.pos)&&y.join(x.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:Nn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),m=f&&fx(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(u&&Fg(a,"start",!0)&&Fg(i,"end")){let p=i,b=[];for(;b.push(p),!p.isTextblock;)p=p.lastChild;let y=a,x=1;for(;!y.isTextblock;y=y.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,y.content)){if(n){let v=Nt.empty;for(let M=b.length-1;M>=0;M--)v=Nt.from(b[M].copy(v));let S=t.tr.step(new ra(e.pos-b.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new $t(v,b.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function bne(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(hn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const _He=bne(-1),wHe=bne(1);function SHe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&TL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function B9(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function DL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}DL(kL,lne,une);DL(kL,hne,fne);DL(mne,pne,gne,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 iM(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new iM(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=TL(a,n,r,e);return l?(t&&EHe(t,e,l,i,n),!0):!1}function EHe(t,e,n,r,i){let a=Nt.empty;for(let d=n.length-1;d>=0;d--)a=Nt.from(n[d].type.create(n[d].attrs,a));t.step(new ra(e.start-(r?2:0),e.end,e.start,e.end,new $t(a,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,m=!0;d<f;d++,m=!1)!m&&uu(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 ra(a-1,o,a,o,new $t(Nt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new iM(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=fx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return bh(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?Nt.empty:Nt.from(i))))return!1;let f=a.pos,m=f+o.nodeSize;return r.step(new ra(f-(l?1:0),m+(c?1:0),f+1,m-1,new $t((l?Nt.empty:Nt.from(i.copy(Nt.empty))).append(c?Nt.empty:Nt.from(i.copy(Nt.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=Nt.from(u?t.create():null),f=new $t(Nt.from(t.create(null,Nt.from(l.type.create(null,d)))),u?3:1,0),m=a.start,p=a.end;n(e.tr.step(new ra(m-(u?3:1),p,m,p,f,1,!0)).scrollIntoView())}return!0}}const Sa=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ug=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let $R=null;const Wc=function(t,e,n){let r=$R||($R=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},jHe=function(){$R=null},om=function(t,e,n,r){return n&&($9(t,e,n,r,-1)||$9(t,e,n,r,1))},PHe=/^(img|br|input|textarea|hr)$/i;function $9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ao(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Zy(t)||PHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Sa(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Ao(t):0}else return!1}}function Ao(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function 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=Ao(t)}else if(t.parentNode&&!Zy(t))e=Sa(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&&!Zy(t))e=Sa(t)+1,t=t.parentNode;else return null}}function OHe(t,e,n){for(let r=e==0,i=e==Ao(t);r||i;){if(t==n)return!0;let a=Sa(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Ao(t)}}function Zy(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const SE=function(t){return t.focusNode&&om(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function lf(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(Ao(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Ao(r.startContainer),r.startOffset)}}}const ac=typeof navigator<"u"?navigator:null,H9=typeof document<"u"?document:null,yh=ac&&ac.userAgent||"",HR=/Edge\/(\d+)/.exec(yh),yne=/MSIE \d/.exec(yh),VR=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yh),Ns=!!(yne||VR||HR),qd=yne?document.documentMode:VR?+VR[1]:HR?+HR[1]:0,jo=!Ns&&/gecko\/(\d+)/i.test(yh);jo&&+(/Firefox\/(\d+)/.exec(yh)||[0,0])[1];const GR=!Ns&&/Chrome\/(\d+)/.exec(yh),ta=!!GR,vne=GR?+GR[1]:0,Ca=!Ns&&!!ac&&/Apple Computer/.test(ac.vendor),zg=Ca&&(/Mobile\/\w+/.test(yh)||!!ac&&ac.maxTouchPoints>2),_o=zg||(ac?/Mac/.test(ac.platform):!1),_ne=ac?/Win/.test(ac.platform):!1,nu=/Android \d/.test(yh),Qy=!!H9&&"webkitFontSmoothing"in H9.documentElement.style,FHe=Qy?+(/\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 zc(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 V9(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Ug(o);continue}let l=o,c=l==a.body,u=c?UHe(a):zHe(l),d=0,f=0;if(e.top<u.top+zc(r,"top")?f=-(u.top-e.top+zc(i,"top")):e.bottom>u.bottom-zc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+zc(i,"top")-u.top:e.bottom-u.bottom+zc(i,"bottom")),e.left<u.left+zc(r,"left")?d=-(u.left-e.left+zc(i,"left")):e.right>u.right-zc(r,"right")&&(d=e.right-u.right+zc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,b=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let y=l.scrollLeft-p,x=l.scrollTop-b;e={left:e.left-y,top:e.top-x,right:e.right-y,bottom:e.bottom-x}}let m=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(m))break;o=m=="absolute"?o.offsetParent:Ug(o)}}function 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:wne(t.dom)}}function wne(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ug(r));return e}function $He({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Sne(n,r==0?0:r-e)}function Sne(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 Lp=null;function HHe(t){if(t.setActive)return t.setActive();if(Lp)return t.focus(Lp);let e=wne(t);t.focus(Lp==null?{get preventScroll(){return Lp={preventScroll:!0},!0}}:void 0),Lp||(Lp=!1,Sne(e,0))}function Mne(t,e){let n,r=2e8,i,a=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let m;if(d.nodeType==1)m=d.getClientRects();else if(d.nodeType==3)m=Wc(d).getClientRects();else continue;for(let p=0;p<m.length;p++){let b=m[p];if(b.top<=o&&b.bottom>=l){o=Math.max(b.bottom,o),l=Math.min(b.top,l);let y=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&y&&(a=f+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!c&&b.left<=e.left&&b.right>=e.left&&(c=d,u={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?VHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:Mne(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=gd(r,1);if(o.top!=o.bottom&&OL(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 OL(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}=Mne(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 Nne(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(OL(e,u))return Nne(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(!OL(e,u)||(o=Nne(t.dom,e,u),!o))return null}if(Ca)for(let u=o;r&&u;u=Ug(u))u.draggable&&(r=void 0);if(o=GHe(o,e),r){if(jo&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;Qy&&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 G9(t){return t.top<t.bottom||t.left<t.right}function gd(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(G9(r))return r}return Array.prototype.find.call(n,G9)||t.getBoundingClientRect()}const XHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ene(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=Qy||jo;if(r.nodeType==3)if(o&&(XHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=gd(Wc(r,i,i),n);if(jo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=gd(Wc(r,i-1,i-1),-1);if(u.top==c.top){let d=gd(Wc(r,i,i+1),-1);if(d.top!=c.top)return Pb(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,Pb(gd(Wc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Ao(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return wj(c.getBoundingClientRect(),!1)}if(a==null&&i<Ao(r)){let c=r.childNodes[i];if(c.nodeType==1)return wj(c.getBoundingClientRect(),!0)}return wj(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Ao(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Wc(c,Ao(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Pb(gd(u,1),!1)}if(a==null&&i<Ao(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Wc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Pb(gd(u,-1),!0)}return Pb(gd(r.nodeType==3?Wc(r):r,-n),n>=0)}function Pb(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function wj(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Ane(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 Ane(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=Ene(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Wc(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const 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:Ane(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),m=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:y}=t.domSelectionRange(),x=b&&!p.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==y;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return m!=null&&(l.caretBidiLevel=m),x}):r.pos==r.start()||r.pos==r.end()}let W9=null,q9=null,K9=!1;function JHe(t,e,n){return W9==e&&q9==n?K9:(W9=e,q9=n,K9=n=="up"||n=="down"?YHe(t,e,n):QHe(t,e,n))}const Po=0,X9=1,yf=2,sc=3;class Jy{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Po,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Sa(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 Cne){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 Tne&&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?Sa(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?Sa(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=Sa(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=Sa(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let p=0,b=0;p<this.children.length;p++){let y=this.children[p],x=b+y.size;if(a>b&&o<x)return y.setSelection(e-b-y.border,n-b-y.border,r,i);b=x}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((jo||Ca)&&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:Sa(x)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=p.childNodes[b-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(jo&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ca)&&om(l.node,l.offset,d.anchorNode,d.anchorOffset)&&om(c.node,c.offset,d.focusNode,d.focusOffset))return;let m=!1;if((u.extend||e==n)&&!(f&&jo)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let b=l;l=c,c=b}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?yf:X9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=sc:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?yf:sc}r=o}this.dirty=yf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?yf:X9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Tne extends Jy{constructor(e,n,r,i){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==Po&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class eVe extends Jy{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 lm extends Jy{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=gm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new lm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&sc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=sc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Po){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Po}}slice(e,n,r){let i=lm.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=qR(a,n,o,r)),e>0&&(a=qR(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 Kd extends Jy{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}=gm.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=Pne(d,r,n),u?c=new tVe(e,n,r,i,d,f||null,m,u,a,o+1):n.isText?new ME(e,n,r,i,d,m,a):new Kd(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=()=>Nt.empty)}return e}matchesNode(e,n,r){return this.dirty==Po&&e.eq(this.node)&&sM(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?wr.none:this.node.child(d).marks,r,e,d),c.placeWidget(u,e,i)},(u,d,f,m)=>{c.syncToMarks(u.marks,r,e,m);let p;c.findNodeMatch(u,d,f,m)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,m,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==yf)&&(o&&this.protectLocalComposition(e,o),kne(this.contentDOM,this.children,e),zg&&oVe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof hn)||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=qR(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==sc||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Po}updateOuterDeco(e){if(sM(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=jne(this.dom,this.nodeDOM,WR(this.outerDeco,this.node,n),WR(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Y9(t,e,n,r,i){Pne(r,e,t);let a=new Kd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class ME extends Kd{constructor(e,n,r,i,a,o,l){super(e,n,r,i,a,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==sc||this.dirty!=Po&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Po||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Po,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new ME(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=sc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Cne extends Jy{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Po&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class tVe extends Kd{constructor(e,n,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==sc)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function kne(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=Z9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof lm){let c=r?r.previousSibling:t.lastChild;kne(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Z9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const h0=function(t){t&&(this.nodeName=t)};h0.prototype=Object.create(null);const vf=[new h0];function WR(t,e,n){if(t.length==0)return vf;let r=n?vf[0]:new h0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new h0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new h0(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function jne(t,e,n,r){if(n==vf&&r==vf)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=vf[0]),i=c}nVe(i,l||vf[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 Pne(t,e,n){return jne(t,t,vf,WR(e,n,t.nodeType!=1))}function sM(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 Z9(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=Po,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let c=-1,u=this.top.children.length;i<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let d=this.index;d<u;d++){let f=this.top.children[d];if(f.matchesMark(e[o])&&!this.isLocked(f.dom)){c=d;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=lm.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let o=this.top.children[i];return o.dirty==sc&&o.dom==o.contentDOM&&(o.dirty=yf),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 Kd){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,m=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=sc&&sM(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=yf,f.updateChildren(i,o+1),f.dirty=Po),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!sM(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Kd.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=Kd.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 Tne(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 lm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ME)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ca||ta)&&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 Cne(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 lm)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 qR(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 LL(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(SE(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&rn.isSelectable(f)&&i.parent&&!(f.isInline&&OHe(n.focusNode,n.focusOffset,i.dom))){let m=i.posBefore;u=new rn(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=IL(t,d,l,f)}return u}function Rne(t){return t.editable?t.hasFocus():One(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function du(t,e=!1){let n=t.state.selection;if(Dne(t,n),!!Rne(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ta){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&om(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;Q9&&!(n instanceof hn)&&(n.$from.parent.inlineContent||(a=J9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=J9(t,n.to))),t.docView.setSelection(r,i,t,e),Q9&&(a&&eW(a),o&&eW(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 Q9=Ca||ta&&vne<63;function J9(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(Ca&&i&&i.contentEditable=="false")return Sj(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return Sj(i);if(a)return Sj(a)}}function Sj(t){return t.contentEditable="true",Ca&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function eW(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(()=>{(!Rne(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,Sa(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ns&&qd<=11&&(n.disabled=!0,n.disabled=!1)}function Dne(t,e){if(e instanceof rn){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(tW(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else tW(t)}function tW(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function IL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||hn.between(e,n,r)}function nW(t){return t.editable&&!t.hasFocus()?!1:One(t)}function One(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 om(e.node,e.offset,n.anchorNode,n.anchorOffset)}function KR(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&Nn.findFrom(a,e)}function _d(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function rW(t,e,n){let r=t.state.selection;if(r instanceof hn)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 _d(t,new hn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=KR(t.state,e);return i&&i instanceof rn?_d(t,i):!1}else if(!(_o&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?rn.isSelectable(a)?_d(t,new rn(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Qy?_d(t,new hn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof rn&&r.node.isInline)return _d(t,new hn(e>0?r.$to:r.$from));{let i=KR(t.state,e);return i?_d(t,i):!1}}}function oM(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function f0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ip(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(jo&&n.nodeType==1&&r<oM(n)&&f0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(f0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Lne(n))break;{let l=n.previousSibling;for(;l&&f0(l,-1);)i=n.parentNode,a=Sa(l),l=l.previousSibling;if(l)n=l,r=oM(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?XR(t,n,r):i&&XR(t,i,a)}function fVe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=oM(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(f0(l,1))a=n,o=++r;else break}else{if(Lne(n))break;{let l=n.nextSibling;for(;l&&f0(l,1);)a=l.parentNode,o=Sa(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=oM(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&XR(t,a,o)}function Lne(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function mVe(t,e){for(;t&&e==t.childNodes.length&&!Zy(t);)e=Sa(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&&!Zy(t);)e=Sa(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 XR(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(SE(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&du(t)},50)}function iW(t,e){let n=t.state.doc.resolve(e);if(!(ta||_ne)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function aW(t,e,n){let r=t.state.selection;if(r instanceof hn&&!r.empty||n.indexOf("s")>-1||_o&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=KR(t.state,e);if(o&&o instanceof rn)return _d(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Ys?Nn.near(o,e):Nn.findFrom(o,e);return l?_d(t,l):!1}return!1}function sW(t,e){if(!(t.state.selection instanceof hn))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function oW(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function gVe(t){if(!Ca||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;oW(t,r,"true"),setTimeout(()=>oW(t,r,"false"),20)}return!1}function 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||_o&&n==72&&r=="c")return sW(t,-1)||Ip(t,-1);if(n==46&&!e.shiftKey||_o&&n==68&&r=="c")return sW(t,1)||Ip(t,1);if(n==13||n==27)return!0;if(n==37||_o&&n==66&&r=="c"){let i=n==37?iW(t,t.state.selection.from)=="ltr"?-1:1:-1;return rW(t,i,r)||Ip(t,i)}else if(n==39||_o&&n==70&&r=="c"){let i=n==39?iW(t,t.state.selection.from)=="ltr"?1:-1:1;return rW(t,i,r)||Ip(t,i)}else{if(n==38||_o&&n==80&&r=="c")return aW(t,-1,r)||Ip(t,-1);if(n==40||_o&&n==78&&r=="c")return gVe(t)||aW(t,1,r)||Ip(t,1);if(r==(_o?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function FL(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")||gm.fromSchema(t.state.schema),l=$ne(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=Bne[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 Ine(t,e,n,r,i){let a=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",m=>{e=m(e,a||r,t)}),a)return l=new $t(Nt.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=gm.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),Qy&&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")||u0.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(lW(l,+d[1],+d[2]),d[4]);else if(l=$t.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=lW(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&&Une(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=zne(o[o.length-1],a.length));let d=Fne(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return Nt.from(o)}return t}function Fne(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Nt.from(t));return t}function Une(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Une(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(Nt.from(Fne(n,t,i+1))))}}function zne(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,zne(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Nt.empty,!0);return t.copy(n.append(r))}function YR(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=YR(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(Nt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function lW(t,e,n){return e<t.openStart&&(t=new $t(YR(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new $t(YR(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Bne={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let cW=null;function $ne(){return cW||(cW=document.implementation.createHTMLDocument("title"))}let Mj=null;function _Ve(t){let e=window.trustedTypes;return e?(Mj||(Mj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Mj.createHTML(t)):t}function wVe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=$ne().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Bne[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(ta?"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=Nt.from(c.create(r[l+1],i)),a++,o++}return new $t(i,a,o)}const is={},as={},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 is){let n=is[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{CVe(t,r)&&!UL(t,r)&&(t.editable||!(r.type in as))&&n(t,r)},NVe[e]?{passive:!0}:void 0)}Ca&&t.dom.addEventListener("input",()=>null),ZR(t)}function Ld(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 ZR(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>UL(t,r))})}function UL(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){!UL(t,e)&&is[e.type]&&(t.editable||!(e.type in as))&&is[e.type](t,e)}as.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Vne(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(nu&&ta&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),zg&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,lf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||bVe(t,n)?n.preventDefault():Ld(t,"key")};as.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};as.keypress=(t,e)=>{let n=e;if(Vne(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||_o&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof hn)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function NE(t){return{left:t.clientX,top:t.clientY}}function jVe(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function zL(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 fg(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&&rn.isSelectable(r)?(fg(t,new rn(n)),!0):!1}function RVe(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof rn&&(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(rn.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?(fg(t,rn.create(t.state.doc,i)),!0):!1}function DVe(t,e,n,r,i){return zL(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 zL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function LVe(t,e,n,r){return zL(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?(fg(t,hn.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)fg(t,hn.create(r,l+1,l+1+o.content.size));else if(rn.isSelectable(o))fg(t,rn.create(r,l));else continue;return!0}}function BL(t){return lM(t)}const Hne=_o?"metaKey":"ctrlKey";is.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=BL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&jVe(n,t.input.lastClick)&&!n[Hne]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(NE(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new FVe(t,o,n,!!r)):(a=="doubleClick"?OVe:LVe)(t,o.pos,o.inside,n)?n.preventDefault():Ld(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[Hne],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 rn&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&jo&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ld(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(()=>du(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(NE(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ld(this.view,"pointer"):DVe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ca&&this.mightDrag&&!this.mightDrag.node.isAtom||ta&&!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)?(fg(this.view,Nn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ld(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ld(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}is.touchstart=t=>{t.input.lastTouch=Date.now(),BL(t),Ld(t,"pointer")};is.touchmove=t=>{t.input.lastTouch=Date.now(),Ld(t,"pointer")};is.contextmenu=t=>BL(t);function Vne(t,e){return t.composing?!0:Ca&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const UVe=nu?5e3:-1;as.compositionstart=as.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof hn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ta&&_ne&&zVe(t)))t.markCursor=t.state.storedMarks||n.marks(),lM(t,!0),t.markCursor=null;else if(lM(t,!e.selection.empty),jo&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}Gne(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"}as.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Gne(t,20))};function Gne(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>lM(t),e))}function Wne(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 lM(t,e=!1){if(!(nu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Wne(t),e||t.docView&&t.docView.dirty){let n=LL(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 ly=Ns&&qd<15||zg&&FHe<604;is.copy=as.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ly?null:n.clipboardData,o=r.content(),{dom:l,text:c}=FL(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?cy(t,r.value,null,i,e):cy(t,r.textContent,r.innerHTML,i,e)},50)}function cy(t,e,n,r,i){let a=Ine(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||$t.empty)))return!0;if(!a)return!1;let o=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 qne(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}as.paste=(t,e)=>{let n=e;if(t.composing&&!nu)return;let r=ly?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&cy(t,qne(r),r.getData("text/html"),i,n)?n.preventDefault():GVe(t,n)};class Kne{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const WVe=_o?"altKey":"ctrlKey";function Xne(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[WVe]}is.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(NE(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof rn?i.to-1:i.to))){if(r&&r.mightDrag)o=rn.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=rn.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=FL(t,l);(!n.dataTransfer.files.length||!ta||vne>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ly?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",ly||n.dataTransfer.setData("text/plain",u),t.dragging=new Kne(d,Xne(t,n),o)};is.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};as.dragover=as.dragenter=(t,e)=>e.preventDefault();as.drop=(t,e)=>{try{qVe(t,e,t.dragging)}finally{t.dragging=null}};function qVe(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(NE(e));if(!r)return;let i=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",p=>{a=p(a,t,!1)}):a=Ine(t,qne(e.dataTransfer),ly?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&Xne(t,e));if(t.someProp("handleDrop",p=>p(t,e,a||$t.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let l=a?Jte(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&&rn.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new rn(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(IL(t,m,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}is.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&du(t)},20))};is.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};is.beforeinput=(t,e)=>{if(ta&&nu&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,lf(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in as)is[t]=as[t];function uy(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 cM{constructor(e,n){this.toDOM=e,this.spec=n||Df,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Qa(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof cM&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&uy(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Xd{constructor(e,n){this.attrs=e,this.spec=n||Df}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new Qa(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Xd&&uy(this.attrs,e.attrs)&&uy(this.spec,e.spec)}static is(e){return e.type instanceof Xd}destroy(){}}class $L{constructor(e,n){this.attrs=e,this.spec=n||Df}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=a.pos?null:new Qa(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof $L&&uy(this.attrs,e.attrs)&&uy(this.spec,e.spec)}destroy(){}}class Qa{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Qa(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Qa(e,e,new cM(n,r))}static inline(e,n,r,i){return new Qa(e,n,new Xd(r,i))}static node(e,n,r,i){return new Qa(e,n,new $L(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Xd}get widget(){return this.type instanceof cM}}const Gp=[],Df={};class Gr{constructor(e,n){this.local=e.length?e:Gp,this.children=n.length?n:Gp}static create(e,n){return n.length?uM(n,e,0,Df):Ia}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==Ia||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Df)}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 Gr(o.sort(Of),Gp):Ia}add(e,n){return n.length?this==Ia?Gr.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=Zne(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,uM(d,l,u+1,Df)),a+=3}});let o=Yne(a?Qne(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Gr(o.length?this.local.concat(o).sort(Of):this.local,i||this.children)}remove(e){return e.length==0||this==Ia?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!=Ia?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 Gr(i,r):Ia}forChild(e,n){if(this==Ia)return this;if(n.isLeaf)return Gr.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 Xd){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 Gr(i.sort(Of),Gp);return r?new Ad([l,r]):l}return r||Ia}eq(e){if(this==e)return!0;if(!(e instanceof Gr)||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 HL(this.localsInner(e))}localsInner(e){if(this==Ia)return Gp;if(e.inlineContent||!this.local.some(Xd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Xd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Gr.empty=new Gr([],[]);Gr.removeOverlap=HL;const Ia=Gr.empty;class Ad{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Df));return Ad.from(r)}forChild(e,n){if(n.isLeaf)return Gr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Ia&&(a instanceof Ad?r=r.concat(a.members):r.push(a))}return Ad.from(r)}eq(e){if(!(e instanceof Ad)||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?HL(r?n:n.sort(Of)):Gp}static from(e){switch(e.length){case 0:return Ia;case 1:return e[0];default:return new Ad(e.every(n=>n instanceof Gr)?e:e.reduce((n,r)=>n.concat(r instanceof Gr?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!=Ia?(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=uM(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 Gr(e.sort(Of),l)}function Yne(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Qa(i.from+e,i.to+e,i.type))}return n}function 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 Zne(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 Qne(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function uM(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Zne(t,l,c+n);if(u){a=!0;let d=uM(u,l,n+c+1,r);d!=Ia&&i.push(c,c+l.nodeSize,d)}});let o=Yne(a?Qne(t):t,-n).sort(Of);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 Gr(o,i):Ia}function Of(t,e){return t.from-e.from||t.to-e.to}function HL(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),uW(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),uW(e,i,r.copy(a.from,r.to)));break}}}return e}function uW(t,e,n){for(;e<t.length&&Of(n,t[e])>0;)e++;t.splice(e,0,n)}function Nj(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ia&&e.push(r)}),t.cursorWrapper&&e.push(Gr.create(t.state.doc,[t.cursorWrapper.deco])),Ad.from(e)}const YVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ZVe=Ns&&qd<=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]);Ns&&qd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Ca&&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(nW(this.view)){if(this.suppressingSelectionUpdates)return du(this.view);if(Ns&&qd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&om(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=Ug(a))n.add(a);for(let a=e.anchorNode;a;a=Ug(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&nW(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(jo&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,m]=d;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of d){let p=m.parentNode;p&&p.nodeName=="LI"&&(!f||nGe(e,f)!=p)&&m.remove()}}}else if((ta||Ca)&&c.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let d of c)if(d.nodeName=="BR"&&d.parentNode){let f=d.nextSibling;f&&f.nodeType==1&&f.contentEditable=="false"&&d.parentNode.removeChild(d)}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&SE(r)&&(u=LL(e))&&u.eq(Nn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,du(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)||du(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(Ns&&qd<=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?Sa(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?Sa(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let dW=new WeakMap,hW=!1;function eGe(t){if(!dW.has(t)&&(dW.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=jo,hW)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),hW=!0}}function fW(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return om(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 fW(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?fW(t,n):null}function 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}],SE(c)||u.push({node:c.focusNode,offset:c.focusOffset})),ta&&t.input.lastKeyCode===8)for(let x=a;x>i;x--){let v=r.childNodes[x-1],S=v.pmViewDesc;if(v.nodeName=="BR"&&!S){a=x;break}if(!S||S.size)break}let f=t.state.doc,m=t.someProp("domParser")||u0.fromSchema(t.state.schema),p=f.resolve(o),b=null,y=m.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode: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(Ca&&/^(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||Ca&&/^(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,D=LL(t,E);if(D&&!t.state.selection.eq(D)){if(ta&&nu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,lf(13,"Enter"))))return;let C=t.state.tr.setSelection(D);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++,(zg&&t.input.lastIOSEnter>Date.now()-225||nu)&&i.some(E=>E.nodeType==1&&!sGe.test(E.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",E=>E(t,lf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&c instanceof hn&&!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=mW(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let D=t.state.tr.setSelection(E);a&&D.setMeta("composition",a),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof hn&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Ns&&qd<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)==" "&&(b.start--,b.endA--,b.endB--);let y=u.doc.resolveNoCache(b.start-u.from),x=u.doc.resolveNoCache(b.endB-u.from),v=d.resolve(b.start),S=y.sameParent(x)&&y.parent.inlineContent&&v.end()>=b.endA;if((zg&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(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,lf(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,lf(8,"Backspace")))){nu&&ta&&t.domObserver.suppressSelectionUpdates();return}ta&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),nu&&!S&&y.start()!=x.start()&&x.parentOffset==0&&y.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,x=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,lf(13,"Enter"))})},20));let M=b.start,A=b.endA,T=E=>{let D=E||t.state.tr.replace(M,A,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let C=mW(t,D.doc,u.sel);C&&!(ta&&t.composing&&C.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==M||C.head==D.mapping.map(A)-1)||Ns&&C.empty&&C.head==M)&&D.setSelection(C)}return a&&D.setMeta("composition",a),D.scrollIntoView()},k;if(S)if(y.pos==x.pos){Ns&&qd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>du(t),20));let E=T(t.state.tr.delete(M,A)),D=d.resolve(b.start).marksAcross(d.resolve(b.endA));D&&E.ensureMarks(D),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),D=()=>T(t.state.tr.insertText(E,M,A));t.someProp("handleTextInput",C=>C(t,M,A,E,D))||t.dispatch(D())}else t.dispatch(T());else t.dispatch(T())}function mW(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:IL(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(Nt.from(u).eq(t))return{mark:l,type:o}}function cGe(t,e,n,r,i){if(n-e<=i.pos-r.pos||Ej(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=t.resolve(Ej(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Ej(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Ej(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function 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&&pW(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&pW(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function pW(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Jne{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(vW),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=bW(this),xW(this),this.nodeViews=yW(this),this.docView=Y9(this.state.doc,gW(this),Nj(this),this.dom,this),this.domObserver=new 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&&ZR(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vW),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(Wne(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=yW(this);hGe(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ZR(this),this.editable=bW(this),xW(this);let c=Nj(this),u=gW(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let m=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&BHe(this);if(o){this.domObserver.stop();let p=f&&(Ns||ta)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&dGe(i.selection,e.selection);if(f){let b=ta?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=Y9(e.doc,u,c,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dVe(this))?du(this,p):(Dne(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 rn){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&V9(this,n.getBoundingClientRect(),e)}else V9(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new Kne(e.slice,e.move,i<0?void 0:rn.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Ns){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&HHe(this.dom),du(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 Ene(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 cy(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return cy(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return FL(this,e)}destroy(){this.docView&&(TVe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Nj(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,jHe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return kVe(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ca&&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()}}Jne.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function gW(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Qa.node(0,t.state.doc.content.size,e)]}function xW(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Qa.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function bW(t){return!t.someProp("editable",e=>e(t.state)===!1)}function 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 yW(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function 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 vW(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var lh={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:"'"},dM={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 Ma=0;Ma<10;Ma++)lh[48+Ma]=lh[96+Ma]=String(Ma);for(var Ma=1;Ma<=24;Ma++)lh[Ma+111]="F"+Ma;for(var Ma=65;Ma<=90;Ma++)lh[Ma]=String.fromCharCode(Ma+32),dM[Ma]=String.fromCharCode(Ma);for(var Aj in lh)dM.hasOwnProperty(Aj)||(dM[Aj]=lh[Aj]);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?dM:lh)[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 Tj(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function vGe(t){return new Yr({props:{handleKeyDown:ere(t)}})}function ere(t){let e=yGe(t);return function(n,r){let i=pGe(r),a,o=e[Tj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Tj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(xGe&&r.ctrlKey&&r.altKey)&&(a=lh[r.keyCode])&&a!=i){let l=e[Tj(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var _Ge=Object.defineProperty,VL=(t,e)=>{for(var n in e)_Ge(t,n,{get:e[n],enumerable:!0})};function EE(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var AE=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,m])=>[f,(...b)=>{const y=this.buildProps(c,e),x=m(...b)(y);return o.push(x),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:EE({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(o)]))}};return o}},tre={};VL(tre,{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=fx(p);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,y)}(b||b===0)&&e.lift(p,b)})}),!0},NGe=t=>e=>t(e),EGe=()=>({state:t,dispatch:e})=>pne(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 hn(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 Ci(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=Ci(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})=>kL(t,e),PGe=()=>({commands:t})=>t.keyboardShortcut("Enter"),RGe=()=>({state:t,dispatch:e})=>gHe(t,e);function GL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function hM(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:GL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function nre(t,e,n={}){return t.find(r=>r.type===e&&hM(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function _W(t,e,n={}){return!!nre(t,e,n)}function WL(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),!nre([...i.node.marks],e,n)))return;let o=i.index,l=t.start()+i.offset,c=o+1,u=l+i.node.nodeSize;for(;o>0&&_W([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&_W([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function ku(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=ku(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=WL(c,a,e);if(f&&f.from<=u&&f.to>=d){const m=hn.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 rre(t){return t instanceof hn}function _f(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ire(t,e=null){if(!e)return null;const n=Nn.atStart(t),r=Nn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?hn.create(t,_f(0,i,a),_f(t.content.size,i,a)):hn.create(t,_f(e,i,a),_f(e,i,a))}function wW(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function fM(){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=()=>{(fM()||wW())&&r.dom.focus(),LGe()&&!fM()&&!wW()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!rre(n.state.selection))return o(),!0;const l=ire(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),are=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&&are(r)}return t};function Fw(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 are(n)}function dy(t,e,n){if(t instanceof Wd||t instanceof Nt)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 Nt.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),dy("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new $te({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:u=>(o=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?u0.fromSchema(c).parseSlice(Fw(t),n.parseOptions):u0.fromSchema(c).parse(Fw(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=u0.fromSchema(e);return n.slice?a.parseSlice(Fw(t),n.parseOptions).content:a.parse(Fw(t),n.parseOptions)}return dy("",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 Qi||i instanceof ra))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(Nn.near(t.doc.resolve(o),n))}var 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{dy(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{l=dy(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 Nt){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})=>lne(t,e),WGe=()=>({state:t,dispatch:e})=>hne(t,e),qGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vE(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},KGe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vE(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},XGe=()=>({state:t,dispatch:e})=>dHe(t,e),YGe=()=>({state:t,dispatch:e})=>hHe(t,e);function sre(){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))fM()||sre()?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 ch(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?Ci(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=>hM(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=Ci(t,n.schema);return ch(n,i,e)?pHe(n,r):!1},e7e=()=>({state:t,dispatch:e})=>gne(t,e),t7e=t=>({state:e,dispatch:n})=>{const r=Ci(t,e.schema);return AHe(r)(e,n)},n7e=()=>({state:t,dispatch:e})=>mne(t,e);function TE(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function SW(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var r7e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=TE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ci(t,r.schema)),l==="mark"&&(o=ku(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,SW(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(m=>{o===m.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(SW(m.attrs,e))))})})}),c},i7e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),a7e=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ys(t.doc);t.setSelection(n)}return!0},s7e=()=>({state:t,dispatch:e})=>une(t,e),o7e=()=>({state:t,dispatch:e})=>fne(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 QR(t,e,n={},r={}){return dy(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=QR(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function ore(t,e){const n=ku(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 lre(t,e){const n=new ine(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 CE(t){return e=>m7e(e.$from,t)}function Jt(t,e,n){return t.config[e]===void 0&&t.parent?Jt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Jt(t.parent,e,n):null}):t.config[e]}function qL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Jt(e,"addExtensions",n);return r?[e,...qL(r())]:e}).flat(10)}function KL(t,e){const n=gm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function cre(t){return typeof t=="function"}function ar(t,e=void 0,...n){return cre(t)?e?t.bind(e)(...n):t(...n):t}function p7e(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Bg(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function ure(t){const e=[],{nodeExtensions:n,markExtensions:r}=Bg(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=Jt(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=Jt(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 hy(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 MW(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):g7e(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function NW(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&p7e(n)?!1:n!=null))}function EW(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function x7e(t,e){var n;const r=ure(t),{nodeExtensions:i,markExtensions:a}=Bg(t),o=(n=i.find(u=>Jt(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=Jt(S,"extendNodeSchema",f);return{...v,...M?M(u):{}}},{}),p=NW({...m,content:ar(Jt(u,"content",f)),marks:ar(Jt(u,"marks",f)),group:ar(Jt(u,"group",f)),inline:ar(Jt(u,"inline",f)),atom:ar(Jt(u,"atom",f)),selectable:ar(Jt(u,"selectable",f)),draggable:ar(Jt(u,"draggable",f)),code:ar(Jt(u,"code",f)),whitespace:ar(Jt(u,"whitespace",f)),linebreakReplacement:ar(Jt(u,"linebreakReplacement",f)),defining:ar(Jt(u,"defining",f)),isolating:ar(Jt(u,"isolating",f)),attrs:Object.fromEntries(d.map(EW))}),b=ar(Jt(u,"parseHTML",f));b&&(p.parseDOM=b.map(v=>MW(v,d)));const y=Jt(u,"renderHTML",f);y&&(p.toDOM=v=>y({node:v,HTMLAttributes:hy(v,d)}));const x=Jt(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=Jt(v,"extendMarkSchema",f);return{...x,...S?S(u):{}}},{}),p=NW({...m,inclusive:ar(Jt(u,"inclusive",f)),excludes:ar(Jt(u,"excludes",f)),group:ar(Jt(u,"group",f)),spanning:ar(Jt(u,"spanning",f)),code:ar(Jt(u,"code",f)),attrs:Object.fromEntries(d.map(EW))}),b=ar(Jt(u,"parseHTML",f));b&&(p.parseDOM=b.map(x=>MW(x,d)));const y=Jt(u,"renderHTML",f);return y&&(p.toDOM=x=>y({mark:x,HTMLAttributes:hy(x,d)})),[u.name,p]}));return new $te({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 mM(t){return t.sort((n,r)=>{const i=Jt(n,"priority")||100,a=Jt(r,"priority")||100;return i>a?-1:i<a?1:0})}function dre(t){const e=mM(qL(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 hre(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 hre(t,n,e)}function fre(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=Ci(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 mre(t,e){const n=TE(typeof e=="string"?e:e.name,t.schema);return n==="node"?v7e(t,e):n==="mark"?ore(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 pre(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 XL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=WL(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 Uw(t,e){return e.nodes[t]||e.marks[t]||null}function S1(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 JR(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?ku(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>hM(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=>hM(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 ch(t,null,n)||JR(t,null,n);const r=TE(e,t.schema);return r==="node"?ch(t,e,n):r==="mark"?JR(t,e,n):!1}var E7e=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=CE(l=>l.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},A7e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function AW(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function TW(t,e){const{nodeExtensions:n}=Bg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=ar(Jt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function kE(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(kE(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function gre(t){return t instanceof rn}var xre=class bre{constructor(e){this.position=e}static fromJSON(e){return new bre(e.position)}toJSON(){return{position:this.position}}};function T7e(t,e){const n=e.mapping.mapResult(t.position);return{position:new xre(n.pos),mapResult:n}}function C7e(t){return new xre(t)}function k7e(t,e,n){var r;const{selection:i}=e;let a=null;if(rre(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=ku(t,r.schema);if(i)if(o){const u=ore(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=Ci(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>B9(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>B9(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},D7e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=_f(t,0,r.content.size),a=rn.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=hn.atStart(r).from,l=hn.atEnd(r).to,c=_f(i,o,l),u=_f(a,o,l),d=hn.create(r,c,u);e.setSelection(d)}return!0},I7e=t=>({state:e,dispatch:n})=>{const r=Ci(t,e.schema);return kHe(r)(e,n)};function CW(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var 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=S1(u,l.node().type.name,l.node().attrs);if(a instanceof rn&&a.node.isBlock)return!l.parentOffset||!uu(o,l.pos)?!1:(r&&(t&&CW(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,m=l.depth===0?void 0:h7e(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&m?[{type:m,attrs:d}]:void 0,b=uu(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!b&&uu(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 hn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),m&&!f&&!l.parentOffset&&l.parent.type!==m)){const y=e.mapping.map(l.before()),x=e.doc.resolve(y);l.node(-1).canReplaceWith(x.index(),x.index()+1,m)&&e.setNodeMarkup(e.mapping.map(l.before()),m)}t&&CW(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},U7e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=Ci(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=Nt.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let D=c.depth-S;D>=c.depth-3;D-=1)v=Nt.from(c.node(D).copy(v));const M=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...S1(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(Nt.from(l.createAndFill(null,T)||void 0));const k=c.before(c.depth-(S-1));n.replace(k,c.after(-M),new $t(v,4-S,0));let E=-1;n.doc.nodesBetween(k,n.doc.content.size,(D,C)=>{if(E>-1)return!1;D.isTextblock&&D.content.size===0&&(E=C+1)}),E>-1&&n.setSelection(hn.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...S1(m,f.type.name,f.attrs),...e},y={...S1(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(!uu(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},Cj=(t,e)=>{const n=CE(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&bh(t.doc,n.pos)&&t.join(n.pos),!0},kj=(t,e)=>{const n=CE(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&bh(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=Ci(t,o.schema),b=Ci(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=CE(k=>TW(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(TW(T.node.type.name,f)&&p.validContent(T.node.content)&&l)return c().command(()=>(a.setNodeMarkup(T.pos,p),!0)).command(()=>Cj(a,p)).command(()=>kj(a,p)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Cj(a,p)).command(()=>kj(a,p)).run():c().command(()=>{const k=d().wrapInList(p,r),E=A.filter(D=>m.includes(D.type.name));return a.ensureMarks(E),k?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Cj(a,p)).command(()=>kj(a,p)).run()},B7e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=ku(t,r.schema);return JR(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},$7e=(t,e,n={})=>({state:r,commands:i})=>{const a=Ci(t,r.schema),o=Ci(e,r.schema),l=ch(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=Ci(t,n.schema);return ch(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=ku(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=WL(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=TE(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=Ci(t,r.schema)),l==="mark"&&(o=ku(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=Ci(t,n.schema);return SHe(i,e)(n,r)},Y7e=(t,e={})=>({state:n,dispatch:r})=>{const i=Ci(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={}}},jE=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(GL(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 zw(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=EE({state:c.state,transaction:b}),x={from:r-(p[0].length-a.length),to:i},{commands:v,chain:S,can:M}=new AE({editor:n,state:y});m.handler({state:y,range:x,match:p,commands:v,chain:S,can:M})===null||!b.steps.length||(m.undoable&&b.setMeta(l,{transform:b,from:r,to:i,text:a}),c.dispatch(b),d=!0)}),d}function J7e(t){const{editor:e,rules:n}=t,r=new Yr({state:{init(){return null},apply(i,a,o){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=KL(Nt.from(d),o.schema);const{from:f}=c,m=f+d.length;zw({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 zw({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&zw({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?zw({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 Bw(t){return e9e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function yre(t,e){const n={...t};return Bw(t)&&Bw(e)&&Object.keys(e).forEach(r=>{Bw(e[r])&&Bw(t[r])?n[r]=yre(t[r],e[r]):n[r]=e[r]}),n}var YL=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{...ar(Jt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ar(Jt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>yre(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}},vh=class vre extends YL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new vre(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(GL(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 AE({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,b)=>{var y,x,v,S,M;if((x=(y=p.type)==null?void 0:y.spec)!=null&&x.code||!(p.isText||p.isTextblock||p.isInline))return;const 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 R=T+C.index+1,U=R+C[0].length,O={from:n.tr.mapping.map(R),to:n.tr.mapping.map(U)},q=a.handler({state:n,range:O,match:C,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(q)})}),f.every(p=>p!==null)}var $w=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=EE({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 Yr({view(f){const m=b=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(b.target)?f.dom.parentElement:null,r&&($w=e)},p=()=>{$w&&($w=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=$w;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=KL(Nt.from(T),p.schema);const{from:k}=v,E=k+T.length,D=a9e(T);return c({rule:d,state:p,from:k,to:{b:E},pasteEvt:D})}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 PE=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=dre(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:Uw(e.name,this.schema)},r=Jt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return mM([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Uw(r.name,this.schema)},a=[],o=Jt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Jt(r,"exitable",i)&&(l.ArrowRight=()=>vh.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=Jt(r,"addInputRules",i);if(AW(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=Jt(r,"addPasteRules",i);if(AW(r,t.options.enablePasteRules)&&d){const m=d();if(m&&m.length){const p=s9e({editor:t,rules:m});a.push(...p)}}const f=Jt(r,"addProseMirrorPlugins",i);if(f){const m=f();a.push(...m)}return a})}get attributes(){return ure(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Bg(this.extensions);return Object.fromEntries(e.filter(n=>!!Jt(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:Ci(n.name,this.schema)},a=Jt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,m)=>{const p=hy(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 mM([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Uw(i.name,this.schema)},o=Jt(i,"dispatchTransaction",a);return o?l=>{o.call(a,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Bg(this.extensions);return Object.fromEntries(e.filter(n=>!!Jt(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:ku(n.name,this.schema)},a=Jt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=hy(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:Uw(e.name,this.schema)};e.type==="mark"&&((n=ar(Jt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Jt(e,"onBeforeCreate",r),a=Jt(e,"onCreate",r),o=Jt(e,"onUpdate",r),l=Jt(e,"onSelectionUpdate",r),c=Jt(e,"onTransaction",r),u=Jt(e,"onFocus",r),d=Jt(e,"onBlur",r),f=Jt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};PE.resolve=dre;PE.sort=mM;PE.flatten=qL;var o9e={};VL(o9e,{ClipboardTextSerializer:()=>wre,Commands:()=>Sre,Delete:()=>Mre,Drop:()=>Nre,Editable:()=>Ere,FocusEvents:()=>Tre,Keymap:()=>Cre,Paste:()=>kre,Tabindex:()=>jre,TextDirection:()=>Pre,focusEventsPluginKey:()=>Are});var br=class _re extends YL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new _re(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},wre=br.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Yr({key:new Hi("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=fre(n);return hre(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Sre=br.create({name:"commands",addCommands(){return{...tre}}}),Mre=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=lre(t.before,[t,...e]);pre(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 al){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()}}),Nre=br.create({name:"drop",addProseMirrorPlugins(){return[new Yr({key:new Hi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Ere=br.create({name:"editable",addProseMirrorPlugins(){return[new Yr({key:new Hi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Are=new Hi("focusEvents"),Tre=br.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Yr({key:Are,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}}}})]}}),Cre=br.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:m,parent:p}=f,b=f.parent.isTextblock&&m>0?l.doc.resolve(m-1):f,y=b.parent.type.spec.isolating,x=f.pos-f.parentOffset,v=y&&b.parent.childCount===1?x===f.pos:Nn.atStart(u).from===m;return!d||!p.type.isTextblock||p.textContent.length||!v||v&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return fM()||sre()?a:i},addProseMirrorPlugins(){return[new Yr({key:new Hi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=Nn.atStart(e.doc).from,u=Nn.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!kE(n.doc))return;const m=n.tr,p=EE({state:n,transaction:m}),{commands:b}=new AE({editor:this.editor,state:p});if(b.clearNodes(),!!m.steps.length)return m}})]}}),kre=br.create({name:"paste",addProseMirrorPlugins(){return[new Yr({key:new Hi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),jre=br.create({name:"tabindex",addProseMirrorPlugins(){return[new Yr({key:new Hi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Pre=br.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Bg(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Yr({key:new Hi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),l9e=class Yb{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Yb(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Yb(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Yb(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(a?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!i&&!o&&c.depth<=this.depth)return;const u=new Yb(c,this.editor,i,i||o?n:null);i&&(u.actualDepth=this.depth+1),e.push(u)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&a.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},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=ire(e,this.options.autofocus);this.editorState=Jp.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=cre(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?[Ere,wre.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Sre,Tre,Cre,jre,Nre,kre,Mre,Pre.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new PE(r,this)}createCommandManager(){this.commandManager=new AE({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=QR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=QR(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new Jne(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 mre(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 KL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return y7e(this.state.doc,{blockSeparator:e,textSerializers:{...fre(this.schema),...n}})}get isEmpty(){return kE(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new l9e(e,this)}get $doc(){return this.$pos(0)}};function $g(t){return new jE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ar(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(XL(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 Rre(t){return new jE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=ar(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 eD(t){return new jE({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=ar(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function Hg(t){return new jE({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=ar(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&TL(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&&bh(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 rn){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={};VL(p9e,{createAtomBlockMarkdownSpec:()=>g9e,createBlockMarkdownSpec:()=>x9e,createInlineMarkdownSpec:()=>v9e,parseAttributes:()=>ZL,parseIndentedBlocks:()=>tD,renderNestedMarkdownContent:()=>JL,serializeAttributes:()=>QL});function ZL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const m=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[m];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function QL(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function g9e(t){const{nodeName:e,name:n,parseAttributes:r=ZL,serializeAttributes:i=QL,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(m=>{m in d&&(f[m]=d[m])}),f};return{parseMarkdown:(d,f)=>{const m={...a,...d.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(m))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,m){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=d.match(p);if(!b)return;const y=b[1]||"",x=r(y);if(!o.find(S=>!(S in x)))return{type:e,raw:b[0],attributes:x}}},renderMarkdown:d=>{const f=u(d.attrs||{}),m=i(f),p=m?` {${m}}`:"";return`:::${c}${p} :::`}}}function x9e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=ZL,serializeAttributes:a=QL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const m={};return c.forEach(p=>{p in f&&(m[p]=f[p])}),m};return{parseMarkdown:(f,m)=>{let p;if(r){const y=r(f);p=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?p=m.parseChildren(f.tokens||[]):p=m.parseInline(f.tokens||[]);const b={...o,...f.attributes};return m.createNode(e,b,p)},markdownTokenizer:{name:e,level:"block",start(f){var m;const p=new RegExp(`^:::${u}`,"m"),b=(m=f.match(p))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(f,m,p){var b;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=f.match(y);if(!x)return;const[v,S=""]=x,M=i(S);let A=1;const T=v.length;let k="";const E=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(T);for(E.lastIndex=0;;){const C=E.exec(D);if(C===null)break;const R=C.index,U=C[1];if(!((b=C[2])!=null&&b.endsWith(":::"))){if(U)A+=1;else if(A-=1,A===0){const O=D.slice(0,R);k=O.trim();const q=f.slice(0,T+R+C[0].length);let j=[];if(k)if(l==="block")for(j=p.blockTokens(O),j.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});j.length>0;){const W=j[j.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))j.pop();else break}else j=p.inlineTokens(k);return{type:e,raw:q,attributes:M,content:k,tokens:j}}}}}},renderMarkdown:(f,m)=>{const p=d(f.attrs||{}),b=a(p),y=b?` {${b}}`:"",x=m.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${x}
- :::`}}}function 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 tD(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(R=>R.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 JL(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 As=class Dre extends YL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Dre(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function cm(t){return new n9e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=ar(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(XL(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 jj(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function Hw(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 kW(t){return w9e(t).concat(S9e(t))}const E9e=Object.hasOwn||((t,e)=>M9e.call(t,e));function xm(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const A9e="__v",T9e="__o",C9e="_owner",{getOwnPropertyDescriptor:jW,keys:PW}=Object;function k9e(t,e){return t.byteLength===e.byteLength&&pM(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&&pM(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function R9e(t,e){return xm(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 RW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.entries();let o,l,c=0;for(;(o=a.next())&&!o.done;){const u=e.entries();let d=!1,f=0;for(;(l=u.next())&&!l.done;){if(i[f]){f++;continue}const m=o.value,p=l.value;if(n.equals(m[0],p[0],c,f,t,e,n)&&n.equals(m[1],p[1],m[0],p[0],t,e,n)){d=i[f]=!0;break}f++}if(!d)return!1;c++}return!0}const L9e=xm;function I9e(t,e,n){const r=PW(t);let i=r.length;if(PW(e).length!==i)return!1;for(;i-- >0;)if(!Ore(t,e,n,r[i]))return!1;return!0}function Rb(t,e,n){const r=kW(t);let i=r.length;if(kW(e).length!==i)return!1;let a,o,l;for(;i-- >0;)if(a=r[i],!Ore(t,e,n,a)||(o=jW(t,a),l=jW(e,a),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function F9e(t,e){return xm(t.valueOf(),e.valueOf())}function U9e(t,e){return t.source===e.source&&t.flags===e.flags}function DW(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),a=t.values();let o,l;for(;(o=a.next())&&!o.done;){const c=e.values();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(!i[d]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){u=i[d]=!0;break}d++}if(!u)return!1}return!0}function pM(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 Ore(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?Rb:j9e,areDataViewsEqual:P9e,areDatesEqual:R9e,areErrorsEqual:D9e,areFunctionsEqual:O9e,areMapsEqual:n?jj(RW,Rb):RW,areNumbersEqual:L9e,areObjectsEqual:n?Rb:I9e,arePrimitiveWrappersEqual:F9e,areRegExpsEqual:U9e,areSetsEqual:n?jj(DW,Rb):DW,areTypedArraysEqual:n?jj(pM,Rb):pM,areUrlsEqual:z9e,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=Hw(r.areArraysEqual),a=Hw(r.areMapsEqual),o=Hw(r.areObjectsEqual),l=Hw(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=_h();_h({strict:!0});_h({circular:!0});_h({circular:!0,strict:!0});_h({createInternalComparator:()=>xm});_h({strict:!0,createInternalComparator:()=>xm});_h({circular:!0,createInternalComparator:()=>xm});_h({circular:!0,createInternalComparator:()=>xm,strict:!0});function _h(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=wD.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=pX.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,nD=typeof window>"u",xWe=nD||!!(typeof window<"u"&&window.next),bWe=class Lre{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?nD||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?Lre.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=wD.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 gM=(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=As.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return gM("blockquote",{...ci(this.options.HTMLAttributes,t),children:gM("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Hg({find:SWe,type:this.type})]}}),NWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,EWe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,AWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,TWe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,CWe=vh.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 gM("strong",{...ci(this.options.HTMLAttributes,t),children:gM("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[$g({find:NWe,type:this.type}),$g({find:AWe,type:this.type})]},addPasteRules(){return[cm({find:EWe,type:this.type}),cm({find:TWe,type:this.type})]}}),kWe=/(^|[^`])`([^`]+)`(?!`)$/,jWe=/(^|[^`])`([^`]+)`(?!`)/g,PWe=vh.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[$g({find:kWe,type:this.type})]},addPasteRules(){return[cm({find:jWe,type:this.type})]}}),Pj=4,RWe=/^```([a-z]+)?[\s\n]$/,DWe=/^~~~([a-z]+)?[\s\n]$/,OWe=As.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Pj,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",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:Pj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,p=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(b=>l+b).join(`
- `);return c.replaceWith(u,d,r.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Pj,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),p=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let b=0,y=0;const x=u-d;for(let k=0;k<p.length;k+=1){if(y+p[k].length>=x){b=k;break}y+=p[k].length+1}const S=((c=p[b].match(/^ */))==null?void 0:c[0])||"",M=Math.min(S.length,n);if(M===0)return!0;let 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(hn.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(Nn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[eD({find:RWe,type:this.type,getAttributes:t=>({language:t[1]})}),eD({find:DWe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Yr({key:new Hi("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(hn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),LWe=As.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),IWe=As.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",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=As.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,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=>eD({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),UWe=As.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 gre(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(hn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(rn.create(o.doc,c.pos)):o.setSelection(hn.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(hn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Rre({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=vh.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[$g({find:zWe,type:this.type}),$g({find:$We,type:this.type})]},addPasteRules(){return[cm({find:BWe,type:this.type}),cm({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",rD="numeric",iD="ascii",aD="alpha",m0="asciinumeric",Zb="alphanumeric",sD="domain",Ire="emoji",qWe="scheme",KWe="slashscheme",Rj="whitespace";function XWe(t,e){return t in e||(e[t]=[]),e[t]}function wf(t,e,n){e[rD]&&(e[m0]=!0,e[Zb]=!0),e[iD]&&(e[m0]=!0,e[aD]=!0),e[m0]&&(e[Zb]=!0),e[aD]&&(e[Zb]=!0),e[Zb]&&(e[sD]=!0),e[Ire]&&(e[sD]=!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 bs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}bs.groups={};bs.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||bs.groups;let i;return e&&e.j?i=e:(i=new bs(e),n&&r&&wf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||bs.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new bs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new bs,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(YWe(o.t,r),n);wf(a,c,r)}else n&&wf(a,n,r);o.t=a}return i.j[t]=o,o}};const _n=(t,e,n,r,i)=>t.ta(e,n,r,i),ei=(t,e,n,r,i)=>t.tr(e,n,r,i),OW=(t,e,n,r,i)=>t.ts(e,n,r,i),Tt=(t,e,n,r,i)=>t.tt(e,n,r,i),Gc="WORD",oD="UWORD",Fre="ASCIINUMERICAL",Ure="ALPHANUMERICAL",fy="LOCALHOST",lD="TLD",cD="UTLD",M1="SCHEME",Wp="SLASH_SCHEME",eI="NUM",uD="WS",tI="NL",p0="OPENBRACE",g0="CLOSEBRACE",xM="OPENBRACKET",bM="CLOSEBRACKET",yM="OPENPAREN",vM="CLOSEPAREN",_M="OPENANGLEBRACKET",wM="CLOSEANGLEBRACKET",SM="FULLWIDTHLEFTPAREN",MM="FULLWIDTHRIGHTPAREN",NM="LEFTCORNERBRACKET",EM="RIGHTCORNERBRACKET",AM="LEFTWHITECORNERBRACKET",TM="RIGHTWHITECORNERBRACKET",CM="FULLWIDTHLESSTHAN",kM="FULLWIDTHGREATERTHAN",jM="AMPERSAND",PM="APOSTROPHE",RM="ASTERISK",wd="AT",DM="BACKSLASH",OM="BACKTICK",LM="CARET",Td="COLON",nI="COMMA",IM="DOLLAR",Pl="DOT",FM="EQUALS",rI="EXCLAMATION",bo="HYPHEN",x0="PERCENT",UM="PIPE",zM="PLUS",BM="POUND",b0="QUERY",iI="QUOTE",zre="FULLWIDTHMIDDLEDOT",aI="SEMI",Rl="SLASH",y0="TILDE",$M="UNDERSCORE",Bre="EMOJI",HM="SYM";var $re=Object.freeze({__proto__:null,ALPHANUMERICAL:Ure,AMPERSAND:jM,APOSTROPHE:PM,ASCIINUMERICAL:Fre,ASTERISK:RM,AT:wd,BACKSLASH:DM,BACKTICK:OM,CARET:LM,CLOSEANGLEBRACKET:wM,CLOSEBRACE:g0,CLOSEBRACKET:bM,CLOSEPAREN:vM,COLON:Td,COMMA:nI,DOLLAR:IM,DOT:Pl,EMOJI:Bre,EQUALS:FM,EXCLAMATION:rI,FULLWIDTHGREATERTHAN:kM,FULLWIDTHLEFTPAREN:SM,FULLWIDTHLESSTHAN:CM,FULLWIDTHMIDDLEDOT:zre,FULLWIDTHRIGHTPAREN:MM,HYPHEN:bo,LEFTCORNERBRACKET:NM,LEFTWHITECORNERBRACKET:AM,LOCALHOST:fy,NL:tI,NUM:eI,OPENANGLEBRACKET:_M,OPENBRACE:p0,OPENBRACKET:xM,OPENPAREN:yM,PERCENT:x0,PIPE:UM,PLUS:zM,POUND:BM,QUERY:b0,QUOTE:iI,RIGHTCORNERBRACKET:EM,RIGHTWHITECORNERBRACKET:TM,SCHEME:M1,SEMI:aI,SLASH:Rl,SLASH_SCHEME:Wp,SYM:HM,TILDE:y0,TLD:lD,UNDERSCORE:$M,UTLD:cD,UWORD:oD,WORD:Gc,WS:uD});const Bc=/[a-z]/,Db=new RegExp("\\p{L}","u"),Dj=new RegExp("\\p{Emoji}","u"),$c=/\d/,Oj=/\s/,LW="\r",Lj=`
- `,ZWe="️",QWe="",Ij="";let Vw=null,Gw=null;function JWe(t=[]){const e={};bs.groups=e;const n=new bs;Vw==null&&(Vw=IW(GWe)),Gw==null&&(Gw=IW(WWe)),Tt(n,"'",PM),Tt(n,"{",p0),Tt(n,"}",g0),Tt(n,"[",xM),Tt(n,"]",bM),Tt(n,"(",yM),Tt(n,")",vM),Tt(n,"<",_M),Tt(n,">",wM),Tt(n,"(",SM),Tt(n,")",MM),Tt(n,"「",NM),Tt(n,"」",EM),Tt(n,"『",AM),Tt(n,"』",TM),Tt(n,"<",CM),Tt(n,">",kM),Tt(n,"&",jM),Tt(n,"*",RM),Tt(n,"@",wd),Tt(n,"`",OM),Tt(n,"^",LM),Tt(n,":",Td),Tt(n,",",nI),Tt(n,"$",IM),Tt(n,".",Pl),Tt(n,"=",FM),Tt(n,"!",rI),Tt(n,"-",bo),Tt(n,"%",x0),Tt(n,"|",UM),Tt(n,"+",zM),Tt(n,"#",BM),Tt(n,"?",b0),Tt(n,'"',iI),Tt(n,"/",Rl),Tt(n,";",aI),Tt(n,"~",y0),Tt(n,"_",$M),Tt(n,"\\",DM),Tt(n,"・",zre);const r=ei(n,$c,eI,{[rD]:!0});ei(r,$c,r);const i=ei(r,Bc,Fre,{[m0]:!0}),a=ei(r,Db,Ure,{[Zb]:!0}),o=ei(n,Bc,Gc,{[iD]:!0});ei(o,$c,i),ei(o,Bc,o),ei(i,$c,i),ei(i,Bc,i);const l=ei(n,Db,oD,{[aD]:!0});ei(l,Bc),ei(l,$c,a),ei(l,Db,l),ei(a,$c,a),ei(a,Bc),ei(a,Db,a);const c=Tt(n,Lj,tI,{[Rj]:!0}),u=Tt(n,LW,uD,{[Rj]:!0}),d=ei(n,Oj,uD,{[Rj]:!0});Tt(n,Ij,d),Tt(u,Lj,c),Tt(u,Ij,d),ei(u,Oj,d),Tt(d,LW),Tt(d,Lj),ei(d,Oj,d),Tt(d,Ij,d);const f=ei(n,Dj,Bre,{[Ire]:!0});Tt(f,"#"),ei(f,Dj,f),Tt(f,ZWe,f);const m=Tt(f,QWe);Tt(m,"#"),ei(m,Dj,f);const p=[[Bc,o],[$c,i]],b=[[Bc,null],[Db,l],[$c,a]];for(let y=0;y<Vw.length;y++)md(n,Vw[y],lD,Gc,p);for(let y=0;y<Gw.length;y++)md(n,Gw[y],cD,oD,b);wf(lD,{tld:!0,ascii:!0},e),wf(cD,{utld:!0,alpha:!0},e),md(n,"file",M1,Gc,p),md(n,"mailto",M1,Gc,p),md(n,"http",Wp,Gc,p),md(n,"https",Wp,Gc,p),md(n,"ftp",Wp,Gc,p),md(n,"ftps",Wp,Gc,p),wf(M1,{scheme:!0,ascii:!0},e),wf(Wp,{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[sD]=!0:Bc.test(x)?$c.test(x)?S[m0]=!0:S[iD]=!0:S[rD]=!0,OW(n,x,x,S)}return OW(n,"localhost",fy,{ascii:!0}),n.jd=new bs(HM),{start:n,tokens:Object.assign({groups:e},$re)}}function Hre(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 md(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new bs(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new bs(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function IW(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const my={defaultProtocol:"http",events:null,format:FW,formatHref:FW,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function sI(t,e=null){let n=Object.assign({},my);t&&(n=Object.assign(n,t instanceof sI?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}sI.prototype={o:my,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]:my[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function FW(t){return t}function Vre(t,e){this.t="token",this.v=t,this.tk=e}Vre.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=my.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:a,eventListeners:f}}};function RE(t,e){class n extends Vre{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const UW=RE("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),zW=RE("text"),tqe=RE("nl"),Ww=RE("url",{isLink:!0,toHref(t=my.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==fy&&t[1].t===Td}}),po=t=>new bs(t);function nqe({groups:t}){const e=t.domain.concat([jM,RM,wd,DM,OM,LM,IM,FM,bo,eI,x0,UM,zM,BM,Rl,HM,y0,$M]),n=[PM,Td,nI,Pl,rI,x0,b0,iI,aI,_M,wM,p0,g0,bM,xM,yM,vM,SM,MM,NM,EM,AM,TM,CM,kM],r=[jM,PM,RM,DM,OM,LM,IM,FM,bo,p0,g0,x0,UM,zM,BM,b0,Rl,HM,y0,$M],i=po(),a=Tt(i,y0);_n(a,r,a),_n(a,t.domain,a);const o=po(),l=po(),c=po();_n(i,t.domain,o),_n(i,t.scheme,l),_n(i,t.slashscheme,c),_n(o,r,a),_n(o,t.domain,o);const u=Tt(o,wd);Tt(a,wd,u),Tt(l,wd,u),Tt(c,wd,u);const d=Tt(a,Pl);_n(d,r,a),_n(d,t.domain,a);const f=po();_n(u,t.domain,f),_n(f,t.domain,f);const m=Tt(f,Pl);_n(m,t.domain,f);const p=po(UW);_n(m,t.tld,p),_n(m,t.utld,p),Tt(u,fy,p);const b=Tt(f,bo);Tt(b,bo,b),_n(b,t.domain,f),_n(p,t.domain,f),Tt(p,Pl,m),Tt(p,bo,b);const y=Tt(p,Td);_n(y,t.numeric,UW);const x=Tt(o,bo),v=Tt(o,Pl);Tt(x,bo,x),_n(x,t.domain,o),_n(v,r,a),_n(v,t.domain,o);const S=po(Ww);_n(v,t.tld,S),_n(v,t.utld,S),_n(S,t.domain,o),_n(S,r,a),Tt(S,Pl,v),Tt(S,bo,x),Tt(S,wd,u);const M=Tt(S,Td),A=po(Ww);_n(M,t.numeric,A);const T=po(Ww),k=po();_n(T,e,T),_n(T,n,k),_n(k,e,T),_n(k,n,k),Tt(S,Rl,T),Tt(A,Rl,T);const E=Tt(l,Td),D=Tt(c,Td),C=Tt(D,Rl),R=Tt(C,Rl);_n(l,t.domain,o),Tt(l,Pl,v),Tt(l,bo,x),_n(c,t.domain,o),Tt(c,Pl,v),Tt(c,bo,x),_n(E,t.domain,T),Tt(E,Rl,T),Tt(E,b0,T),_n(R,t.domain,T),_n(R,e,T),Tt(R,Rl,T);const U=[[p0,g0],[xM,bM],[yM,vM],[_M,wM],[SM,MM],[NM,EM],[AM,TM],[CM,kM]];for(let O=0;O<U.length;O++){const[q,j]=U[O],W=Tt(T,q);Tt(k,q,W),Tt(W,j,T);const K=po(Ww);_n(W,e,K);const G=po();_n(W,n),_n(K,e,K),_n(K,n,G),_n(G,e,K),_n(G,n,G),Tt(K,j,T),Tt(G,j,T)}return Tt(i,fy,S),Tt(i,tI,tqe),{start:i,tokens:$re}}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(Fj(zW,e,o)),o=[]),i-=m,d-=m;const p=f.t,b=n.slice(i-d,i);a.push(Fj(p,e,b))}}return o.length>0&&a.push(Fj(zW,e,o)),a}function Fj(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const 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.",Rr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function sqe(){return bs.groups={},Rr.scanner=null,Rr.parser=null,Rr.tokenQueue=[],Rr.pluginQueue=[],Rr.customSchemes=[],Rr.initialized=!1,Rr}function BW(t,e=!1){if(Rr.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`);Rr.customSchemes.push([t,e])}function oqe(){Rr.scanner=JWe(Rr.customSchemes);for(let t=0;t<Rr.tokenQueue.length;t++)Rr.tokenQueue[t][1]({scanner:Rr.scanner});Rr.parser=nqe(Rr.scanner.tokens);for(let t=0;t<Rr.pluginQueue.length;t++)Rr.pluginQueue[t][1]({scanner:Rr.scanner,parser:Rr.parser});return Rr.initialized=!0,Rr}function oI(t){return Rr.initialized||oqe(),rqe(Rr.parser.start,t,Hre(Rr.scanner.start,t))}oI.scan=Hre;function Gre(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 sI(n),i=oI(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 lI="[\0- -\u2029 ]",lqe=new RegExp(lI),cqe=new RegExp(`${lI}$`),uqe=new RegExp(lI,"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 Yr({key:new Hi("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=lre(n.doc,[...e]);if(pre(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=oI(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=>{XL(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 Yr({key:new Hi("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=mre(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 Yr({key:new Hi("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=Gre(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 Yh(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(uqe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Wre=vh.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){BW(t);return}BW(t.scheme,t.optionalSlashes)})},onDestroy(){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)=>!!Yh(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=>!!Yh(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Yh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",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=>!!Yh(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Yh(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[cm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Gre(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Yh(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(hqe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Yh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),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=Wre,gqe=Object.defineProperty,xqe=(t,e)=>{for(var n in e)gqe(t,n,{get:e[n],enumerable:!0})},bqe="listItem",$W="textStyle",HW=/^\s*([-+*])\s$/,qre=As.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",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($W)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Hg({find:HW,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hg({find:HW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes($W),editor:this.editor})),[t]}}),Kre=As.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",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)=>JL(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:()=>ev,getNextListDepth:()=>cI,handleBackspace:()=>dD,handleDelete:()=>hD,hasListBefore:()=>Xre,hasListItemAfter:()=>vqe,hasListItemBefore:()=>Yre,listItemHasSubList:()=>Zre,nextListIsDeeper:()=>Qre,nextListIsHigher:()=>Jre});var ev=(t,e)=>{const{$from:n}=e.selection,r=Ci(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}},cI=(t,e)=>{const n=ev(t,e);if(!n)return!1;const[,r]=S7e(e,t,n.$pos.pos+4);return r},Xre=(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))},Yre=(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)},Zre=(t,e,n)=>{if(!n)return!1;const r=Ci(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},dD=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ch(t.state,e)&&Xre(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(!ch(t.state,e)||!A7e(t.state))return!1;const r=ev(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Zre(e,t.state,a);return Yre(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Qre=(t,e)=>{const n=cI(t,e),r=ev(t,e);return!r||!n?!1:n>r.depth},Jre=(t,e)=>{const n=cI(t,e),r=ev(t,e);return!r||!n?!1:n<r.depth},hD=(t,e)=>{if(!ch(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:Qre(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Jre(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)},eie=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&&hD(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&&hD(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&&dD(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&&dD(t,n,r)&&(e=!0)}),e}}}}),VW=/^(\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(VW);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const m=[i];for(;f<t.length;){const p=t[f];if(p.match(VW))break;if(p.trim()==="")m.push(p),d+=`
- `,f+=1;else if(p.match(_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 tie(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=tie(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",GW="textStyle",WW=/^(\d+)\.\s$/,nie=As.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",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=tie(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(GW)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Hg({find:WW,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hg({find:WW,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(GW)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Nqe=/^\s*(\[([( |x])?\])\s$/,Eqe=As.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",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 JL(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=hy(f,m),b=new Set(Object.keys(p)),y=this.options.HTMLAttributes;return d.forEach(x=>{b.has(x)||(x in y?i.setAttribute(x,y[x]):i.removeAttribute(x))}),Object.entries(p).forEach(([x,v])=>{v==null?x in y?i.setAttribute(x,y[x]):i.removeAttribute(x):i.setAttribute(x,v)}),d=b,!0}}}},addInputRules(){return[Hg({find:Nqe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Aqe=As.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",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=tD(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=tD(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(qre.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Kre.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(eie.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(nie.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 qW=" ",Tqe=" ",Cqe=As.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===qW||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?qW: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=vh.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[$g({find:kqe,type:this.type})]},addPasteRules(){return[cm({find:jqe,type:this.type})]}}),Rqe=As.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),rie=vh.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=rie;function Oqe(t={}){return new Yr({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=Jte(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 Nn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ai.valid(r)?new ai(r):Nn.near(r)}content(){return $t.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 uI(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&&!rn.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;Nn.jsonID("gapcursor",ai);class uI{constructor(e){this.pos=e}map(e){return new uI(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ai.valid(n)?new ai(n):Nn.near(n)}}function iie(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||iie(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||iie(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Uqe(){return new Yr({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=ere({ArrowLeft:qw("horiz",-1),ArrowRight:qw("horiz",1),ArrowUp:qw("vert",-1),ArrowDown:qw("vert",1)});function qw(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 hn){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&&rn.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=Nt.empty;for(let o=r.length-1;o>=0;o--)i=Nt.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new $t(i,0,0));return a.setSelection(hn.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",Gr.create(t.doc,[Qa.widget(t.selection.head,e,{key:"gapcursor"})])}var VM=200,ia=function(){};ia.prototype.append=function(e){return e.length?(e=ia.from(e),!this.length&&e||e.length<VM&&this.leafAppend(e)||this.length<VM&&e.leafPrepend(this)||this.appendInner(e)):this};ia.prototype.prepend=function(e){return e.length?ia.from(e).append(this):this};ia.prototype.appendInner=function(e){return new Vqe(this,e)};ia.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ia.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ia.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ia.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ia.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};ia.from=function(e){return e instanceof ia?e:e&&e.length?new aie(e):ia.empty};var aie=(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<=VM)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=VM)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ia);ia.empty=new aie([]);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})(ia);const Gqe=500;class nl{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,m)=>{if(!f.step){i||(i=this.remapping(r,m+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new Dl(f.map));let p=f.step.map(i.slice(a)),b;p&&o.maybeStep(p).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],u.push(new Dl(b,void 0,void 0,u.length+d.length))),a--,b&&i.appendMap(b,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new nl(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let a=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),m=new Dl(e.mapping.maps[d],f,n),p;(p=c&&c.merge(m))&&(m=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(m),n&&(o++,n=void 0),i||(c=m)}let u=o-r.depth;return u>qqe&&(l=Wqe(l,u),o-=u),new nl(l.append(a),o)}remapping(e,n){let r=new sy;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 nl(this.items.append(e.map(n=>new Dl(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(m=>{m.selection&&l--},i);let c=n;this.items.forEach(m=>{let p=a.getMirror(--c);if(p==null)return;o=Math.min(o,p);let b=a.maps[p];if(m.step){let y=e.steps[p].invert(e.docs[p]),x=m.selection&&m.selection.map(a.slice(c+1,p));x&&l++,r.push(new Dl(b,y,x))}else r.push(new Dl(b))},i);let u=[];for(let m=n;m<o;m++)u.push(new Dl(a.maps[m]));let d=this.items.slice(0,i).append(u).append(r),f=new nl(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 Dl(u.invert(),c,d),m,p=i.length-1;(m=i.length&&i[p].merge(f))?i[p]=m:i.push(f)}}else o.map&&r--},this.items.length,0),new nl(ia.from(i.reverse()),a)}}nl.empty=new nl(ia.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 Dl{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Dl(n.getMap().invert(),n,this.selection)}}}class Sd{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(Lf),a;if(i)return i.historyState;n.getMeta(Zqe)&&(t=new Sd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Lf))return o.getMeta(Lf).redo?new Sd(t.done.addTransform(n,void 0,r,N1(e)),t.undone,KW(n.mapping.maps),t.prevTime,t.prevComposition):new Sd(t.done,t.undone.addTransform(n,void 0,r,N1(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?Uj(t.prevRanges,n.mapping):KW(n.mapping.maps);return new Sd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,N1(e)),nl.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Sd(t.done.rebased(n,a),t.undone.rebased(n,a),Uj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Sd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Uj(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 KW(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function Uj(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function Yqe(t,e,n){let r=N1(e),i=Lf.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 Sd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Lf,{redo:n,historyState:c})}let zj=!1,XW=null;function N1(t){let e=t.plugins;if(XW!=e){zj=!1,XW=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){zj=!0;break}}return zj}const Lf=new Hi("history"),Zqe=new Hi("closeHistory");function Qqe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Yr({key:Lf,state:{init(){return new Sd(nl.empty,nl.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"?oie:r=="historyRedo"?lie:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function sie(t,e){return(n,r)=>{let i=Lf.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 oie=sie(!1,!0),lie=sie(!0,!0);br.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Yr({key:new Hi("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 Yr({key:new Hi("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Gr.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(Qa.node(u,u+c.nodeSize,{class:this.options.className}))}),Gr.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=ar(Jt(t,"allowGapCursor",n)))!=null?e:null}}});br.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Yr({key:new Hi("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&kE(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Qa.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Gr.create(t,i)}}})]}});br.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Yr({key:new Hi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||gre(n.selection)||t.view.dragging?null:Gr.create(n.doc,[Qa.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function YW({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var tKe=br.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Hi(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Yr({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,m=u.nodes[n];if(d)return c.insert(f,m.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!YW({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!YW({node:o,types:r})}}})]}}),nKe=br.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>oie(t,e),redo:()=>({state:t,dispatch:e})=>lie(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(qre.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(Kre.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(eie.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Wre.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(nie.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(rie.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,cie=(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(...cie(r,e+1))}),n},lKe=t=>{if(!t.children.length)return;const e=cie(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}`)})},uie=vh.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()}}}),die=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(die.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(uie.configure(this.options.textStyle)),t}});var fKe=die,mKe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,pKe=As.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",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[Rre({find:mKe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),gKe=pKe;function fD({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"]}),uie,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(cN,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(xK,{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(Yg,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(HD,{className:"w-4 h-4"})})]}),s.jsx(hWe,{editor:r})]})}function hie({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:()=>fe.getArchiveProjectPage(t)}),p=mt({mutationFn:T=>fe.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"),D=C=>{if(C.nodeType===Node.TEXT_NODE)return C.textContent||"";if(C.nodeType===Node.ELEMENT_NODE){const R=C,U=R.tagName.toLowerCase();if(!k.includes(U))return Array.from(R.childNodes).map(D).join("");let O="";if(U==="a"&&R.getAttribute("href")){const j=R.getAttribute("href");j?.toLowerCase().startsWith("http")&&(O=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(U==="img"){const j=R.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";O=` src="${j}" style="max-width: 100%; height: auto;"`}const q=Array.from(R.childNodes).map(D).join("");return["br","img"].includes(U)?`<${U}${O} />`:`<${U}${O}>${q}</${U}>`}return""};return Array.from(E.body.childNodes).map(D).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(Ya,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&M&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:y,children:[s.jsx($f,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Me,{variant:"primary",size:"sm",onClick:x,disabled:p.isPending,children:[s.jsx(ys,{className:"w-4 h-4 mr-1"}),"Save"]})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),m&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!M&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ya,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&M&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange: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(SP,{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(SP,{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(Ya,{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(Ya,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(fD,{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(fD,{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(wy,{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(Bf,{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(Zs,{className:"w-6 h-6 text-white"})}),s.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:s.jsx(Ht,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",b.length]})]})]})}const xKe=[.25,.5,.75,1,1.5,2,3,4];function Fp(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}=Gn(),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,D]=w.useState(.8),[C,R]=w.useState(!1),{data:U,isLoading:O}=ut({queryKey:["timelapse-info",t],queryFn:()=>fe.getTimelapseInfo(t)}),{data:q}=ut({queryKey:["timelapse-thumbnails",t],queryFn:()=>fe.getTimelapseThumbnails(t,15)}),j=mt({mutationFn:()=>fe.processTimelapse(t,{trimStart:p,trimEnd:y,speed:v,saveMode:"replace"},M||void 0),onSuccess:z=>{i(z.message,"success"),r?.(),n()},onError:z=>{i(z.message||"Processing failed","error")}});w.useEffect(()=>{U?.duration&&y===0&&x(U.duration)},[U?.duration,y]),w.useEffect(()=>{const z=V=>{V.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]),w.useEffect(()=>{const z=a.current;if(!z)return;const V=()=>{const pe=z.currentTime;d(pe),pe>=y&&(z.currentTime=p)},ne=()=>{m(z.duration),y===0&&x(z.duration)},ae=()=>c(!0),he=()=>c(!1);return z.addEventListener("timeupdate",V),z.addEventListener("durationchange",ne),z.addEventListener("play",ae),z.addEventListener("pause",he),()=>{z.removeEventListener("timeupdate",V),z.removeEventListener("durationchange",ne),z.removeEventListener("play",ae),z.removeEventListener("pause",he)}},[p,y]),w.useEffect(()=>{const z=o.current,V=a.current;!z||!V||!T||(z.currentTime=V.currentTime,z.playbackRate=V.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 V=a.current;V&&(V.currentTime=Math.max(p,Math.min(y,z)))},G=z=>{const V=z.target.files?.[0];V&&(T&&URL.revokeObjectURL(T),A(V),k(URL.createObjectURL(V)))},Q=()=>{T&&URL.revokeObjectURL(T),A(null),k(null)};w.useEffect(()=>()=>{T&&URL.revokeObjectURL(T)},[T]);const te=y-p,J=te/v;return O?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(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(Ud,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(ys,{className:"w-4 h-4"}),"Save"]})}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:W,muted:!!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(Do,{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:[Fp(p)," - ",Fp(y)," (",Fp(te),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:q?.thumbnails.map((z,V)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${z})`}},V))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${p/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${p/f*100}%`,right:`${(f-y)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:p,onChange:z=>{const V=parseFloat(z.target.value);V<y-1&&(b(V),a.current&&a.current.currentTime<V&&(a.current.currentTime=V))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:y,onChange:z=>{const V=parseFloat(z.target.value);V>p+1&&x(V)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:z=>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(BD,{className:"w-5 h-5 text-white"}):s.jsx(Do,{className:"w-5 h-5 text-white"})})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(aN,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",Fp(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(_P,{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(_P,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:M.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(M.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>R(!C),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:C?s.jsx(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=>D(parseFloat(z.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:Q,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(un,{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(mi,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:G,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",Fp(f)," @ ",U?.width,"x",U?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",Fp(J)," @ ",v,"x speed",M&&" + music overlay"]})]})]}),j.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(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 fie({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=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),w.useEffect(()=>{const E=o.current;if(!E)return;const D=()=>m(E.currentTime),C=()=>b(E.duration),R=()=>c(!0),U=()=>c(!1);return E.addEventListener("timeupdate",D),E.addEventListener("durationchange",C),E.addEventListener("play",R),E.addEventListener("pause",U),()=>{E.removeEventListener("timeupdate",D),E.removeEventListener("durationchange",C),E.removeEventListener("play",R),E.removeEventListener("pause",U)}},[]);const v=()=>{const E=o.current;E&&(l?E.pause():E.play())},S=E=>{const D=o.current;D&&(D.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 D=Math.floor(E/60),C=Math.floor(E%60);return`${D}:${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(Ud,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>x(!0),children:[s.jsx(sa,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx(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(Ht,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:v}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children: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(BD,{className:"w-5 h-5 text-white"}):s.jsx(Do,{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(k0,{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:()=>fe.compareArchives(t)});return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(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(An,{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(Me,{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(An,{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(An,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(ts,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[s.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),s.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?s.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>s.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[s.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",s.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):s.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:s.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function 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(Mt,{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-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(Xn,{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(fu,{className:"w-5 h-5"}):s.jsx(Di,{className:"w-5 h-5"})}),s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:m||void 0}),disabled:i,children:i?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ja,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:a,children:a?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4 text-red-400"})})]})]}),b&&s.jsx(zn,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),y(!1)},onCancel:()=>y(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:x=>f(x.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:m||"",onChange:x=>p(x.target.value?Number(x.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[s.jsx("option",{value:"",children:"No project"}),e.map(x=>s.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})]})})}function NKe(){const t=on(),{showToast:e}=Gn(),[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:Bp.list,refetchInterval:1e4}),{data:m}=ut({queryKey:["projects"],queryFn:()=>fe.getProjects()}),p=mt({mutationFn:({id:v,data:S})=>Bp.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=>Bp.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:Bp.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:Bp.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(Mt,{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(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mi,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ja,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:x.isPending,children:x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(un,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Mt,{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(zn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{y.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(zn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{x.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function GM(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ob(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function cf(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}=Gn(),d=jK(),[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,D]=w.useState([]),[C,R]=w.useState(!1),[U,O]=w.useState(!1),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[G,Q]=w.useState(!1),[te,J]=w.useState(!1),[z,V]=w.useState(null),ne=w.useRef(null),ae=w.useRef(null),he=mt({mutationFn:I=>fe.uploadSource3mf(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${I.filename}`)},onError:I=>{u(I.message||"Failed to upload source 3MF","error")}}),pe=mt({mutationFn:()=>fe.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:I=>{u(I.message||"Failed to remove source 3MF","error")}}),ie=mt({mutationFn:I=>fe.uploadF3d(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${I.filename}`)},onError:I=>{u(I.message||"Failed to upload F3D","error")}}),Ee=mt({mutationFn:()=>fe.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:I=>{u(I.message||"Failed to remove F3D","error")}}),xe=mt({mutationFn:()=>fe.scanArchiveTimelapse(t.id),onSuccess:I=>{I.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${I.filename}`)):I.status==="exists"?u("Timelapse already attached"):I.status==="not_found"&&I.available_files&&I.available_files.length>0?(D(I.available_files),k(!0)):u(I.message||"No matching timelapse found","warning")},onError:I=>{u(I.message||"Failed to scan for timelapse","error")}}),Ne=mt({mutationFn:I=>fe.selectArchiveTimelapse(t.id,I),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${I.filename}`),k(!1),D([])},onError:I=>{u(I.message||"Failed to attach timelapse","error")}}),_e=mt({mutationFn:()=>fe.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),le=mt({mutationFn:()=>fe.toggleFavorite(t.id),onSuccess:I=>{c.invalidateQueries({queryKey:["archives"]}),u(I.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Ve}=ut({queryKey:["archive-folders",t.id],queryFn:()=>fe.getLibraryFoldersByArchive(t.id)}),H=mt({mutationFn:I=>fe.updateArchive(t.id,{project_id:I}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),ee=I=>{I.preventDefault(),V({x:I.clientX,y:I.clientY})},B=[...cf(t.filename)?[{label:"Print",icon:s.jsx(Wr,{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",ue=`${window.location.origin}${fe.getArchiveForSlicer(t.id,I)}`;Xc(ue)}}]:[{label:"Slice",icon:s.jsx(zr,{className:"w-4 h-4"}),onClick:()=>{const I=t.print_name||t.filename||"model",ue=`${window.location.origin}${fe.getArchiveForSlicer(t.id,I)}`;Xc(ue)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(zd,{className:"w-4 h-4"}),onClick:()=>{const I=t.external_url||t.makerworld_url;I&&window.open(I,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>m(!0)},{label:"View Timelapse",icon:s.jsx(Ud,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(I1,{className:"w-4 h-4"}),onClick:()=>xe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||xe.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(D1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const I=document.createElement("a");I.href=fe.getSource3mfDownloadUrl(t.id),I.download=`${t.print_name||t.filename}_source.3mf`,I.click()}else ne.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(mi,{className:"w-4 h-4"}),onClick:()=>ne.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>Q(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Bs,{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=fe.getF3dDownloadUrl(t.id),I.download=`${t.print_name||t.filename}.f3d`,I.click()}},{label:"Remove F3D",icon:s.jsx(un,{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=fe.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()}},{label:"Copy Download Link",icon:s.jsx(ol,{className:"w-4 h-4"}),onClick:()=>{const I=`${window.location.origin}${fe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(I).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(_K,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(zf,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ya,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Hf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>le.mutate()},{label:"Edit",icon:s.jsx(sa,{className:"w-4 h-4"}),onClick:()=>S(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(Aa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(Aa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const I=[];if(t.project_id&&I.push({label:"Remove from Project",icon:s.jsx(Ht,{className:"w-4 h-4"}),onClick:()=>H.mutate(null)}),!a)I.push({label:"Loading...",icon:s.jsx(dt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const ue=a.filter(Ae=>Ae.status==="active");ue.length===0?I.push({label:"No projects available",icon:s.jsx(Aa,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):ue.forEach(Ae=>{I.push({label:Ae.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Ae.color||"#888"}}),onClick:()=>H.mutate(Ae.id),disabled:t.project_id===Ae.id})})}return I})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Oo,{className:"w-4 h-4"}):s.jsx(Lo,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(un,{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(Oo,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Lo,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?s.jsx("img",{src:fe.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(wy,{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 ue=I.currentTarget.getBoundingClientRect();V({x:ue.left,y:ue.bottom+4})},title:"Right-click for more options",children:s.jsx(Fd,{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(Hf,{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(ol,{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 ue=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Ae=`${window.location.origin}${fe.getSource3mfForSlicer(t.id,ue)}`;Xc(Ae)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(D1,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&s.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:I=>{I.stopPropagation(),window.location.href=fe.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(Bs,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&s.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:I=>{I.stopPropagation(),A(!0)},title:"View timelapse",children:s.jsx(Ud,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:I=>{I.stopPropagation(),O(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(zf,{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})]}),Ve&&Ve.length>0&&s.jsx(gs,{to:`/files?folder=${Ve[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: ${Ve[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(ll,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Mt,{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 ${cf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:cf(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:cf(t.filename)?"GCODE":"SOURCE"}),t.project_name&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(I=>I.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(I=>I.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Ob(t.print_time_seconds||0)}
- Actual: ${Ob(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Ob(t.actual_time_seconds)}`:`Estimated: ${Ob(t.print_time_seconds||0)}`,children:[s.jsx(Xn,{className:"w-3 h-3"}),Ob(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&s.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Ql,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(cl,{className:"w-3 h-3"}),t.total_layers&&s.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`${t.object_count} object${t.object_count>1?"s":""}`,children:[s.jsx(Bs,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((I,ue)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:I},title:I},ue))})]})]}),(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(SK,{className:"w-3 h-3"})}),t.tags?.split(",").map((I,ue)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:I.trim()},ue))]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[s.jsx("span",{children:yg(t.created_at,l)}),s.jsx("span",{children:GM(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[cf(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>b(!0),children:[s.jsx(Wr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const I=t.print_name||t.filename||"model",ue=`${window.location.origin}${fe.getArchiveForSlicer(t.id,I)}`;Xc(ue)},title:"Open in Bambu Studio",children:s.jsx(zr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Me,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const I=t.print_name||t.filename||"model",ue=`${window.location.origin}${fe.getArchiveForSlicer(t.id,I)}`;Xc(ue)},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(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const I=t.external_url||t.makerworld_url;I&&window.open(I,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?"External Link":t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"No external link",children:s.jsx(zd,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"3D Preview",children:s.jsx(Bs,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const I=document.createElement("a");I.href=fe.getArchiveDownload(t.id),I.download=`${t.print_name||t.filename}.3mf`,I.click()},title:"Download",children:s.jsx(Hr,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>S(!0),title:"Edit",children:s.jsx(sa,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:s.jsx(un,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&s.jsx(Ste,{archive:t,onClose:()=>S(!1)}),f&&s.jsx(yte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>m(!1)}),p&&s.jsx(oh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),y&&s.jsx(zn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{_e.mutate(),x(!1)},onCancel:()=>x(!1)}),G&&s.jsx(zn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{pe.mutate(),Q(!1)},onCancel:()=>Q(!1)}),te&&s.jsx(zn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Ee.mutate(),J(!1)},onCancel:()=>J(!1)}),z&&s.jsx(Mte,{x:z.x,y:z.y,items:B,onClose:()=>V(null)}),M&&t.timelapse_path&&s.jsx(fie,{src:fe.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),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children: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(Ud,{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:[GM(I.size),I.mtime&&` • ${yg(I.mtime,l)}`]})]})]},I.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Me,{variant:"secondary",onClick:()=>{k(!1),D([])},className:"w-full",children:"Cancel"})})]})}),C&&s.jsx(Nte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&t.photos.length>0&&s.jsx(Ete,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async I=>{try{await fe.deleteArchivePhoto(t.id,I),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),q&&s.jsx(hie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),W&&s.jsx(oh,{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 ue=I.target.files?.[0];ue&&he.mutate(ue),I.target.value=""}}),s.jsx("input",{ref:ae,type:"file",accept:".f3d",className:"hidden",onChange:I=>{const ue=I.target.files?.[0];ue&&ie.mutate(ue),I.target.value=""}})]})}function AKe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=on(),{showToast:c}=Gn(),[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,D]=w.useState([]),[C,R]=w.useState(!1),[U,O]=w.useState(!1),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[G,Q]=w.useState(!1),[te,J]=w.useState(null),z=w.useRef(null),V=w.useRef(null),ne=mt({mutationFn:X=>fe.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:()=>fe.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:X=>{c(X.message||"Failed to remove source 3MF","error")}}),he=mt({mutationFn:X=>fe.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")}}),pe=mt({mutationFn:()=>fe.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:X=>{c(X.message||"Failed to remove F3D","error")}}),ie=mt({mutationFn:()=>fe.scanArchiveTimelapse(t.id),onSuccess:X=>{X.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`)):X.status==="exists"?c("Timelapse already attached"):X.status==="not_found"&&X.available_files&&X.available_files.length>0?(D(X.available_files),k(!0)):c(X.message||"No matching timelapse found","warning")},onError:X=>{c(X.message||"Failed to scan for timelapse","error")}}),Ee=mt({mutationFn:X=>fe.selectArchiveTimelapse(t.id,X),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${X.filename}`),k(!1),D([])},onError:X=>{c(X.message||"Failed to attach timelapse","error")}}),xe=mt({mutationFn:()=>fe.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),Ne=mt({mutationFn:()=>fe.toggleFavorite(t.id),onSuccess:X=>{l.invalidateQueries({queryKey:["archives"]}),c(X.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:_e}=ut({queryKey:["archive-folders",t.id],queryFn:()=>fe.getLibraryFoldersByArchive(t.id)}),le=mt({mutationFn:X=>fe.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")}}),Ve=X=>{X.preventDefault(),J({x:X.clientX,y:X.clientY})},ee=[...cf(t.filename)?[{label:"Print",icon:s.jsx(Wr,{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}${fe.getArchiveForSlicer(t.id,X)}`;Xc(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}${fe.getArchiveForSlicer(t.id,X)}`;Xc(B)}}],{label:t.external_url?"External Link":"View on MakerWorld",icon:s.jsx(zd,{className:"w-4 h-4"}),onClick:()=>{const X=t.external_url||t.makerworld_url;X&&window.open(X,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>S(!0)},{label:"View Timelapse",icon:s.jsx(Ud,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(I1,{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(D1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const X=document.createElement("a");X.href=fe.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(mi,{className:"w-4 h-4"}),onClick:()=>z.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(un,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(Bs,{className:"w-4 h-4"}),onClick:()=>V.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=fe.getF3dDownloadUrl(t.id),X.download=`${t.print_name||t.filename}.f3d`,X.click()}},{label:"Remove F3D",icon:s.jsx(un,{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=fe.getArchiveDownload(t.id),X.download=`${t.print_name||t.filename}.3mf`,X.click()}},{label:"Copy Download Link",icon:s.jsx(ol,{className:"w-4 h-4"}),onClick:()=>{const X=`${window.location.origin}${fe.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(_K,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(zf,{className:"w-4 h-4"}),onClick:()=>O(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ya,{className:"w-4 h-4"}),onClick:()=>j(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(Hf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ne.mutate()},{label:"Edit",icon:s.jsx(sa,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(Aa,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(Aa,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const X=[];if(t.project_id&&X.push({label:"Remove from Project",icon:s.jsx(Ht,{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(Aa,{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(Oo,{className:"w-4 h-4"}):s.jsx(Lo,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(un,{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:Ve,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(Oo,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Lo,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:fe.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:s.jsx(wy,{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(Ud,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),_e&&_e.length>0&&s.jsx(gs,{to:`/files?folder=${_e[0].id}`,className:"flex-shrink-0",title:`Open folder: ${_e[0].name}`,onClick:X=>X.stopPropagation(),children:s.jsx(ll,{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:bg(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:GM(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const X=t.print_name||t.filename||"model",B=`${window.location.origin}${fe.getArchiveForSlicer(t.id,X)}`;Xc(B)},title:"Open in Bambu Studio",children:s.jsx(zr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?"External Link":"MakerWorld",children:s.jsx(zd,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{const X=document.createElement("a");X.href=fe.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(Me,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(sa,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>m(!0),title:"Delete",children:s.jsx(un,{className:"w-4 h-4 text-red-400"})}),s.jsx(Me,{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(Fd,{className:"w-4 h-4"})})]})]}),u&&s.jsx(Ste,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(yte,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>S(!1)}),p&&s.jsx(oh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),f&&s.jsx(zn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{xe.mutate(),m(!1)},onCancel:()=>m(!1)}),W&&s.jsx(zn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{ae.mutate(),K(!1)},onCancel:()=>K(!1)}),G&&s.jsx(zn,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{pe.mutate(),Q(!1)},onCancel:()=>Q(!1)}),te&&s.jsx(Mte,{x:te.x,y:te.y,items:ee,onClose:()=>J(null)}),M&&t.timelapse_path&&s.jsx(fie,{src:fe.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),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:E.map(X=>s.jsxs("button",{onClick:()=>Ee.mutate(X.name),disabled:Ee.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:X.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:GM(X.size)}),X.mtime&&s.jsx("span",{children:bg(X.mtime)})]})]},X.name))})]})}),C&&s.jsx(Nte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),U&&t.photos&&s.jsx(Ete,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>O(!1),onDelete:async X=>{try{await fe.deleteArchivePhoto(t.id,X),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),q&&s.jsx(hie,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>j(!1)}),y&&s.jsx(oh,{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:V,type:"file",accept:".f3d",className:"hidden",onChange:X=>{const B=X.target.files?.[0];B&&he.mutate(B),X.target.value=""}})]})}const TKe=[{id:"all",label:"All Archives",icon:s.jsx(ll,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(Xn,{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(Hf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(aa,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(ol,{className:"w-4 h-4"})}];function CKe(){const t=on(),{showToast:e}=Gn(),n=w.useRef(null),[r,i]=w.useState(""),[a,o]=w.useState(()=>{const re=localStorage.getItem("archiveFilterPrinter");return re?Number(re):null}),[l,c]=w.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=w.useState(()=>{const re=localStorage.getItem("archiveFilterColors");return re?new Set(JSON.parse(re)):new Set}),[f,m]=w.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,b]=w.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[y,x]=w.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,S]=w.useState(()=>localStorage.getItem("archiveFilterTag")),[M,A]=w.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[T,k]=w.useState(!1),[E,D]=w.useState([]),[C,R]=w.useState(!1),[U,O]=w.useState(new Set),[q,j]=w.useState(!1),[W,K]=w.useState(!1),[G,Q]=w.useState(!1),[te,J]=w.useState(!1),[z,V]=w.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ne,ae]=w.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[he,pe]=w.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ie,Ee]=w.useState(!1),[xe,Ne]=w.useState(!1),[_e,le]=w.useState(!1),[Ve,H]=w.useState(null);w.useEffect(()=>{if(Ve){const re=setTimeout(()=>{const ve=document.querySelector(`[data-archive-id="${Ve}"]`);ve&&ve.scrollIntoView({behavior:"smooth",block:"center"})},100),ke=setTimeout(()=>H(null),5e3);return()=>{clearTimeout(re),clearTimeout(ke)}}},[Ve]);const{data:ee,isLoading:X}=ut({queryKey:["archives",a],queryFn:()=>fe.getArchives(a||void 0)}),{data:B}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:I}=ut({queryKey:["projects"],queryFn:()=>fe.getProjects()}),{data:ue}=ut({queryKey:["settings"],queryFn:fe.getSettings}),Ae=ue?.time_format||"system",Ie=mt({mutationFn:async re=>(await Promise.all(re.map(ke=>fe.deleteArchive(ke))),re.length),onSuccess:re=>{t.invalidateQueries({queryKey:["archives"]}),O(new Set),e(`${re} archive${re!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});w.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),w.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),w.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),w.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),w.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),w.useEffect(()=>{localStorage.setItem("archiveHideFailed",y.toString())},[y]),w.useEffect(()=>{v?localStorage.setItem("archiveFilterTag",v):localStorage.removeItem("archiveFilterTag")},[v]),w.useEffect(()=>{localStorage.setItem("archiveFilterFileType",M)},[M]),w.useEffect(()=>{localStorage.setItem("archiveViewMode",z)},[z]),w.useEffect(()=>{localStorage.setItem("archiveSortBy",ne)},[ne]),w.useEffect(()=>{localStorage.setItem("archiveCollection",he)},[he]);const ce=new Map(B?.map(re=>[re.id,re.name])||[]),$=[...new Set(ee?.flatMap(re=>re.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),L=[...new Set(ee?.flatMap(re=>re.filament_color?.split(",")||[]).filter(Boolean)||[])],Y=[...new Set(ee?.flatMap(re=>re.tags?.split(",").map(ke=>ke.trim())||[]).filter(Boolean)||[])].sort(),be=ee?.filter(re=>{const ke=new Date,ve=Mi(re.created_at)||new Date(0);let Fe=!0;switch(he){case"recent":Fe=ke.getTime()-ve.getTime()<1440*60*1e3;break;case"this-week":Fe=ke.getTime()-ve.getTime()<10080*60*1e3;break;case"this-month":Fe=ve.getMonth()===ke.getMonth()&&ve.getFullYear()===ke.getFullYear();break;case"favorites":Fe=re.is_favorite===!0;break;case"failed":Fe=re.status==="failed"||re.status==="aborted";break;case"duplicates":Fe=re.duplicate_count>0;break}const Ue=(re.print_name||re.filename).toLowerCase().includes(r.toLowerCase()),Te=!l||re.filament_type?.split(", ").includes(l),qe=re.filament_color?.split(",")||[],bt=u.size===0||(f==="or"?qe.some(Kt=>u.has(Kt)):[...u].every(Kt=>qe.includes(Kt))),Pt=he==="favorites"||!p||re.is_favorite,Ot=he==="failed"||!y||re.status!=="failed"&&re.status!=="aborted",ln=re.tags?.split(",").map(Kt=>Kt.trim())||[],Gt=!v||ln.includes(v),vn=cf(re.filename);return Fe&&Ue&&Te&&bt&&Pt&&Ot&&Gt&&(M==="all"||M==="gcode"&&vn||M==="source"&&!vn)}).sort((re,ke)=>{switch(ne){case"date-desc":return(Mi(ke.created_at)?.getTime()||0)-(Mi(re.created_at)?.getTime()||0);case"date-asc":return(Mi(re.created_at)?.getTime()||0)-(Mi(ke.created_at)?.getTime()||0);case"name-asc":return(re.print_name||re.filename).localeCompare(ke.print_name||ke.filename);case"name-desc":return(ke.print_name||ke.filename).localeCompare(re.print_name||re.filename);case"size-desc":return ke.file_size-re.file_size;case"size-asc":return re.file_size-ke.file_size;default:return 0}}),Se=q||U.size>0,se=re=>{O(ke=>{const ve=new Set(ke);return ve.has(re)?ve.delete(re):ve.add(re),ve})},Pe=()=>{be&&O(new Set(be.map(re=>re.id)))},Re=()=>{O(new Set),j(!1)},Xe=re=>{d(ke=>{const ve=new Set(ke);return ve.has(re)?ve.delete(re):ve.add(re),ve})},et=()=>{d(new Set)},Je=()=>{i(""),o(null),c(null),b(!1),x(!1),S(null),A("all")},oe=r||a||l||p||y||v||M!=="all",ye=w.useCallback(re=>{re.preventDefault(),re.dataTransfer.types.includes("Files")&&R(!0)},[]),je=w.useCallback(re=>{re.preventDefault(),re.currentTarget===re.target&&R(!1)},[]),$e=w.useCallback(re=>{re.preventDefault(),R(!1);const ke=Array.from(re.dataTransfer.files).filter(ve=>ve.name.endsWith(".3mf"));ke.length>0?(D(ke),k(!0)):re.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ft=w.useCallback(re=>{const ke=re.target;if(ke.tagName==="INPUT"||ke.tagName==="TEXTAREA"||ke.isContentEditable){re.key==="Escape"&&ke.blur();return}switch(re.key){case"/":re.preventDefault(),n.current?.focus();break;case"u":case"U":!re.metaKey&&!re.ctrlKey&&(re.preventDefault(),k(!0));break;case"Escape":Se&&Re();break}},[Se]);return w.useEffect(()=>(document.addEventListener("keydown",ft),()=>document.removeEventListener("keydown",ft)),[ft]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:ye,onDragLeave:je,onDrop:$e,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(mi,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),Se&&s.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Re,children:[s.jsx(Ht,{className:"w-4 h-4"}),"Close"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("span",{className:"text-white font-medium",children:[U.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Pe,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Q(!0),children:[s.jsx(xg,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>J(!0),children:[s.jsx(Aa,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>{const re=Array.from(U);Promise.all(re.map(ke=>fe.toggleFavorite(ke))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${re.length} archive${re.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(Hf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Me,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>K(!0),children:[s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:he,onChange:re=>pe(re.target.value),children:TKe.map(re=>s.jsx("option",{value:re.id,children:re.label},re.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[be?.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(Me,{variant:"secondary",onClick:()=>Ee(!ie),disabled:xe,children:[xe?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(O1,{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()=>{Ee(!1),Ne(!0);try{const{blob:re,filename:ke}=await fe.exportArchives({format:"csv",printerId:a||void 0,status:he==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(re),Fe=document.createElement("a");Fe.href=ve,Fe.download=ke,Fe.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{Ne(!1)}},children:[s.jsx(Ya,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{Ee(!1),Ne(!0);try{const{blob:re,filename:ke}=await fe.exportArchives({format:"xlsx",printerId:a||void 0,status:he==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(re),Fe=document.createElement("a");Fe.href=ve,Fe.download=ke,Fe.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{Ne(!1)}},children:[s.jsx(O1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),U.size>=2&&U.size<=5&&s.jsxs(Me,{variant:"secondary",onClick:()=>le(!0),children:[s.jsx(eg,{className:"w-4 h-4"}),"Compare (",U.size,")"]}),!Se&&s.jsxs(Me,{variant:"secondary",onClick:()=>j(!0),children:[s.jsx(Oo,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(mi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(St,{className:"mb-6",children:s.jsxs(Mt,{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(Na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:re=>i(re.target.value)})]}),s.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(iN,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:re=>o(re.target.value?Number(re.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),B?.map(re=>s.jsx("option",{value:re.id,children:re.name},re.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Ql,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:l||"",onChange:re=>c(re.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),$.map(re=>s.jsx("option",{value:re,children:re},re))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(D1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:M,onChange:re=>A(re.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>b(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[s.jsx(Hf,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>x(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[s.jsx(aa,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Y.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(xg,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v||"",onChange:re=>S(re.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),Y.map(re=>s.jsx("option",{value:re,children:re},re))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(dK,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:ne,onChange:re=>ae(re.target.value),children:[s.jsx("option",{value:"date-desc",children:"Newest first"}),s.jsx("option",{value:"date-asc",children:"Oldest first"}),s.jsx("option",{value:"name-asc",children:"Name A-Z"}),s.jsx("option",{value:"name-desc",children:"Name Z-A"}),s.jsx("option",{value:"size-desc",children:"Largest first"}),s.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${z==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("grid"),title:"Grid view",children:s.jsx(lN,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("list"),title:"List view",children:s.jsx(cN,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${z==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("calendar"),title:"Calendar view",children:s.jsx(Jue,{className:"w-4 h-4"})})]})]}),oe&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:Je,className:"text-bambu-gray hover:text-white",children:[s.jsx(Ht,{className:"w-4 h-4"}),"Reset"]})]}),L.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&s.jsx("button",{onClick:()=>m(re=>re==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:L.map(re=>s.jsx("button",{onClick:()=>Xe(re),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(re)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:re},title:re},re))}),u.size>0&&s.jsxs("button",{onClick:et,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Ht,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(NKe,{}),X?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):be?.length===0?s.jsx(St,{children:s.jsxs(Mt,{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:be||[],onArchiveClick:re=>{i(""),V("grid"),H(re.id)},highlightedArchiveId:Ve})}):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:be?.map(re=>s.jsx(EKe,{archive:re,printerName:re.printer_id?ce.get(re.printer_id)||"Unknown":"No Printer",isSelected:U.has(re.id),onSelect:se,selectionMode:Se,projects:I,isHighlighted:re.id===Ve,timeFormat:Ae},re.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"})]}),be?.map(re=>s.jsx(AKe,{archive:re,printerName:re.printer_id?ce.get(re.printer_id)||"Unknown":"No Printer",isSelected:U.has(re.id),onSelect:se,selectionMode:Se,projects:I,isHighlighted:re.id===Ve},re.id))]})}):null,T&&s.jsx(s$e,{onClose:()=>{k(!1),D([])},initialFiles:E}),W&&s.jsx(zn,{title:"Delete Archives",message:`Are you sure you want to delete ${U.size} archive${U.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${U.size}`,variant:"danger",onConfirm:()=>{Ie.mutate(Array.from(U)),K(!1)},onCancel:()=>K(!1)}),G&&s.jsx(c$e,{selectedIds:Array.from(U),existingTags:Y,onClose:()=>Q(!1)}),te&&s.jsx(u$e,{selectedIds:Array.from(U),onClose:()=>J(!1)}),_e&&U.size>=2&&U.size<=5&&s.jsx(vKe,{archiveIds:Array.from(U),onClose:()=>{le(!1),O(new Set),j(!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 DE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function dI(t){return"nodeType"in t}function Ts(t){var e,n;return t?mx(t)?t:dI(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function hI(t){const{Document:e}=Ts(t);return t instanceof e}function tv(t){return mx(t)?!1:t instanceof Ts(t).HTMLElement}function mie(t){return t instanceof Ts(t).SVGElement}function px(t){return t?mx(t)?t.document:dI(t)?hI(t)?t:tv(t)||mie(t)?t.ownerDocument:document:document:document}const oc=DE?w.useLayoutEffect:w.useEffect;function fI(t){const e=w.useRef(t);return oc(()=>{e.current=t}),w.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function 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 py(t,e){e===void 0&&(e=[t]);const n=w.useRef(t);return oc(()=>{n.current!==t&&(n.current=t)},e),n}function nv(t,e){const n=w.useRef();return w.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function WM(t){const e=fI(t),n=w.useRef(null),r=w.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function mD(t){const e=w.useRef();return w.useEffect(()=>{e.current=t},[t]),e.current}let Bj={};function rv(t,e){return w.useMemo(()=>{if(e)return e;const n=Bj[t]==null?0:Bj[t]+1;return Bj[t]=n,t+"-"+n},[t,e])}function pie(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 mg=pie(1),gy=pie(-1);function PKe(t){return"clientX"in t&&"clientY"in t}function mI(t){if(!t)return!1;const{KeyboardEvent:e}=Ts(t.target);return e&&t instanceof e}function RKe(t){if(!t)return!1;const{TouchEvent:e}=Ts(t.target);return e&&t instanceof e}function pD(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 Vg=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[Vg.Translate.toString(t),Vg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),ZW="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(ZW)?t:t.querySelector(ZW)}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 gie=w.createContext(null);function UKe(t){const e=w.useContext(gie);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=rv("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?Zc.createPortal(d,n):d}var Ri;(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"})(Ri||(Ri={}));function qM(){}function KM(t,e){return w.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function xie(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return w.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const fl=Object.freeze({x:0,y:0});function bie(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function yie(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 QW(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 vie(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function JW(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const _ie=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=JW(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=bie(JW(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(yie)},GKe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=QW(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=QW(c),d=i.reduce((m,p,b)=>m+bie(u[b],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(yie)};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 wie(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:fl}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 gx(t,e){e===void 0&&(e=JKe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Ts(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 eq(t){return gx(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=Ts(t).getComputedStyle(t)),e.position==="fixed"}function nXe(t,e){e===void 0&&(e=Ts(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function OE(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(hI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!tv(i)||mie(i)||n.includes(i))return n;const a=Ts(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 Sie(t){const[e]=OE(t,1);return e??null}function $j(t){return!DE||!t?null:mx(t)?t:dI(t)?hI(t)||t===px(t).scrollingElement?window:tv(t)?t:null:null}function Mie(t){return mx(t)?t.scrollX:t.scrollLeft}function Nie(t){return mx(t)?t.scrollY:t.scrollTop}function gD(t){return{x:Mie(t),y:Nie(t)}}var Zi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Zi||(Zi={}));function Eie(t){return!DE||!t?!1:t===document.scrollingElement}function Aie(t){const e={x:0,y:0},n=Eie(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}=Aie(t),p={x:0,y:0},b={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+y.height?(p.y=Zi.Backward,b.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Zi.Forward,b.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!m&&l>=e.right-y.width?(p.x=Zi.Forward,b.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(p.x=Zi.Backward,b.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:b}}function 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 Tie(t){return t.reduce((e,n)=>mg(e,gD(n)),fl)}function sXe(t){return t.reduce((e,n)=>e+Mie(n),0)}function oXe(t){return t.reduce((e,n)=>e+Nie(n),0)}function lXe(t,e){if(e===void 0&&(e=gx),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Sie(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 pI{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=OE(n),i=Tie(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 v0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function uXe(t){const{EventTarget:e}=Ts(t);return t instanceof e?t:px(t)}function Hj(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var wo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(wo||(wo={}));function tq(t){t.preventDefault()}function dXe(t){t.stopPropagation()}var Fn;(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"})(Fn||(Fn={}));const Cie={start:[Fn.Space,Fn.Enter],cancel:[Fn.Esc],end:[Fn.Space,Fn.Enter,Fn.Tab]},hXe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Fn.Right:return{...n,x:n.x+25};case Fn.Left:return{...n,x:n.x-25};case Fn.Down:return{...n,y:n.y+25};case Fn.Up:return{...n,y:n.y-25}}};class LE{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new v0(px(n)),this.windowListeners=new v0(Ts(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(wo.Resize,this.handleCancel),this.windowListeners.add(wo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(wo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&lXe(r),n(fl)}handleKeyDown(e){if(mI(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Cie,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}:fl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const m=gy(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}=Aie(y),E=aXe(y),D={x:Math.min(x===Fn.Right?E.right-E.width/2:E.right,Math.max(x===Fn.Right?E.left:E.left+E.width/2,f.x)),y:Math.min(x===Fn.Down?E.bottom-E.height/2:E.bottom,Math.max(x===Fn.Down?E.top:E.top+E.height/2,f.y))},C=x===Fn.Right&&!S||x===Fn.Left&&!M,R=x===Fn.Down&&!A||x===Fn.Up&&!v;if(C&&D.x!==f.x){const U=y.scrollLeft+m.x,O=x===Fn.Right&&U<=T.x||x===Fn.Left&&U>=k.x;if(O&&!m.y){y.scrollTo({left:U,behavior:l});return}O?p.x=y.scrollLeft-U:p.x=x===Fn.Right?y.scrollLeft-T.x:y.scrollLeft-k.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(R&&D.y!==f.y){const U=y.scrollTop+m.y,O=x===Fn.Down&&U<=T.y||x===Fn.Up&&U>=k.y;if(O&&!m.x){y.scrollTo({top:U,behavior:l});return}O?p.y=y.scrollTop-U:p.y=x===Fn.Down?y.scrollTop-T.y:y.scrollTop-k.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,mg(gy(f,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}LE.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Cie,onActivation:i}=e,{active:a}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function nq(t){return!!(t&&"distance"in t)}function rq(t){return!!(t&&"delay"in t)}class gI{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=px(o),this.documentListeners=new v0(this.document),this.listeners=new v0(r),this.windowListeners=new v0(Ts(o)),this.initialCoordinates=(i=pD(a))!=null?i:fl,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(wo.Resize,this.handleCancel),this.windowListeners.add(wo.DragStart,tq),this.windowListeners.add(wo.VisibilityChange,this.handleCancel),this.windowListeners.add(wo.ContextMenu,tq),this.documentListeners.add(wo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(rq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(nq(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(wo.Click,dXe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(wo.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=pD(e))!=null?n:fl,u=gy(i,c);if(!r&&l){if(nq(l)){if(l.tolerance!=null&&Hj(u,l.tolerance))return this.handleCancel();if(Hj(u,l.distance))return this.handleStart()}if(rq(l)&&Hj(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(c)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Fn.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 IE extends gI{constructor(e){const{event:n}=e,r=px(n.target);super(e,fXe,r)}}IE.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const mXe={move:{name:"mousemove"},end:{name:"mouseup"}};var xD;(function(t){t[t.RightClick=2]="RightClick"})(xD||(xD={}));class pXe extends gI{constructor(e){super(e,mXe,px(e.event.target))}}pXe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===xD.RightClick?!1:(r?.({event:n}),!0)}}];const Vj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class gXe extends gI{constructor(e){super(e,Vj)}static setup(){return window.addEventListener(Vj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Vj.move.name,e)};function e(){}}}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 _0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(_0||(_0={}));var XM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(XM||(XM={}));function xXe(t){let{acceleration:e,activator:n=_0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=XM.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 _0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case _0.DraggableRect:return i}},[n,i,c]),M=w.useRef(null),A=w.useCallback(()=>{const k=M.current;if(!k)return;const E=x.current.x*v.current.x,D=x.current.y*v.current.y;k.scrollBy(E,D)},[]),T=w.useMemo(()=>l===XM.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),D=d[E];if(!D)continue;const{direction:C,speed:R}=iXe(k,D,S,e,m);for(const U of["x","y"])p[U][C[U]]||(R[U]=0,C[U]=0);if(R.x>0||R.y>0){y(),M.current=k,b(A,o),x.current=R,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:{[Zi.Backward]:!1,[Zi.Forward]:!1},y:{[Zi.Backward]:!1,[Zi.Forward]:!1}};function yXe(t){let{delta:e,disabled:n}=t;const r=mD(e);return nv(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:{[Zi.Backward]:i.x[Zi.Backward]||a.x===-1,[Zi.Forward]:i.x[Zi.Forward]||a.x===1},y:{[Zi.Backward]:i.y[Zi.Backward]||a.y===-1,[Zi.Forward]:i.y[Zi.Forward]||a.y===1}}},[n,e,r])}function vXe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return nv(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 xy;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(xy||(xy={}));var bD;(function(t){t.Optimized="optimized"})(bD||(bD={}));const iq=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=py(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=nv(v=>{if(f&&!n)return iq;if(!v||v===iq||d.current!==t||a!=null){const S=new Map;for(let M of t){if(!M)continue;if(a&&a.length>0&&!a.includes(M.id)&&M.rect.current){S.set(M.id,M.rect.current);continue}const A=M.node.current,T=A?new pI(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 xy.Always:return!1;case xy.BeforeDragging:return n;default:return!n}}}function kie(t,e){return nv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function SXe(t,e){return kie(t,e)}function MXe(t){let{callback:e,disabled:n}=t;const r=fI(e),i=w.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return w.useEffect(()=>()=>i?.disconnect(),[i]),i}function FE(t){let{callback:e,disabled:n}=t;const r=fI(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 pI(gx(t),t)}function aq(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=FE({callback:a});return oc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function EXe(t){const e=kie(t);return wie(t,e)}const sq=[];function AXe(t){const e=w.useRef(t),n=nv(r=>t?r&&r!==sq&&t&&e.current&&t.parentNode===e.current.parentNode?r:OE(t):sq,[t]);return w.useEffect(()=>{e.current=t},[t]),n}function TXe(t){const[e,n]=w.useState(null),r=w.useRef(t),i=w.useCallback(a=>{const o=$j(a.target);o&&n(l=>l?(l.set(o,gD(o)),new Map(l)):null)},[]);return w.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=$j(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,gD(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(a)};function o(l){l.forEach(c=>{const u=$j(c);u?.removeEventListener("scroll",i)})}},[i,t]),w.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>mg(a,o),fl):Tie(t):fl,[t,e])}function oq(t,e){e===void 0&&(e=[]);const n=w.useRef(null);return w.useEffect(()=>{n.current=null},e),w.useEffect(()=>{const r=t!==fl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?gy(t,n.current):fl}function CXe(t){w.useEffect(()=>{if(!DE)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function 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 jie(t){return w.useMemo(()=>t?eXe(t):null,[t])}const lq=[];function jXe(t,e){e===void 0&&(e=gx);const[n]=t,r=jie(n?Ts(n):null),[i,a]=w.useState(lq);function o(){a(()=>t.length?t.map(c=>Eie(c)?r:new pI(e(c),c)):lq)}const l=FE({callback:o});return oc(()=>{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 tv(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(tv(d)){r(f=>{const m=e(d);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=FE({callback:i}),o=w.useCallback(u=>{const d=PXe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=WM(o);return w.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const DXe=[{sensor:IE,options:{}},{sensor:LE,options:{}}],OXe={current:{}},E1={draggable:{measure:eq},droppable:{measure:eq,strategy:xy.WhileDragging,frequency:bD.Optimized},dragOverlay:{measure:gx}};class w0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const LXe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new w0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:qM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:E1,measureDroppableContainers:qM,windowRect:null,measuringScheduled:!1},IXe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:qM,draggableNodes:new Map,over:null,measureDroppableContainers:qM},UE=w.createContext(IXe),Pie=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 w0}}}function UXe(t,e){switch(e.type){case Ri.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ri.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 Ri.DragEnd:case Ri.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ri.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new w0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Ri.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new w0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Ri.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new w0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function zXe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=w.useContext(UE),a=mD(r),o=mD(n?.id);return w.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!mI(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:{...E1.draggable,...t?.draggable},droppable:{...E1.droppable,...t?.droppable},dragOverlay:{...E1.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;oc(()=>{if(!o&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=wie(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=Sie(u);m&&m.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const Rie=w.createContext({...fl,scaleX:1,scaleY:1});var Md;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Md||(Md={}));const Die=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(Md.Uninitialized),k=A===Md.Initialized,{draggable:{active:E,nodes:D,translate:C},droppable:{containers:R}}=x,U=E!=null?D.get(E):null,O=w.useRef({initial:null,translated:null}),q=w.useMemo(()=>{var Fe;return E!=null?{id:E,data:(Fe=U?.data)!=null?Fe:OXe,rect:O}:null},[E,U]),j=w.useRef(null),[W,K]=w.useState(null),[G,Q]=w.useState(null),te=py(b,Object.values(b)),J=rv("DndDescribedBy",o),z=w.useMemo(()=>R.getEnabled(),[R]),V=$Xe(m),{droppableRects:ne,measureDroppableContainers:ae,measuringScheduled:he}=wXe(z,{dragging:k,dependencies:[C.x,C.y],config:V.droppable}),pe=vXe(D,E),ie=w.useMemo(()=>G?pD(G):null,[G]),Ee=ve(),xe=SXe(pe,V.draggable.measure);HXe({activeNode:E!=null?D.get(E):null,config:Ee.layoutShiftCompensation,initialRect:xe,measure:V.draggable.measure});const Ne=aq(pe,V.draggable.measure,xe),_e=aq(pe?pe.parentElement:null),le=w.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ve=R.getNodeFor((n=le.current.over)==null?void 0:n.id),H=RXe({measure:V.dragOverlay.measure}),ee=(r=H.nodeRef.current)!=null?r:pe,X=k?(i=H.rect)!=null?i:Ne:null,B=!!(H.nodeRef.current&&H.rect),I=EXe(B?null:Ne),ue=jie(ee?Ts(ee):null),Ae=AXe(k?Ve??pe:null),Ie=jXe(Ae),ce=BXe(p,{transform:{x:C.x-I.x,y:C.y-I.y,scaleX:1,scaleY:1},activatorEvent:G,active:q,activeNodeRect:Ne,containerNodeRect:_e,draggingNodeRect:X,over:le.current.over,overlayNodeRect:H.rect,scrollableAncestors:Ae,scrollableAncestorRects:Ie,windowRect:ue}),$=ie?mg(ie,C):null,L=TXe(Ae),Y=oq(L),be=oq(L,[Ne]),Se=mg(ce,Y),se=X?YKe(X,ce):null,Pe=q&&se?f({active:q,collisionRect:se,droppableRects:ne,droppableContainers:z,pointerCoordinates:$}):null,Re=vie(Pe,"id"),[Xe,et]=w.useState(null),Je=B?ce:mg(ce,be),oe=KKe(Je,(a=Xe?.rect)!=null?a:null,Ne),ye=w.useRef(null),je=w.useCallback((Fe,Ue)=>{let{sensor:Te,options:qe}=Ue;if(j.current==null)return;const bt=D.get(j.current);if(!bt)return;const Pt=Fe.nativeEvent,Ot=new Te({active:j.current,activeNode:bt,event:Pt,options:qe,context:le,onAbort(Gt){if(!D.get(Gt))return;const{onDragAbort:gt}=te.current,Kt={id:Gt};gt?.(Kt),S({type:"onDragAbort",event:Kt})},onPending(Gt,vn,gt,Kt){if(!D.get(Gt))return;const{onDragPending:Et}=te.current,Ln={id:Gt,constraint:vn,initialCoordinates:gt,offset:Kt};Et?.(Ln),S({type:"onDragPending",event:Ln})},onStart(Gt){const vn=j.current;if(vn==null)return;const gt=D.get(vn);if(!gt)return;const{onDragStart:Kt}=te.current,pn={activatorEvent:Pt,active:{id:vn,data:gt.data,rect:O}};Zc.unstable_batchedUpdates(()=>{Kt?.(pn),T(Md.Initializing),v({type:Ri.DragStart,initialCoordinates:Gt,active:vn}),S({type:"onDragStart",event:pn}),K(ye.current),Q(Pt)})},onMove(Gt){v({type:Ri.DragMove,coordinates:Gt})},onEnd:ln(Ri.DragEnd),onCancel:ln(Ri.DragCancel)});ye.current=Ot;function ln(Gt){return async function(){const{active:gt,collisions:Kt,over:pn,scrollAdjustedTranslate:Et}=le.current;let Ln=null;if(gt&&Et){const{cancelDrop:Nr}=te.current;Ln={activatorEvent:Pt,active:gt,collisions:Kt,delta:Et,over:pn},Gt===Ri.DragEnd&&typeof Nr=="function"&&await Promise.resolve(Nr(Ln))&&(Gt=Ri.DragCancel)}j.current=null,Zc.unstable_batchedUpdates(()=>{v({type:Gt}),T(Md.Uninitialized),et(null),K(null),Q(null),ye.current=null;const Nr=Gt===Ri.DragEnd?"onDragEnd":"onDragCancel";if(Ln){const Or=te.current[Nr];Or?.(Ln),S({type:Nr,event:Ln})}})}}},[D]),$e=w.useCallback((Fe,Ue)=>(Te,qe)=>{const bt=Te.nativeEvent,Pt=D.get(qe);if(j.current!==null||!Pt||bt.dndKit||bt.defaultPrevented)return;const Ot={active:Pt};Fe(Te,Ue.options,Ot)===!0&&(bt.dndKit={capturedBy:Ue.sensor},j.current=qe,je(Te,Ue))},[D,je]),ft=_Xe(d,$e);CXe(d),oc(()=>{Ne&&A===Md.Initializing&&T(Md.Initialized)},[Ne,A]),w.useEffect(()=>{const{onDragMove:Fe}=te.current,{active:Ue,activatorEvent:Te,collisions:qe,over:bt}=le.current;if(!Ue||!Te)return;const Pt={active:Ue,activatorEvent:Te,collisions:qe,delta:{x:Se.x,y:Se.y},over:bt};Zc.unstable_batchedUpdates(()=>{Fe?.(Pt),S({type:"onDragMove",event:Pt})})},[Se.x,Se.y]),w.useEffect(()=>{const{active:Fe,activatorEvent:Ue,collisions:Te,droppableContainers:qe,scrollAdjustedTranslate:bt}=le.current;if(!Fe||j.current==null||!Ue||!bt)return;const{onDragOver:Pt}=te.current,Ot=qe.get(Re),ln=Ot&&Ot.rect.current?{id:Ot.id,rect:Ot.rect.current,data:Ot.data,disabled:Ot.disabled}:null,Gt={active:Fe,activatorEvent:Ue,collisions:Te,delta:{x:bt.x,y:bt.y},over:ln};Zc.unstable_batchedUpdates(()=>{et(ln),Pt?.(Gt),S({type:"onDragOver",event:Gt})})},[Re]),oc(()=>{le.current={activatorEvent:G,active:q,activeNode:pe,collisionRect:se,collisions:Pe,droppableRects:ne,draggableNodes:D,draggingNode:ee,draggingNodeRect:X,droppableContainers:R,over:Xe,scrollableAncestors:Ae,scrollAdjustedTranslate:Se},O.current={initial:X,translated:se}},[q,pe,Pe,se,D,ee,X,ne,R,Xe,Ae,Se]),xXe({...Ee,delta:C,draggingRect:se,pointerCoordinates:$,scrollableAncestors:Ae,scrollableAncestorRects:Ie});const re=w.useMemo(()=>({active:q,activeNode:pe,activeNodeRect:Ne,activatorEvent:G,collisions:Pe,containerNodeRect:_e,dragOverlay:H,draggableNodes:D,droppableContainers:R,droppableRects:ne,over:Xe,measureDroppableContainers:ae,scrollableAncestors:Ae,scrollableAncestorRects:Ie,measuringConfiguration:V,measuringScheduled:he,windowRect:ue}),[q,pe,Ne,G,Pe,_e,H,D,R,ne,Xe,ae,Ae,Ie,V,he,ue]),ke=w.useMemo(()=>({activatorEvent:G,activators:ft,active:q,activeNodeRect:Ne,ariaDescribedById:{draggable:J},dispatch:v,draggableNodes:D,over:Xe,measureDroppableContainers:ae}),[G,ft,q,Ne,v,J,D,Xe,ae]);return Ur.createElement(gie.Provider,{value:M},Ur.createElement(UE.Provider,{value:ke},Ur.createElement(Pie.Provider,{value:re},Ur.createElement(Rie.Provider,{value:oe},u)),Ur.createElement(zXe,{disabled:l?.restoreFocus===!1})),Ur.createElement(HKe,{...l,hiddenTextDescribedById:J}));function ve(){const Fe=W?.autoScrollEnabled===!1,Ue=typeof c=="object"?c.enabled===!1:c===!1,Te=k&&!Fe&&!Ue;return typeof c=="object"?{...c,enabled:Te}:{enabled:Te}}}),VXe=w.createContext(null),cq="button",GXe="Draggable";function WXe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=rv(GXe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:m}=w.useContext(UE),{role:p=cq,roleDescription:b="draggable",tabIndex:y=0}=i??{},x=c?.id===e,v=w.useContext(x?Rie:VXe),[S,M]=WM(),[A,T]=WM(),k=kXe(o,e),E=py(n);oc(()=>(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 D=w.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":x&&p===cq?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,p,y,x,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:x,listeners:r?void 0:k,node:S,over:m,setNodeRef:M,setActivatorNodeRef:T,transform:v}}function qXe(){return w.useContext(Pie)}const KXe="Droppable",XXe={timeout:25};function YXe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=rv(KXe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=w.useContext(UE),d=w.useRef({disabled:n}),f=w.useRef(!1),m=w.useRef(null),p=w.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:x}={...XXe,...i},v=py(y??r),S=w.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},x)},[x]),M=FE({callback:S,disabled:b||!o}),A=w.useCallback((D,C)=>{M&&(C&&(M.unobserve(C),f.current=!1),D&&M.observe(D))},[M]),[T,k]=WM(A),E=py(e);return w.useEffect(()=>{!M||!T.current||(M.disconnect(),f.current=!1,M.observe(T.current))},[T,M]),w.useEffect(()=>(l({type:Ri.RegisterDroppable,element:{id:r,key:a,disabled:n,node:T,rect:m,data:E}}),()=>l({type:Ri.UnregisterDroppable,key:a,id:r})),[r]),w.useEffect(()=>{n!==d.current.disabled&&(l({type:Ri.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 zE(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function ZXe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function Kw(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 xI=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=zE(e,r,n),o=e[i],l=a[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},Xw={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,...Xw}:null}const c=tYe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...Xw}:i<n&&i>=o?{x:0,y:l.height+c,...Xw}:{x:0,y:0,...Xw}};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 Oie="Sortable",Lie=Ur.createContext({activeIndex:-1,containerId:Oie,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:xI,disabled:{draggable:!1,droppable:!1}});function Iie(t){let{children:e,id:n,items:r,strategy:i=xI,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=qXe(),f=rv(Oie,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);oc(()=>{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(Lie.Provider,{value:T},e)}const nYe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return zE(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"},Fie="transform",aYe=Vg.Transition.toString({property:Fie,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 oc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=gx(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),w.useEffect(()=>{a&&o(null)},[a]),a}function Uie(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(Lie),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:D,isOver:C,setNodeRef:R}=YXe({id:o,data:T,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:k,...c}}),{active:U,activatorEvent:O,activeNodeRect:q,attributes:j,setNodeRef:W,listeners:K,isDragging:G,over:Q,setActivatorNodeRef:te,transform:J}=WXe({id:o,data:T,attributes:{...sYe,...n},disabled:M.draggable}),z=kKe(R,W),V=!!U,ne=V&&!b&&Kw(m)&&Kw(x),ae=!v&&G,he=ae&&ne?J:null,ie=ne?he??(l??S)({rects:y,activeNodeRect:q,activeIndex:m,overIndex:x,index:A}):null,Ee=Kw(m)&&Kw(x)?a({id:o,items:d,activeIndex:m,overIndex:x}):A,xe=U?.id,Ne=w.useRef({activeId:xe,items:d,newIndex:Ee,containerId:f}),_e=d!==Ne.current.items,le=e({active:U,containerId:f,isDragging:G,isSorting:V,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}),Ve=oYe({disabled:!le,index:A,node:D,rect:E});return w.useEffect(()=>{V&&Ne.current.newIndex!==Ee&&(Ne.current.newIndex=Ee),f!==Ne.current.containerId&&(Ne.current.containerId=f),d!==Ne.current.items&&(Ne.current.items=d)},[V,Ee,f,d]),w.useEffect(()=>{if(xe===Ne.current.activeId)return;if(xe!=null&&Ne.current.activeId==null){Ne.current.activeId=xe;return}const ee=setTimeout(()=>{Ne.current.activeId=xe},50);return()=>clearTimeout(ee)},[xe]),{active:U,activeIndex:m,attributes:j,data:T,rect:E,index:A,newIndex:Ee,items:d,isOver:C,isSorting:V,isDragging:G,listeners:K,node:D,overIndex:x,over:Q,setNodeRef:z,setActivatorNodeRef:te,setDroppableNodeRef:R,setDraggableNodeRef:W,transform:Ve??ie,transition:H()};function H(){if(Ve||_e&&Ne.current.newIndex===A)return aYe;if(!(ae&&!mI(O)||!u)&&(V||le))return Vg.Transition.toString({...u,property:Fie})}}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 YM(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=[Fn.Down,Fn.Right,Fn.Up,Fn.Left],zie=(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 Fn.Down:r.top<m.top&&c.push(f);break;case Fn.Up:r.top>m.top&&c.push(f);break;case Fn.Left:r.left>m.left&&c.push(f);break;case Fn.Right:r.left<m.left&&c.push(f);break}});const u=GKe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=vie(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),m=a.get(d),p=m?i.get(m.id):null,b=m?.node.current;if(b&&p&&f&&m){const x=OE(b).some((k,E)=>l[E]!==k),v=Bie(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:gy(A,M)}}}};function Bie(t,e){return!YM(t)||!YM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function uYe(t,e){return!YM(t)||!YM(e)||!Bie(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function $ie(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=Mi(t);if(!n)return"ASAP";const r=new Date,i=n.getTime()-r.getTime();return i<-6e4?"Overdue":i<0?"Now":i<6e4?"In less than a minute":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)} hours`:yg(t,e)}function hYe({status:t}){const e={pending:{icon:Xn,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:"Pending"},printing:{icon:Do,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:On,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:"Completed"},failed:{icon:na,color:"text-status-error bg-status-error/10 border-status-error/20",label:"Failed"},skipped:{icon:k0,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Ht,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[s.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function 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,D]=w.useState("unchanged"),C=()=>{const U={};a!=="unchanged"&&(U.printer_id=a),l!=="unchanged"&&(U.manual_start=l),u!=="unchanged"&&(U.auto_off_after=u),f!=="unchanged"&&(U.require_previous_success=f),p!=="unchanged"&&(U.bed_levelling=p),y!=="unchanged"&&(U.flow_cali=y),v!=="unchanged"&&(U.vibration_cali=v),M!=="unchanged"&&(U.layer_inspect=M),T!=="unchanged"&&(U.timelapse=T),E!=="unchanged"&&(U.use_ams=E),n(U)},R=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(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Only changed settings will be applied to selected items."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Printer"}),s.jsxs("select",{value:a===null?"null":a==="unchanged"?"unchanged":String(a),onChange:U=>{const O=U.target.value;o(O==="unchanged"?"unchanged":O==="null"?null:Number(O))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"unchanged",children:"— No change —"}),s.jsx("option",{value:"null",children:"Unassigned"}),e.map(U=>s.jsx("option",{value:U.id,children:U.name},U.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Queue Options"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Hc,{label:"Staged (manual start)",value:l,onChange:c}),s.jsx(Hc,{label:"Auto power off after print",value:u,onChange:d}),s.jsx(Hc,{label:"Require previous success",value:f,onChange:m})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Print Options"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Hc,{label:"Bed levelling",value:p,onChange:b}),s.jsx(Hc,{label:"Flow calibration",value:y,onChange:x}),s.jsx(Hc,{label:"Vibration calibration",value:v,onChange:S}),s.jsx(Hc,{label:"First layer inspection",value:M,onChange:A}),s.jsx(Hc,{label:"Timelapse",value:T,onChange:k}),s.jsx(Hc,{label:"Use AMS",value:E,onChange:D})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Me,{onClick:C,disabled:!R||i,children:i?"Saving...":"Apply Changes"})]})]})})}function Hc({label:t,value:e,onChange:n}){return s.jsxs("div",{className:"flex items-center justify-between py-1",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[s.jsx("button",{onClick:()=>n("unchanged"),className:`px-2 py-1 text-xs rounded ${e==="unchanged"?"bg-bambu-dark-tertiary text-white":"text-bambu-gray hover:text-white"}`,children:"—"}),s.jsx("button",{onClick:()=>n(!1),className:`px-2 py-1 text-xs rounded ${e===!1?"bg-red-500/20 text-red-400":"text-bambu-gray hover:text-white"}`,children:"Off"}),s.jsx("button",{onClick:()=>n(!0),className:`px-2 py-1 text-xs rounded ${e===!0?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white"}`,children:"On"})]})]})}function Gj({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d}){const{attributes:f,listeners:m,setNodeRef:p,transform:b,transition:y,isDragging:x}=Uie({id:t.id,disabled:t.status!=="pending"}),v={transform:Vg.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(ts,{className:"w-4 h-4"})}),M?s.jsx("div",{...f,...m,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:s.jsx(gg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?s.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):s.jsx("div",{className:"w-8"}),s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?s.jsx("img",{src:fe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:fe.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(cl,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||t.library_file_name||`File #${t.archive_id||t.library_file_id}`}),t.archive_id?s.jsx(gs,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:s.jsx(zr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(gs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View in File Manager",children:s.jsx(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(Wr,{className:"w-3.5 h-3.5"}),t.printer_id===null?"Unassigned":t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Cd,{className:"w-3.5 h-3.5"}),$ie(t.print_time_seconds)]}),M&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Xn,{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(gK,{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(Mu,{className:"w-3 h-3"}),"Auto power off"]})]}),S&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx(aa,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(hYe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[S&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(gde,{className:"w-4 h-4"})}),M&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Me,{variant:"ghost",size:"sm",onClick:l,title:"Start Print",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:s.jsx(Do,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(sa,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Ht,{className:"w-4 h-4"})})]}),A&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{variant:"ghost",size:"sm",onClick:o,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:s.jsx(xr,{className:"w-4 h-4"})}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(un,{className:"w-4 h-4"})})]})]})]})})}function mYe(){const t=on(),{showToast:e}=Gn(),[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 _e=localStorage.getItem("queue.historySortAsc");return _e!==null?_e==="true":!1}),[k,E]=w.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[D,C]=w.useState(()=>{const _e=localStorage.getItem("queue.pendingSortAsc");return _e!==null?_e==="true":!0});w.useEffect(()=>{localStorage.setItem("queue.historySortBy",S)},[S]),w.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(A))},[A]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",k)},[k]),w.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(D))},[D]);const R=xie(KM(IE,{activationConstraint:{distance:8}}),KM(LE,{coordinateGetter:zie})),{data:U}=ut({queryKey:["settings"],queryFn:fe.getSettings}),O=U?.time_format||"system",{data:q,isLoading:j}=ut({queryKey:["queue",n,i],queryFn:()=>fe.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:W}=ut({queryKey:["printers"],queryFn:()=>fe.getPrinters()}),K=mt({mutationFn:_e=>fe.cancelQueueItem(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),G=mt({mutationFn:_e=>fe.removeFromQueue(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),Q=mt({mutationFn:_e=>fe.stopQueueItem(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),te=mt({mutationFn:_e=>fe.startQueueItem(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),J=mt({mutationFn:_e=>fe.reorderQueue(_e),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),z=mt({mutationFn:async()=>{const _e=q?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[];for(const le of _e)await fe.removeFromQueue(le.id);return _e.length},onSuccess:_e=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${_e} history item${_e!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),V=mt({mutationFn:_e=>fe.bulkUpdateQueue(_e),onSuccess:_e=>{t.invalidateQueries({queryKey:["queue"]}),y([]),v(!1),e(_e.message)},onError:()=>e("Failed to update items","error")}),ne=mt({mutationFn:async _e=>{for(const le of _e)await fe.cancelQueueItem(le);return _e.length},onSuccess:_e=>{t.invalidateQueries({queryKey:["queue"]}),y([]),e(`Cancelled ${_e} item${_e!==1?"s":""}`)},onError:()=>e("Failed to cancel items","error")}),ae=_e=>{y(le=>le.includes(_e)?le.filter(Ve=>Ve!==_e):[...le,_e])},he=w.useMemo(()=>{const _e=q?.filter(Ve=>Ve.status==="pending")||[],le=Ve=>{if(!Ve.scheduled_time)return 0;const H=new Date(Ve.scheduled_time).getTime(),ee=Date.now()+4320*60*60*1e3;return H>ee?0:H};return[..._e].sort((Ve,H)=>{let ee;if(k==="name"){const X=Ve.archive_name||Ve.library_file_name||"",B=H.archive_name||H.library_file_name||"";ee=X.localeCompare(B)}else k==="printer"?ee=(Ve.printer_name||"").localeCompare(H.printer_name||""):k==="time"?ee=le(Ve)-le(H):ee=Ve.position-H.position;return D?ee:-ee})},[q,k,D]),pe=()=>{const _e=he.map(le=>le.id);b.length===_e.length?y([]):y(_e)},ie=q?.filter(_e=>_e.status==="printing")||[],Ee=w.useMemo(()=>[...q?.filter(le=>["completed","failed","skipped","cancelled"].includes(le.status))||[]].sort((le,Ve)=>{let H;if(S==="name"){const ee=le.archive_name||le.library_file_name||"",X=Ve.archive_name||Ve.library_file_name||"";H=ee.localeCompare(X)}else S==="printer"?H=(le.printer_name||"").localeCompare(Ve.printer_name||""):H=new Date(Ve.completed_at||Ve.created_at).getTime()-new Date(le.completed_at||le.created_at).getTime();return A?-H:H}),[q,S,A]),xe=w.useMemo(()=>he.reduce((_e,le)=>_e+(le.print_time_seconds||0),0),[he]),Ne=_e=>{const{active:le,over:Ve}=_e;if(!Ve||le.id===Ve.id)return;const H=he.findIndex(X=>X.id===le.id),ee=he.findIndex(X=>X.id===Ve.id);if(H!==-1&&ee!==-1){const B=zE(he,H,ee).map((I,ue)=>({id:I.id,position:ue+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(xK,{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(Mt,{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(Do,{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(Mt,{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(Xn,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:he.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(St,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Mt,{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(Cd,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:$ie(xe)}),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(Mt,{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(On,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Ee.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n===-1?"unassigned":n||"",onChange:_e=>{const le=_e.target.value;r(le==="unassigned"?-1:le===""?null:Number(le))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),W?.map(_e=>s.jsx("option",{value:_e.id,children:_e.name},_e.id))]}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:_e=>a(_e.target.value),children:[s.jsx("option",{value:"",children:"All Status"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"printing",children:"Printing"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"skipped",children:"Skipped"}),s.jsx("option",{value:"cancelled",children:"Cancelled"})]}),s.jsx("div",{className:"flex-1"}),Ee.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(un,{className:"w-4 h-4"}),"Clear History"]})]}),j?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):q?.length===0?s.jsxs(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(_e=>s.jsx(Gj,{item:_e,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:_e}),onRequeue:()=>{},onStart:()=>{},timeFormat:O},_e.id))})]}),he.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Xn,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",he.length," item",he.length!==1?"s":"",")"]}),s.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:k,onChange:_e=>E(_e.target.value),children:[s.jsx("option",{value:"position",children:"Sort by Position"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"}),s.jsx("option",{value:"time",children:"Sort by Schedule"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>C(!D),title:D?"Ascending":"Descending",className:"px-2",children:D?s.jsx(pg,{className:"w-4 h-4"}):s.jsx(T0,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[s.jsxs(Me,{variant:"ghost",size:"sm",onClick:pe,className:"flex items-center gap-2",children:[b.length===he.length&&he.length>0?s.jsx(Oo,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Lo,{className:"w-4 h-4"}),b.length===he.length&&he.length>0?"Deselect All":"Select All"]}),b.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:[b.length," selected"]}),s.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",children:[s.jsx(sa,{className:"w-4 h-4"}),"Edit Selected"]}),s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ne.mutate(b),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:ne.isPending,children:[s.jsx(Ht,{className:"w-4 h-4"}),"Cancel Selected"]})]})]}),s.jsx(Die,{sensors:R,collisionDetection:_ie,onDragEnd:Ne,children:s.jsx(Iie,{items:he.map(_e=>_e.id),strategy:eYe,children:s.jsx("div",{className:"space-y-3",children:he.map((_e,le)=>s.jsx(Gj,{item:_e,position:le+1,onEdit:()=>u(_e),onCancel:()=>p({type:"cancel",item:_e}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>te.mutate(_e.id),timeFormat:O,isSelected:b.includes(_e.id),onToggleSelect:()=>ae(_e.id)},_e.id))})})})]}),Ee.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(On,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Ee.length," item",Ee.length!==1?"s":"",")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:S,onChange:_e=>M(_e.target.value),children:[s.jsx("option",{value:"date",children:"Sort by Date"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>T(!A),title:A?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:A?s.jsx(pg,{className:"w-4 h-4"}):s.jsx(T0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:Ee.slice(0,20).map((_e,le)=>s.jsx(Gj,{item:_e,position:le+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:_e}),onStop:()=>{},onRequeue:()=>f(_e),onStart:()=>{},timeFormat:O},_e.id))})]})]}),c&&s.jsx(oh,{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(oh,{mode:"add-to-queue",archiveId:d.archive_id??void 0,libraryFileId:d.library_file_id??void 0,archiveName:d.archive_name||d.library_file_name||`File #${d.archive_id||d.library_file_id}`,onClose:()=>f(null)}),m&&s.jsx(zn,{title:m.type==="cancel"?"Cancel Scheduled Print":m.type==="stop"?"Stop Print":"Remove from History",message:m.type==="cancel"?`Are you sure you want to cancel "${m.item.archive_name||m.item.library_file_name||"this print"}"?`:m.type==="stop"?`Are you sure you want to stop the current print "${m.item.archive_name||m.item.library_file_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${m.item.archive_name||m.item.library_file_name||"this item"}" from the queue history?`,confirmText:m.type==="cancel"?"Cancel Print":m.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{m.type==="cancel"?K.mutate(m.item.id):m.type==="stop"?Q.mutate(m.item.id):G.mutate(m.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(zn,{title:"Clear History",message:`Are you sure you want to remove all ${Ee.length} item${Ee.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(_e=>({id:_e.id,name:_e.name}))||[],onSave:_e=>{Object.keys(_e).length>0&&V.mutate({item_ids:b,..._e})},onClose:()=>v(!1),isSaving:V.isPending})]})}function 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 O=U.split("T")[0];S[O]=(S[O]||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=[],D=-1;const C=new Date(A);let R=0;for(;C<=M;)C.getDay()===0&&E.length>0&&(T.push(E),E=[],R++),C.getMonth()!==D&&(k.push({month:C.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),D=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,D=k===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(E)} ${D?"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 Yw=["#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=>(Mi(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=Mi(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=Mi(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=Mi(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(s1,{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(RS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(IS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(FS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(l1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(AJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):s.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(s1,{width:160,height:160,children:s.jsxs(SPe,{children:[s.jsx(JQ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,p)=>s.jsx(Vy,{fill:Yw[p%Yw.length]},`cell-${p}`))}),s.jsx(l1,{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:Yw[p%Yw.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(s1,{width:"100%",height:200,children:s.jsxs(dPe,{data:c,children:[s.jsx(RS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(IS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(FS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(l1,{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(vO,{}),s.jsx(PJ,{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}=Uie({id:t}),p={transform:Vg.Transform.toString(d),transition:f,opacity:m?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${m?"ring-2 ring-bambu-green shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:s.jsx(gg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),s.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?s.jsx(yK,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(bK,{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(_y,{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=xie(KM(IE,{activationConstraint:{distance:8}}),KM(LE,{coordinateGetter:zie})),m=A=>{const{active:T,over:k}=A;k&&T.id!==k.id&&c(E=>{const D=E.order.indexOf(T.id),C=E.order.indexOf(k.id);return{...E,order:zE(E.order,D,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(Me,{variant:"secondary",size:"sm",onClick:y,children:[s.jsx(dm,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(Yd,{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(Yd,{className:"w-3 h-3"}),A.title]},A.id))})]}),s.jsx(Die,{sensors:f,collisionDetection:_ie,onDragEnd:m,children:s.jsx(Iie,{items:v.map(A=>A.id),strategy:xI,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(Me,{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(Ql,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),s.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:s.jsx(Xn,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:s.jsx(Ql,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:s.jsx(pP,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:s.jsx(Vf,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:s.jsx(pP,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function _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(On,{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(na,{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(MK,{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(Wr,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function 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:()=>fe.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(An,{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(EK,{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}=Gn(),[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 R=JSON.parse(C);c(R.hidden?.length||0)}}catch{c(0)}};E(),window.addEventListener("storage",E);const D=setInterval(E,500);return()=>{window.removeEventListener("storage",E),clearInterval(D)}},[a]);const{data:f,isLoading:m,refetch:p}=ut({queryKey:["archiveStats"],queryFn:fe.getArchiveStats}),{data:b}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:y}=ut({queryKey:["archives"],queryFn:()=>fe.getArchives(void 0,void 0,1e3,0)}),{data:x}=ut({queryKey:["settings"],queryFn:fe.getSettings}),v=async E=>{i(!1),n(!0);try{const{blob:D,filename:C}=await fe.exportStats({format:E,days:90}),R=URL.createObjectURL(D),U=document.createElement("a");U.href=R,U.download=C,U.click(),URL.revokeObjectURL(R),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},S=async()=>{d(!0);try{const E=await fe.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(Me,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(Yd,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(E=>E+1),t("Layout reset")},children:[s.jsx(dm,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs(Me,{variant:"secondary",onClick:S,disabled:u,title:"Recalculate all archive costs using current filament prices",children:[u?s.jsx(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(Me,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(O1,{className:"w-4 h-4"}),"Export Stats"]}),r&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>v("csv"),children:[s.jsx(Ya,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>v("xlsx"),children:[s.jsx(O1,{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}=Gn(),[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:()=>fe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),y=b?.find(D=>D.id===t.printer_id),x=mt({mutationFn:D=>fe.controlSmartPlug(t.id,D),onMutate:async D=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const C=n.getQueryData(["smart-plug-status",t.id]),R=D==="on"?"ON":D==="off"||m?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],U=>({...U,state:R})),{previousStatus:C}},onError:(D,C,R)=>{R?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],R.previousStatus),r(`Failed to turn ${C} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),v=mt({mutationFn:D=>fe.updateSmartPlug(t.id,D),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),S=mt({mutationFn:()=>fe.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 D=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${D}/`:`http://${D}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(St,{className:"relative",children:s.jsxs(Mt,{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(oN,{className:`w-5 h-5 ${A?M?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Ws,{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(tg,{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(Zg,{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(Sf,{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(Me,{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(Mu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Me,{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(dN,{className:"w-4 h-4"}),"Off"]})]}),s.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Zd,{className:"w-4 h-4"}),"Automation Settings"]}),s.jsx("span",{children:d?"-":"+"})]}),d&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(lN,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:D=>v.mutate({show_in_switchbar:D.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:D=>v.mutate({enabled:D.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:D=>v.mutate({auto_on:D.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:D=>v.mutate({auto_off:D.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(Xn,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(fN,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:D=>v.mutate({off_delay_minutes:parseInt(D.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:D=>v.mutate({off_temp_threshold:parseInt(D.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(uN,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(un,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(zn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{S.mutate(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(zn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{x.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&s.jsx(zn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{x.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function 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(""),[D,C]=w.useState(""),[R,U]=w.useState(!1),O=w.useRef(null),[q,j]=w.useState(""),[W,K]=w.useState(!1),G=w.useRef(null),[Q,te]=w.useState(""),[J,z]=w.useState(!1),V=w.useRef(null),[ne,ae]=w.useState(""),[he,pe]=w.useState(!1),ie=w.useRef(null),[Ee,xe]=w.useState(t?.printer_id||null),[Ne,_e]=w.useState(null),[le,Ve]=w.useState(null),[H,ee]=w.useState(t?.power_alert_enabled||!1),[X,B]=w.useState(t?.power_alert_high?.toString()||""),[I,ue]=w.useState(t?.power_alert_low?.toString()||""),[Ae,Ie]=w.useState(t?.schedule_enabled||!1),[ce,$]=w.useState(t?.schedule_on_time||""),[L,Y]=w.useState(t?.schedule_off_time||""),[be,Se]=w.useState(t?.show_in_switchbar||!1),[se,Pe]=w.useState(!1),[Re,Xe]=w.useState({scanned:0,total:0}),[et,Je]=w.useState([]),oe=w.useRef(null),{data:ye}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:je}=ut({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),{data:$e}=ut({queryKey:["settings"],queryFn:fe.getSettings}),ft=!!($e?.ha_enabled&&$e?.ha_url&&$e?.ha_token);w.useEffect(()=>{const gt=setTimeout(()=>{C(k)},300);return()=>clearTimeout(gt)},[k]),w.useEffect(()=>{const gt=Kt=>{O.current&&!O.current.contains(Kt.target)&&U(!1),G.current&&!G.current.contains(Kt.target)&&K(!1),V.current&&!V.current.contains(Kt.target)&&z(!1),ie.current&&!ie.current.contains(Kt.target)&&pe(!1)};return document.addEventListener("mousedown",gt),()=>document.removeEventListener("mousedown",gt)},[]);const{data:re,isLoading:ke,error:ve}=ut({queryKey:["ha-entities",D],queryFn:()=>fe.getHAEntities(D||void 0),enabled:i==="homeassistant"&&ft,retry:!1,staleTime:0}),{data:Fe}=ut({queryKey:["ha-sensor-entities"],queryFn:fe.getHASensorEntities,enabled:i==="homeassistant"&&ft,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()=>{Pe(!0),Je([]),Xe({scanned:0,total:0}),Ve(null);try{await fe.startTasmotaScan();const gt=async()=>{try{const Kt=await fe.getTasmotaScanStatus();Xe({scanned:Kt.scanned,total:Kt.total});const pn=await fe.getDiscoveredTasmotaDevices();Je(pn),Kt.running||(Pe(!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){Pe(!1);const Kt=gt instanceof Error?gt.message:typeof gt=="string"?gt:JSON.stringify(gt);Ve(Kt||"Failed to start scan")}},Te=async()=>{try{await fe.stopTasmotaScan()}catch{}Pe(!1),oe.current&&(clearInterval(oe.current),oe.current=null)},qe=gt=>{u(gt.ip_address),l(gt.name),_e(null)},bt=mt({mutationFn:()=>fe.testSmartPlugConnection(c,d||null,m||null),onSuccess:gt=>{_e(gt),Ve(null),!o&>.device_name&&l(gt.device_name)},onError:gt=>{_e(null),Ve(gt.message)}}),Pt=mt({mutationFn:gt=>fe.createSmartPlug(gt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:gt=>{Ve(gt.message)}}),Ot=mt({mutationFn:gt=>fe.updateSmartPlug(t.id,gt),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:gt=>{Ve(gt.message)}}),ln=ye?.filter(gt=>!je?.some(pn=>pn.printer_id===gt.id&&pn.id!==t?.id)),Gt=gt=>{if(gt.preventDefault(),Ve(null),!o.trim()){Ve("Name is required");return}if(i==="tasmota"&&!c.trim()){Ve("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!b){Ve("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:Ee,power_alert_enabled:H,power_alert_high:X?parseFloat(X):null,power_alert_low:I?parseFloat(I):null,schedule_enabled:Ae,schedule_on_time:ce||null,schedule_off_time:L||null,show_in_switchbar:be};r?Ot.mutate(Kt):Pt.mutate(Kt)},vn=Pt.isPending||Ot.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(Ht,{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"),_e(null),Ve(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(Ws,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),_e(null),Ve(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(oN,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[se?s.jsxs(Me,{type:"button",variant:"secondary",onClick:Te,className:"w-full",children:[s.jsx(Ht,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Me,{type:"button",variant:"primary",onClick:Ue,className:"w-full",children:[s.jsx(Na,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),se&&Re.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:[Re.scanned," / ",Re.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:`${Re.scanned/Re.total*100}%`}})})]}),et.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",et.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:et.map(gt=>s.jsxs("button",{type:"button",onClick:()=>qe(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(Ws,{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(Mu,{className:"w-3 h-3"}),gt.state]})]},gt.ip_address))})]}),!se&&et.length===0&&Re.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:[!ft&&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..."})})]})]}),ft&&s.jsxs(s.Fragment,{children:[ke&&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..."]}),ve&&s.jsxs("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to load entities: ",ve.message]}),(()=>{const gt=je?.filter(Et=>Et.ha_entity_id&&Et.id!==t?.id).map(Et=>Et.ha_entity_id)||[],Kt=(re||[]).filter(Et=>!gt.includes(Et.entity_id)),pn=re?.find(Et=>Et.entity_id===b);return s.jsxs("div",{ref:O,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("div",{className:"relative",children:[s.jsx(Na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:R?k:pn?`${pn.friendly_name} (${pn.entity_id})`:"",onChange:Et=>{E(Et.target.value),R||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&&!R&&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(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),ke&&s.jsx(dt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),R&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[ke&&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..."]}),!ke&&Kt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:D?`No entities found matching "${D}"`:"No entities available"}),!ke&&Kt.map(Et=>s.jsxs("button",{type:"button",onClick:()=>{y(Et.entity_id),U(!1),E(""),o||l(Et.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Et.entity_id===b?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Et.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:Et.entity_id}),s.jsx("span",{className:Et.state==="on"?"text-bambu-green":"",children:Et.state})]})]},Et.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:D?`Searching all entities (${Kt.length} found)`:`Showing switch, light, input_boolean (${Kt.length} available)`})]})})(),b&&Fe&&Fe.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=Fe.filter(Et=>Et.unit_of_measurement==="W"||Et.unit_of_measurement==="kW"||Et.unit_of_measurement==="mW"),Kt=q?gt.filter(Et=>Et.entity_id.toLowerCase().includes(q.toLowerCase())||Et.friendly_name.toLowerCase().includes(q.toLowerCase())):gt,pn=Fe.find(Et=>Et.entity_id===x);return s.jsxs("div",{ref:G,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("div",{className:"relative",children:[s.jsx(Na,{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:pn?`${pn.friendly_name} (${pn.state} ${pn.unit_of_measurement})`:"",onChange:Et=>{j(Et.target.value),W||K(!0)},onFocus:()=>{K(!0),j("")},placeholder:"Search power sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),x&&!W&&s.jsx("button",{type:"button",onClick:()=>{v(""),j("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),W&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{v(""),K(!1),j("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Kt.map(Et=>s.jsxs("button",{type:"button",onClick:()=>{v(Et.entity_id),K(!1),j("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Et.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Et.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Et.entity_id," • ",Et.state," ",Et.unit_of_measurement]})]},Et.entity_id)),Kt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const gt=Fe.filter(Et=>Et.unit_of_measurement==="kWh"||Et.unit_of_measurement==="Wh"||Et.unit_of_measurement==="MWh"),Kt=Q?gt.filter(Et=>Et.entity_id.toLowerCase().includes(Q.toLowerCase())||Et.friendly_name.toLowerCase().includes(Q.toLowerCase())):gt,pn=Fe.find(Et=>Et.entity_id===S);return s.jsxs("div",{ref:V,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(Na,{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:pn?`${pn.friendly_name} (${pn.state} ${pn.unit_of_measurement})`:"",onChange:Et=>{te(Et.target.value),J||z(!0)},onFocus:()=>{z(!0),te("")},placeholder:"Search energy sensors...",className:"w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),S&&!J&&s.jsx("button",{type:"button",onClick:()=>{M(""),te("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),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),te("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Kt.map(Et=>s.jsxs("button",{type:"button",onClick:()=>{M(Et.entity_id),z(!1),te("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Et.entity_id===S?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Et.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Et.entity_id," • ",Et.state," ",Et.unit_of_measurement]})]},Et.entity_id)),Kt.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const gt=Fe.filter(Et=>Et.unit_of_measurement==="kWh"||Et.unit_of_measurement==="Wh"||Et.unit_of_measurement==="MWh"),Kt=ne?gt.filter(Et=>Et.entity_id.toLowerCase().includes(ne.toLowerCase())||Et.friendly_name.toLowerCase().includes(ne.toLowerCase())):gt,pn=Fe.find(Et=>Et.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(Na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:he?ne:pn?`${pn.friendly_name} (${pn.state} ${pn.unit_of_measurement})`:"",onChange:Et=>{ae(Et.target.value),he||pe(!0)},onFocus:()=>{pe(!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&&!he&&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(Ht,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),he&&s.jsxs("div",{className:"absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto",children:[s.jsx("button",{type:"button",onClick:()=>{T(""),pe(!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(Et=>s.jsxs("button",{type:"button",onClick:()=>{T(Et.entity_id),pe(!1),ae("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Et.entity_id===A?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Et.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Et.entity_id," • ",Et.state," ",Et.unit_of_measurement]})]},Et.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),_e(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>bt.mutate(),disabled:!c.trim()||bt.isPending,children:[bt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(tg,{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(On,{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(Zg,{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:Ee??"",onChange:gt=>xe(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(Sf,{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=>ue(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(Xn,{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:Ae,onChange:gt=>Ie(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"})]})]}),Ae&&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:ce,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:L,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(lN,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:be,onChange:gt=>Se(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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:vn,className:"flex-1",children:[vn?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ys,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Hn({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:fe.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=mt({mutationFn:y=>fe.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=mt({mutationFn:()=>fe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=mt({mutationFn:()=>fe.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),b=y=>y||"";return s.jsxs(s.Fragment,{children:[s.jsx(St,{className:"relative",children:s.jsxs(Mt,{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(Sf,{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: ",bg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Mi(t.last_error_at)?.getTime()||0)>(Mi(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(Hn,{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(L1,{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(Me,{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($D,{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(On,{className:"w-4 h-4"}):s.jsx(na,{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(Zd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(fu,{className:"w-4 h-4"}):s.jsx(Di,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(L1,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(Hn,{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(Xn,{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(Hn,{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(Xn,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",b(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(uN,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(un,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(zn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{m.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const uq=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function 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),[D,C]=w.useState(t?.on_print_failed??!0),[R,U]=w.useState(t?.on_print_stopped??!0),[O,q]=w.useState(t?.on_print_progress??!1),[j,W]=w.useState(t?.on_printer_offline??!1),[K,G]=w.useState(t?.on_printer_error??!1),[Q,te]=w.useState(t?.on_filament_low??!1),[J,z]=w.useState(t?.on_maintenance_due??!1),[V,ne]=w.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,I])=>[B,String(I)])):{}),[ae,he]=w.useState(null),[pe,ie]=w.useState(null),{data:Ee}=ut({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{const B=I=>{I.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const xe=mt({mutationFn:()=>fe.testNotificationConfig({provider_type:o,config:V}),onSuccess:B=>{he(B),ie(null)},onError:B=>{he({success:!1,message:B.message})}}),Ne=mt({mutationFn:B=>fe.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{ie(B.message)}}),_e=mt({mutationFn:B=>fe.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 Ae of I)if(!V[Ae.key]?.trim()){ie(`${Ae.label} is required`);return}const ue={name:i.trim(),provider_type:o,config:V,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?m:null,quiet_hours_end:d?b:null,daily_digest_enabled:x,daily_digest_time:x?S:null,on_print_start:A,on_print_complete:k,on_print_failed:D,on_print_stopped:R,on_print_progress:O,on_printer_offline:j,on_printer_error:K,on_filament_low:Q,on_maintenance_due:J};r?_e.mutate(ue):Ne.mutate(ue)},Ve=Ne.isPending||_e.isPending,H=B=>{switch(B){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"payload_format",label:"Payload Format",type:"select",required:!1,options:[{value:"generic",label:"Generic JSON"},{value:"slack",label:"Slack / Mattermost"}]},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1,showIf:I=>I.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:I=>I.payload_format!=="slack"}];default:return[]}},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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:le,className:"p-6 space-y-4",children:[pe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:pe}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:B=>a(B.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:B=>{l(B.target.value),ne({}),he(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:uq.map(B=>s.jsx("option",{value:B.value,children:B.label},B.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:uq.find(B=>B.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),X.filter(B=>!("showIf"in B)||B.showIf?.(V)!==!1).map(B=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&"options"in B&&B.options?s.jsx("select",{value:V[B.key]||B.options[0]?.value||"",onChange:I=>{ne({...V,[B.key]:I.target.value}),he(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:B.options.map(I=>s.jsx("option",{value:I.value,children:I.label},I.value))}):s.jsx("input",{type:B.type,value:V[B.key]||"",onChange:I=>{ne({...V,[B.key]:I.target.value}),he(null)},placeholder:B.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},B.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Me,{type:"button",variant:"secondary",onClick:()=>{he(null),xe.mutate()},disabled:xe.isPending||!V[ee(o)[0]?.key],className:"flex-1",children:[xe.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx($D,{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(On,{className:"w-5 h-5"}),s.jsx("span",{children:ae.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(na,{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"}),Ee?.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(Hn,{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(Hn,{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(Hn,{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(Hn,{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(Hn,{checked:D,onChange:C})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(Hn,{checked:R,onChange:U})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx(Hn,{checked:O,onChange:q})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx(Hn,{checked:j,onChange:W})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(Hn,{checked:K,onChange:G})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(Hn,{checked:Q,onChange:te})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(Hn,{checked:J,onChange:z})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:Ve,className:"flex-1",children:[Ve?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ys,{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:fe.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:()=>fe.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=>fe.updateNotificationTemplate(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:T=>{u(T.message)}}),v=mt({mutationFn:()=>fe.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,D=k.selectionEnd,C=o,R=C.substring(0,E),U=C.substring(D),O=R+`{${T}}`+U;l(O),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(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange: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(er,{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(Yd,{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(Me,{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(dm,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Me,{onClick:S,disabled:x.isPending||!A,children:[x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ys,{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}=Gn(),[r,i]=w.useState(7),[a,o]=w.useState(null),[l,c]=w.useState(!1),{data:u}=ut({queryKey:["settings"],queryFn:fe.getSettings}),d=u?.time_format||"system",{data:f,isLoading:m,refetch:p,isRefetching:b}=ut({queryKey:["notification-logs",r,l],queryFn:()=>fe.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ut({queryKey:["notification-log-stats",r],queryFn:()=>fe.getNotificationLogStats(r)}),x=mt({mutationFn:()=>fe.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),v=S=>{const M=Mi(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(C0,{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(On,{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(na,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.jsxs("select",{value:r,onChange:S=>i(Number(S.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:S=>c(S.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:b,children:[b?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{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=>yg(M,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(C0,{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(On,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(na,{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(fu,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Di,{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:fe.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=ut({queryKey:["printers"],queryFn:fe.getPrinters});w.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),m(!0))},[y]),w.useEffect(()=>{if(!f||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==a){const W=setTimeout(()=>{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:fe.connectSpoolman,onSuccess:()=>{M()}}),E=mt({mutationFn:fe.disconnectSpoolman,onSuccess:()=>{M()}}),D=mt({mutationFn:fe.syncAllPrintersAms,onSuccess:j=>{j.success}}),C=mt({mutationFn:j=>fe.syncPrinterAms(j),onSuccess:j=>{j.success}}),R=()=>{u==="all"?D.mutate():C.mutate(u)},U=D.isPending||C.isPending,O=u==="all"?D.data:C.data,q=u==="all"?D.isSuccess:C.isSuccess;return x?s.jsxs(St,{children:[s.jsx(ir,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(iu,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Mt,{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(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(iu,{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(ts,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Zl,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:j=>n(j.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:j=>i(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,onChange:j=>o(j.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),S?s.jsx(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(ts,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Ht,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>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(Me,{size:"sm",onClick:()=>k.mutate(),disabled:k.isPending||!r,children:[k.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Gl,{className:"w-4 h-4"}),"Connect"]})})]}),k.isError&&s.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:k.error.message}),v?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("select",{value:u,onChange:j=>d(j.target.value==="all"?"all":Number(j.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[s.jsx("option",{value:"all",children:"All Printers"}),A?.map(j=>s.jsx("option",{value:j.id,children:j.name},j.id))]}),s.jsx(Di,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:R,disabled:U,children:[U?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Sync"]})]})]}),q&&O&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${O.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:O.success?`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} successfully`:`Synced ${O.synced_count} spool${O.synced_count!==1?"s":""} with ${O.errors.length} error${O.errors.length!==1?"s":""}`}),O.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[O.skipped_count," spool",O.skipped_count!==1?"s":""," skipped"]})]}),O.skipped_count>5&&s.jsx("button",{onClick:()=>b(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?O.skipped:O.skipped.slice(0,5)).map((j,W)=>s.jsxs("li",{className:"flex items-center gap-2",children:[j.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${j.color}`}}),s.jsx("span",{children:j.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",j.reason]})]},W)),!p&&O.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",O.skipped_count-5," more"]})]})]}),O.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:O.errors.map((j,W)=>s.jsx("li",{children:j},W))})]})]})]})]})]})}function $Ye({link:t,onClose:e}){const n=on(),{mode:r}=uh(),i=!!t,a=w.useRef(null),[o,l]=w.useState(t?.name||""),[c,u]=w.useState(t?.url||""),[d,f]=w.useState(t?.icon||"link"),[m,p]=w.useState(!!t?.custom_icon),[b,y]=w.useState(t?.custom_icon?fe.getExternalLinkIconUrl(t.id):null),[x,v]=w.useState(null),[S,M]=w.useState(null);w.useEffect(()=>{const U=O=>{O.key==="Escape"&&e()};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[e]);const A=mt({mutationFn:async U=>{const O=await fe.createExternalLink(U);return x?await fe.uploadExternalLinkIcon(O.id,x):O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),T=mt({mutationFn:async U=>{let O=await fe.updateExternalLink(t.id,U);return x?O=await fe.uploadExternalLinkIcon(t.id,x):!m&&t?.custom_icon&&(O=await fe.deleteExternalLinkIcon(t.id)),O},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:U=>{M(U.message)}}),k=U=>{const O=U.target.files?.[0];if(O){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(O.type)){M("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(O.size>1024*1024){M("Image file must be less than 1MB");return}v(O),p(!0);const j=new FileReader;j.onload=W=>{y(W.target?.result)},j.readAsDataURL(O)}},E=()=>{v(null),y(null),p(!1),a.current&&(a.current.value="")},D=U=>{if(U.preventDefault(),M(null),!o.trim()){M("Name is required");return}if(!c.trim()){M("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){M("URL must start with http:// or https://");return}const O={name:o.trim(),url:c.trim(),icon:d};i?T.mutate(O):A.mutate(O)},C=A.isPending||T.isPending,R=mN(d);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:U=>U.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:m&&b?s.jsx("img",{src:b,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(R,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[S&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:U=>l(U.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),s.jsx("input",{type:"text",value:c,onChange:U=>u(U.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:k}),m&&b?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:b,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),s.jsx("button",{type:"button",onClick:E,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(un,{className:"w-4 h-4"})})]}):s.jsxs(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(mi,{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(Me,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:C,className:"flex-1",children:[C?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ys,{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:fe.getExternalLinks}),f=mt({mutationFn:S=>fe.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=mt({mutationFn:S=>fe.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(S,M)=>{c(M),S.dataTransfer.effectAllowed="move"},b=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},y=(S,M)=>{if(S.preventDefault(),l===null||l===M||!u)return;const A=u.map(D=>D.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(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gl,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Me,{size:"sm",onClick:()=>n(!0),children:[s.jsx(er,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Mt,{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=mN(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(gg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(M,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:S.name}),s.jsx(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(sa,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>x(S),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]})]},S.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Gl,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No external links configured"}),s.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&s.jsx($Ye,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(zn,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:v,onCancel:()=>o(null)})]})}function VYe(){const t=on(),{showToast:e}=Gn(),[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:t1.getSettings,refetchInterval:1e4}),{data:x}=ut({queryKey:["virtual-printer-models"],queryFn:t1.getModels});w.useEffect(()=>{if(b){r(b.enabled);let D=b.mode==="queue"?"review":b.mode;D!=="immediate"&&D!=="review"&&D!=="print_queue"&&(D="immediate"),l(D),u(b.model)}},[b]);const v=mt({mutationFn:D=>t1.updateSettings(D),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:D=>{if(e(D.message||"Failed to update settings","error"),b){r(b.enabled);const C=b.mode==="queue"?"review":b.mode;l(C==="print_queue"||C==="review"?C:"immediate"),u(b.model)}p(null)}}),S=()=>{const D=!n;if(D&&!i&&!b?.access_code_set){e("Please set an access code first","error");return}r(D),p("toggle"),v.mutate({enabled:D,access_code:i||void 0,mode:o})},M=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),v.mutate({access_code:i}),a("")},A=D=>{l(D),p("mode"),v.mutate({mode:D})},T=D=>{u(D),p("model"),v.mutate({model:D})};if(y)return s.jsx(St,{children:s.jsx(Mt,{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(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wr,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),k&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${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(Mt,{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:D=>T(D.target.value),disabled:m==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:x?.models&&Object.entries(x.models).sort(([,D],[,C])=>D.localeCompare(C)).map(([D,C])=>s.jsx("option",{value:D,children:C},D))}),s.jsx(Di,{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(Zl,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:b?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(ts,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(An,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:D=>a(D.target.value),placeholder:b?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),s.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?s.jsx(_y,{className:"w-4 h-4"}):s.jsx(Yd,{className:"w-4 h-4"})})]}),s.jsx(Me,{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(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(An,{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(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Zl,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsx("strong",{className:"text-white",children:"How it works:"})}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:"Complete the setup guide for your platform"}),s.jsx("li",{children:"Enable the virtual printer and set an access code"}),s.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),s.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),s.jsx("li",{children:"Connect using the access code you set"}),s.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),k&&E&&s.jsxs(St,{children:[s.jsx(ir,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Mt,{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 Zw=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(hN,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(Sf,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(Ya,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Ws,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Yg,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Wr,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"plate_calibration",labelKey:"backup.categories.plateCalibration",defaultLabel:"Plate Detection",icon:s.jsx(zf,{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(zD,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Qd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Ja,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:s.jsx(Aa,{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(mi,{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(df,{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}=Wg(),[r,i]=w.useState(()=>{const b={};return Zw.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={};Zw.forEach(y=>{b[y.id]=!0}),i(b)},f=()=>{const b={};Zw.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(Mt,{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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[s.jsx("button",{onClick:d,disabled:l,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),s.jsx("span",{className:"text-bambu-gray",children:"|"}),s.jsx("button",{onClick:f,disabled:l,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),s.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:Zw.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(Ja,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[s.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),s.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&s.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(df,{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(Hn,{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(An,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:m,defaultValue:`${m} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Me,{onClick:p,disabled:m===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?s.jsxs(s.Fragment,{children:[s.jsx(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 dq={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives",projects:"Projects",pending_uploads:"Pending Uploads",external_links:"External Links",api_keys:"API Keys"};function 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(Mt,{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(On,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(An,{className:"w-5 h-5"}):s.jsx(mi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&s.jsx("button",{onClick:x,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),r==="options"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:b}),s.jsx("button",{type:"button",onClick:()=>p.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?s.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[s.jsx(On,{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(mi,{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(An,{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(k0,{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(Hn,{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(An,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[s.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Me,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(mi,{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(On,{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:dq[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(k0,{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:[dq[A]||A,k.length>0&&(E?s.jsx(fu,{className:"w-3 h-3"}):s.jsx(Di,{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((D,C)=>s.jsx("div",{children:D},C)),k.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",k.length-10," more"]})]})]},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(An,{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(Me,{onClick:x,children:"Close"})})]})]})})})}function hq({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(On,{className:"w-3 h-3"}),failed:s.jsx(na,{className:"w-3 h-3"}),skipped:s.jsx(k0,{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 fq(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}=Gn(),[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),[D,C]=w.useState(!1),[R,U]=w.useState(!1),[O,q]=w.useState(null),j=w.useRef(null),W=w.useRef(!1),{data:K,isLoading:G}=ut({queryKey:["github-backup-config"],queryFn:fe.getGitHubBackupConfig}),{data:Q}=ut({queryKey:["github-backup-status"],queryFn:fe.getGitHubBackupStatus,refetchInterval:ie=>ie.state.data?.is_running?500:1e4}),{data:te}=ut({queryKey:["github-backup-logs"],queryFn:()=>fe.getGitHubBackupLogs(20)}),{data:J}=ut({queryKey:["cloud-status"],queryFn:fe.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 fe.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 fe.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(Ee){e(`Failed to save: ${Ee.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 j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{z(!1)},500),()=>{j.current&&clearTimeout(j.current)}},[n,o,d,m,b,x,S,A,z,K?.has_token]),w.useEffect(()=>{if(!(!W.current||!K?.has_token||!i))return j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{z(!0)},1e3),()=>{j.current&&clearTimeout(j.current)}},[i,z,K?.has_token]);const V=mt({mutationFn:ie=>fe.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:fe.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:()=>fe.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")}}),he=async()=>{U(!0),q(null);try{let ie;if(i){if(!n){e("Enter repository URL","error"),U(!1);return}ie=await fe.testGitHubConnection(n,i)}else if(K?.has_token)ie=await fe.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)}},pe=()=>{if(!n){e("Repository URL is required","error");return}if(!i){e("Access token is required","error");return}V.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 G?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(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(gP,{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(Hn,{checked:A,onChange:T})]})]})}),s.jsx(Mt,{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(_y,{className:"w-4 h-4"}):s.jsx(Yd,{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: ",fq(Q.last_backup_at)]}),s.jsx(hq,{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(Xn,{className:"w-3 h-3 inline mr-1"}),"Next: ",fq(Q.next_scheduled_run)]})]}),O&&s.jsxs("div",{className:`text-sm flex items-center gap-1 ${O.success?"text-green-400":"text-red-400"}`,children:[O.success?s.jsx(On,{className:"w-4 h-4"}):s.jsx(na,{className:"w-4 h-4"}),O.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(Me,{variant:"primary",size:"sm",onClick:()=>ne.mutate(),disabled:!K?.enabled,children:[s.jsx(Do,{className:"w-4 h-4"}),"Backup Now"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:he,disabled:R,children:[R?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(Me,{variant:"primary",size:"sm",onClick:pe,disabled:V.isPending||!n||!i,children:[V.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(On,{className:"w-4 h-4"}),"Enable Backup"]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:he,disabled:R||!n||!i,children:[R?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(An,{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."})]})})]}),te&&te.length>0&&s.jsxs(St,{children:[s.jsx(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(C0,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>ae.mutate(),disabled:ae.isPending,children:[s.jsx(un,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsx(Mt,{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:te.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(hq,{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(ir,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(iu,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),s.jsxs(Mt,{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(Me,{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(Me,{variant:"secondary",size:"sm",onClick:()=>C(!0),children:[s.jsx(mi,{className:"w-4 h-4"}),"Import"]})]})]})]})}),k&&s.jsx(GYe,{onClose:()=>E(!1),onExport:async ie=>{E(!1);try{const{blob:Ee,filename:xe}=await fe.exportBackup(ie),Ne=URL.createObjectURL(Ee),_e=document.createElement("a");_e.href=Ne,_e.download=xe,_e.click(),URL.revokeObjectURL(Ne),e("Backup downloaded successfully")}catch{e("Failed to create backup","error")}}}),D&&s.jsx(WYe,{onClose:()=>C(!1),onRestore:async(ie,Ee)=>await fe.importBackup(ie,Ee),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 Qb(t,e,n=0){if(n>5)return"...";if(e.$ref)return Qb(t,YYe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=Qb(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?[Qb(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=Qb(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 D={};for(const C of n.parameters)C.schema?.default!==void 0&&(D[C.name]=String(C.schema.default));c(C=>({...D,...C}))}},[a,n.parameters]),w.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,C=Qb(r,D);d(JSON.stringify(C,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const D=[];for(const C of n.parameters||[])if(C.in==="path"||C.required){const R=l[C.name];(R===void 0||R==="")&&D.push(C.name)}return D})(),M=async()=>{if(S.length>0){m({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}b(!0),m(null);try{let D=t;const C=new URLSearchParams;for(const J of n.parameters||[]){const z=l[J.name];z!==void 0&&z!==""&&(J.in==="path"?D=D.replace(`{${J.name}}`,encodeURIComponent(z)):J.in==="query"&&C.append(J.name,z))}const R=C.toString(),U=`${D}${R?`?${R}`:""}`,O={"Content-Type":"application/json"};i&&(O["X-API-Key"]=i);const q={method:e.toUpperCase(),headers:O};["post","put","patch"].includes(e)&&u&&(q.body=u);const j=performance.now(),W=await fetch(U,q),K=Math.round(performance.now()-j),G={};W.headers.forEach((J,z)=>{G[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:G,body:Q,duration:K})}catch(D){m({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{b(!1)}},A=async()=>{if(f){const D=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(D),x(!0),setTimeout(()=>x(!1),2e3)}catch{const C=document.createElement("textarea");C.value=D,C.style.position="fixed",C.style.left="-999999px",document.body.appendChild(C),C.select(),document.execCommand("copy"),document.body.removeChild(C),x(!0),setTimeout(()=>x(!1),2e3)}}},T=(n.parameters||[]).filter(D=>D.in==="path"),k=(n.parameters||[]).filter(D=>D.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(Di,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Zs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${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(D=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[D.name]||"",onChange:C=>c(R=>({...R,[D.name]:C.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),k.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:k.map(D=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),D.schema?.enum?s.jsxs("select",{value:l[D.name]||"",onChange:C=>c(R=>({...R,[D.name]:C.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"-- Select --"}),D.schema.enum.map(C=>s.jsx("option",{value:C,children:C},C))]}):s.jsx("input",{type:"text",value:l[D.name]||"",onChange:C=>c(R=>({...R,[D.name]:C.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),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:D=>d(D.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{onClick:M,disabled:p,children:[p?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Do,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(aa,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:A,children:y?s.jsx(On,{className:"w-3 h-3 text-green-400"}):s.jsx(ol,{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(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(aa,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[x,v]of Object.entries(e.paths))for(const[S,M]of Object.entries(v)){if(S==="parameters")continue;const 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(Me,{variant:"secondary",size:"sm",onClick:b,children:"Expand All"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:y,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(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(Di,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Zs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:x.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(x)&&s.jsx(Mt,{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=pl(),[n,r]=Wq(),{t:i,i18n:a}=Wg(),{showToast:o}=Gn(),{authEnabled:l,user:c,refreshAuth:u}=dh(),{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}=uh(),[E,D]=w.useState(null),[C,R]=w.useState(!1),[U,O]=w.useState(null),[q,j]=w.useState(!1),[W,K]=w.useState(null),[G,Q]=w.useState(null),[te,J]=w.useState(!1),[z,V]=w.useState(RK()),ne=n.get("tab"),ae=ne&&JYe.includes(ne)?ne:"general",[he,pe]=w.useState(ae),ie=me=>{pe(me),me==="general"?n.delete("tab"):n.set("tab",me),r(n,{replace:!0})},[Ee,xe]=w.useState(!1),[Ne,_e]=w.useState(""),[le,Ve]=w.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[H,ee]=w.useState(null),[X,B]=w.useState(null),[I,ue]=w.useState(""),[Ae,Ie]=w.useState(!1),[ce,$]=w.useState(!1),[L,Y]=w.useState(null),[be,Se]=w.useState(!1),[se,Pe]=w.useState(!1),[Re,Xe]=w.useState(null),[et,Je]=w.useState(!1),[oe,ye]=w.useState({}),[je,$e]=w.useState({}),ft=me=>{V(me),Kme(me)},re=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:ke,isLoading:ve}=ut({queryKey:["settings"],queryFn:fe.getSettings}),{data:Fe,isLoading:Ue}=ut({queryKey:["smart-plugs"],queryFn:fe.getSmartPlugs}),{data:Te,isLoading:qe}=ut({queryKey:["smart-plugs-energy",Fe?.map(me=>me.id)],queryFn:async()=>{if(!Fe||Fe.length===0)return null;const me=await Promise.all(Fe.filter(Bt=>Bt.enabled).map(async Bt=>{try{const At=await fe.getSmartPlugStatus(Bt.id);return{plug:Bt,status:At}}catch{return{plug:Bt,status:null}}}));let He=0,Lt=0,jt=0,Wt=0,Rt=0;for(const{status:Bt}of me)Bt?.reachable&&Bt.energy&&(Rt++,Bt.energy.power!=null&&(He+=Bt.energy.power),Bt.energy.today!=null&&(Lt+=Bt.energy.today),Bt.energy.yesterday!=null&&(jt+=Bt.energy.yesterday),Bt.energy.total!=null&&(Wt+=Bt.energy.total));return{totalPower:He,totalToday:Lt,totalYesterday:jt,totalLifetime:Wt,reachableCount:Rt,totalPlugs:Fe.filter(Bt=>Bt.enabled).length}},enabled:he==="plugs"&&!!Fe&&Fe.length>0,refetchInterval:he==="plugs"?1e4:!1}),{data:bt,isLoading:Pt}=ut({queryKey:["notification-providers"],queryFn:fe.getNotificationProviders}),{data:Ot,isLoading:ln}=ut({queryKey:["api-keys"],queryFn:fe.getAPIKeys}),Gt=mt({mutationFn:me=>fe.createAPIKey(me),onSuccess:me=>{ee(me.key||null),xe(!1),_e(""),t.invalidateQueries({queryKey:["api-keys"]}),o("API key created")},onError:me=>{o(`Failed to create API key: ${me.message}`,"error")}}),vn=mt({mutationFn:me=>fe.deleteAPIKey(me),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o("API key deleted")},onError:me=>{o(`Failed to delete API key: ${me.message}`,"error")}}),{data:gt}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:Kt,isLoading:pn}=ut({queryKey:["notification-templates"],queryFn:fe.getNotificationTemplates}),{data:Et}=ut({queryKey:["virtual-printer-settings"],queryFn:t1.getSettings,refetchInterval:1e4}),Ln=Et?.status?.running??!1,{data:Nr}=ut({queryKey:["ffmpeg-status"],queryFn:fe.checkFfmpeg}),{data:Or}=ut({queryKey:["version"],queryFn:fe.getVersion}),{data:tn,refetch:yr,isRefetching:xi}=ut({queryKey:["updateCheck"],queryFn:fe.checkForUpdates,staleTime:300*1e3}),{data:lr,refetch:we}=ut({queryKey:["updateStatus"],queryFn:fe.getUpdateStatus,refetchInterval:me=>{const He=me.state.data;return He?.status==="downloading"||He?.status==="installing"?1e3:!1}}),{data:Ye}=ut({queryKey:["mqtt-status"],queryFn:fe.getMQTTStatus,refetchInterval:he==="network"?5e3:!1}),{data:at}=ut({queryKey:["github-backup-status"],queryFn:fe.getGitHubBackupStatus}),{data:ct}=ut({queryKey:["cloud-status"],queryFn:fe.getCloudStatus}),st=mt({mutationFn:fe.applyUpdate,onSuccess:me=>{me.is_docker?o(me.message,"error"):we()}}),[Ct,Ft]=w.useState(null),Yt=mt({mutationFn:fe.testAllNotificationProviders,onSuccess:me=>{Ft(me),t.invalidateQueries({queryKey:["notification-providers"]}),me.failed===0?o(`All ${me.tested} providers tested successfully!`,"success"):o(`${me.success}/${me.tested} providers succeeded`,me.failed>0?"error":"success")},onError:me=>{o(`Failed to test providers: ${me.message}`,"error")}}),Zt=mt({mutationFn:async me=>{if(!Fe)return{success:0,failed:0};const He=Fe.filter(jt=>jt.enabled),Lt=await Promise.all(He.map(async jt=>{try{return await fe.controlSmartPlug(jt.id,me),{success:!0}}catch{return{success:!1}}}));return{success:Lt.filter(jt=>jt.success).length,failed:Lt.filter(jt=>!jt.success).length}},onSuccess:(me,He)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),me.failed===0?o(`All ${me.success} plugs turned ${He}`,"success"):o(`${me.success} plugs turned ${He}, ${me.failed} failed`,"error")},onError:me=>{o(`Failed: ${me.message}`,"error")}}),de=w.useRef(null),De=w.useRef(!1),We=w.useRef(!0);w.useEffect(()=>{if(ke&&!E){const me={...ke,external_url:ke.external_url||window.location.origin};D(me),setTimeout(()=>{We.current=!1},100)}},[ke,E]);const Ze=mt({mutationFn:fe.updateSettings,onSuccess:me=>{t.setQueryData(["settings"],me),D(me),t.invalidateQueries({queryKey:["archiveStats"]}),o("Settings saved","success")},onError:me=>{o(`Failed to save: ${me.message}`,"error")},onSettled:()=>{De.current=!1}}),Ge=mt({mutationFn:({id:me,data:He})=>fe.updatePrinter(me,He),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o("Camera settings saved","success")},onError:me=>{o(`Failed to update printer: ${me.message}`,"error")}});w.useEffect(()=>{if(!(We.current||!E||!ke||!(ke.auto_archive!==E.auto_archive||ke.save_thumbnails!==E.save_thumbnails||ke.capture_finish_photo!==E.capture_finish_photo||ke.default_filament_cost!==E.default_filament_cost||ke.currency!==E.currency||ke.energy_cost_per_kwh!==E.energy_cost_per_kwh||ke.energy_tracking_mode!==E.energy_tracking_mode||ke.check_updates!==E.check_updates||ke.notification_language!==E.notification_language||ke.ams_humidity_good!==E.ams_humidity_good||ke.ams_humidity_fair!==E.ams_humidity_fair||ke.ams_temp_good!==E.ams_temp_good||ke.ams_temp_fair!==E.ams_temp_fair||ke.ams_history_retention_days!==E.ams_history_retention_days||ke.per_printer_mapping_expanded!==E.per_printer_mapping_expanded||ke.date_format!==E.date_format||ke.time_format!==E.time_format||ke.default_printer_id!==E.default_printer_id||ke.ftp_retry_enabled!==E.ftp_retry_enabled||ke.ftp_retry_count!==E.ftp_retry_count||ke.ftp_retry_delay!==E.ftp_retry_delay||ke.ftp_timeout!==E.ftp_timeout||ke.mqtt_enabled!==E.mqtt_enabled||ke.mqtt_broker!==E.mqtt_broker||ke.mqtt_port!==E.mqtt_port||ke.mqtt_username!==E.mqtt_username||ke.mqtt_password!==E.mqtt_password||ke.mqtt_topic_prefix!==E.mqtt_topic_prefix||ke.mqtt_use_tls!==E.mqtt_use_tls||ke.external_url!==E.external_url||ke.ha_enabled!==E.ha_enabled||ke.ha_url!==E.ha_url||ke.ha_token!==E.ha_token||(ke.library_archive_mode??"ask")!==(E.library_archive_mode??"ask")||Number(ke.library_disk_warning_gb??5)!==Number(E.library_disk_warning_gb??5)||(ke.camera_view_mode??"window")!==(E.camera_view_mode??"window")))&&!De.current)return de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{if(De.current)return;De.current=!0;const He={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};Ze.mutate(He)},500),()=>{de.current&&clearTimeout(de.current)}},[E,ke,Ze]);const lt=w.useCallback((me,He)=>{D(Lt=>Lt?{...Lt,[me]:He}:null)},[]),kt=async(me,He,Lt)=>{if(!He){o("Please enter a camera URL","error");return}$e(jt=>({...jt,[me]:!0})),ye(jt=>({...jt,[me]:null}));try{const jt=await fe.testExternalCamera(me,He,Lt);ye(Wt=>({...Wt,[me]:jt})),jt.success?o(`Camera connected${jt.resolution?` (${jt.resolution})`:""}`,"success"):o(jt.error||"Connection failed","error")}catch(jt){const Wt=jt instanceof Error?jt.message:"Test failed";ye(Rt=>({...Rt,[me]:{success:!1,error:Wt}})),o(Wt,"error")}finally{$e(jt=>({...jt,[me]:!1}))}},[wt,_t]=w.useState({}),Ut=w.useRef({});w.useEffect(()=>{if(gt){const me={};gt.forEach(He=>{He.external_camera_url&&wt[He.id]===void 0&&(me[He.id]=He.external_camera_url)}),Object.keys(me).length>0&&_t(He=>({...He,...me}))}},[gt]);const Le=(me,He)=>{_t(Lt=>({...Lt,[me]:He})),Ut.current[me]&&clearTimeout(Ut.current[me]),Ut.current[me]=setTimeout(()=>{Ge.mutate({id:me,data:{external_camera_url:He||null}})},800)},pt=(me,He)=>{const Lt={};He.type!==void 0&&(Lt.external_camera_type=He.type||null),He.enabled!==void 0&&(Lt.external_camera_enabled=He.enabled),Ge.mutate({id:me,data:Lt})};return ve||!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 ${he==="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 ${he==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ws,{className:"w-4 h-4"}),"Smart Plugs",Fe&&Fe.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Fe.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 ${he==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Sf,{className:"w-4 h-4"}),"Notifications",bt&&bt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:bt.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 ${he==="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 ${he==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(tg,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Ye?.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 ${he==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(df,{className:"w-4 h-4"}),"API Keys",Ot&&Ot.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ot.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 ${he==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Wr,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${Ln?"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 ${he==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(hf,{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 ${he==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(iu,{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"}`})]})]}),he==="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(ir,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(zd,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsx("select",{value:a.language,onChange:me=>a.changeLanguage(me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:Tz.map(me=>s.jsxs("option",{value:me.code,children:[me.nativeName," (",me.name,")"]},me.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:me=>ft(me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:P0.map(me=>s.jsx("option",{value:me.to,children:i(me.labelKey)},me.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:me=>lt("date_format",me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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:me=>lt("time_format",me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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:me=>lt("default_printer_id",me.target.value?Number(me.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(me=>s.jsx("option",{value:me.id,children:me.name},me.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Sidebar order"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:re,children:[s.jsx(dm,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(St,{children:[s.jsx(ir,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(zD,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Mt,{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:me=>{S(me.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:me=>{M(me.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:me=>{v(me.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:me=>{T(me.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:me=>{k(me.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:me=>{A(me.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(ir,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(Mt,{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:me=>lt("auto_archive",me.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:me=>lt("save_thumbnails",me.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:me=>lt("capture_finish_photo",me.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&&Nr&&!Nr.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(An,{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(ir,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(VD,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(Mt,{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:me=>lt("camera_view_mode",me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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(me=>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:me.name}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:me.external_camera_enabled,onChange:He=>pt(me.id,{enabled:He.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"})]})]}),me.external_camera_enabled&&s.jsxs("div",{className:"space-y-2 mt-2",children:[s.jsx("input",{type:"text",placeholder:me.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:wt[me.id]??me.external_camera_url??"",onChange:He=>Le(me.id,He.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:me.external_camera_type||"mjpeg",onChange:He=>pt(me.id,{type:He.target.value}),className:"flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),s.jsx("option",{value:"rtsp",children:"RTSP Stream"}),s.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),s.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>kt(me.id,wt[me.id]??me.external_camera_url??"",me.external_camera_type||"mjpeg"),disabled:je[me.id]||!(wt[me.id]??me.external_camera_url),children:je[me.id]?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),oe[me.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${oe[me.id]?.success?"text-green-500":"text-red-500"}`,children:oe[me.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(On,{className:"w-3 h-3"}),"Connected",oe[me.id]?.resolution&&` (${oe[me.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(na,{className:"w-3 h-3"}),oe[me.id]?.error||"Connection failed"]})})]})]},me.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:"No printers configured"})]})]})]}),s.jsxs(St,{children:[s.jsx(ir,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(Mt,{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:me=>lt("default_filament_cost",parseFloat(me.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:me=>lt("currency",me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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:me=>lt("energy_cost_per_kwh",parseFloat(me.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:me=>lt("energy_tracking_mode",me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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(ir,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ya,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Mt,{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:me=>lt("library_archive_mode",me.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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:me=>lt("library_disk_warning_gb",parseFloat(me.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(ir,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Mt,{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:me=>lt("check_updates",me.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",Or?.version||"..."]})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>yr(),disabled:xi,children:[xi?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(xr,{className:"w-4 h-4"}),"Check now"]})]}),tn?.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",tn.latest_version]}),tn.release_name&&tn.release_name!==tn.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:tn.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[tn.release_notes&&s.jsx("button",{onClick:()=>Se(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),tn.release_url&&s.jsx("a",{href:tn.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"})})]})]}),lr?.status==="downloading"||lr?.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:lr.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:`${lr.progress}%`}})})]}):lr?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:lr.message}):lr?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:lr.error||lr.message}):tn?.is_docker?s.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),s.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):s.jsxs(Me,{className:"mt-3",onClick:()=>st.mutate(),disabled:st.isPending,children:[st.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Hr,{className:"w-4 h-4"}),"Install Update"]})]}):tn?.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: ",tn.error]}):tn&&!tn.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(ir,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(Mt,{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(Me,{variant:"secondary",size:"sm",onClick:()=>Ie(!0),children:[s.jsx(un,{className:"w-4 h-4"}),"Clear"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>$(!0),children:[s.jsx(un,{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(Me,{variant:"secondary",size:"sm",onClick:()=>ie("backup"),children:[s.jsx(iu,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),he==="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(ir,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(zd,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Mt,{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:me=>lt("external_url",me.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(ir,{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(Mt,{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:me=>lt("ftp_retry_enabled",me.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:me=>lt("ftp_retry_count",Math.min(10,Math.max(1,parseInt(me.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:me=>lt("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(me.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:me=>lt("ftp_timeout",Math.min(120,Math.max(10,parseInt(me.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(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(oN,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),E.ha_enabled&&Re&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Re.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Re.success?"text-green-400":"text-red-400"}`,children:Re.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{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:me=>lt("ha_enabled",me.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:me=>lt("ha_url",me.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:me=>lt("ha_token",me.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(Me,{variant:"secondary",size:"sm",disabled:et,onClick:async()=>{Je(!0),Xe(null);try{const me=await fe.testHAConnection(E.ha_url,E.ha_token);Xe(me)}catch(me){Xe({success:!1,message:null,error:me instanceof Error?me.message:"Unknown error"})}finally{Je(!1)}},children:[et?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(tg,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]}),s.jsxs(St,{children:[s.jsx(ir,{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(tg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Ye?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Ye.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Ye.connected?"text-green-400":"text-red-400"}`,children:Ye.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{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:me=>lt("mqtt_enabled",me.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:me=>lt("mqtt_broker",me.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:me=>lt("mqtt_port",Math.min(65535,Math.max(1,parseInt(me.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:me=>{const He=me.target.checked;lt("mqtt_use_tls",He);const Lt=E.mqtt_port??1883;He&&Lt===1883?lt("mqtt_port",8883):!He&&Lt===8883&<("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:me=>lt("mqtt_username",me.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:me=>lt("mqtt_password",me.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:me=>lt("mqtt_topic_prefix",me.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."]})]}),Ye&&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 ${Ye.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Ye.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Ye.broker,":",Ye.port]})]}):"Not connected"})]})})]})]})]})]})]}),Re&&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:[Re.success?s.jsx(On,{className:"w-8 h-8 text-green-400"}):s.jsx(na,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:Re.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:Re.success?Re.message||"Successfully connected to Home Assistant.":Re.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Me,{variant:"primary",onClick:()=>Xe(null),children:"OK"})})]})}),he==="plugs"&&s.jsxs("div",{className:"max-w-4xl",children:[s.jsxs("div",{className:"flex items-start justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ws,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Fe&&Fe.filter(me=>me.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Y("on"),disabled:Zt.isPending,title:"Turn all plugs on",children:[Zt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Mu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Me,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>Y("off"),disabled:Zt.isPending,title:"Turn all plugs off",children:[Zt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(dN,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Me,{className:"whitespace-nowrap",onClick:()=>{O(null),R(!0)},children:[s.jsx(er,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Fe&&Fe.length>0&&s.jsxs(St,{className:"mb-6",children:[s.jsx(ir,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(Vf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",qe&&s.jsx(dt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Mt,{children:Te?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(Vf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Te.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:[Te.reachableCount,"/",Te.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:[Te.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:["~",(Te.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(AK,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Te.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:["~",(Te.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(pP,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Te.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:["~",(Te.totalLifetime*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]})]}):qe?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"})}):Fe&&Fe.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Fe.map(me=>s.jsx(CYe,{plug:me,onEdit:He=>{O(He),R(!0)}},me.id))}):s.jsx(St,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ws,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),s.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),s.jsxs(Me,{onClick:()=>{O(null),R(!0)},children:[s.jsx(er,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),he==="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(Sf,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>J(!0),children:[s.jsx(C0,{className:"w-4 h-4"}),"Log"]}),bt&&bt.length>0&&s.jsxs(Me,{size:"sm",variant:"secondary",onClick:()=>{Ft(null),Yt.mutate()},disabled:Yt.isPending,children:[Yt.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx($D,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Me,{size:"sm",onClick:()=>{K(null),j(!0)},children:[s.jsx(er,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(St,{className:"mb-4",children:s.jsx(Mt,{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:me=>lt("notification_language",me.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:Tz.map(me=>s.jsx("option",{value:me.code,children:me.nativeName},me.code))})]})})}),Ct&&s.jsx(St,{className:"mb-4",children:s.jsxs(Mt,{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:()=>Ft(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(On,{className:"w-4 h-4"}),Ct.success," passed"]}),Ct.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(na,{className:"w-4 h-4"}),Ct.failed," failed"]})]}),Ct.results.filter(me=>!me.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ct.results.filter(me=>!me.success).map(me=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[me.provider_name,":"]})," ",me.message]},me.provider_id))})]})}),Pt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(dt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):bt&&bt.length>0?s.jsx("div",{className:"space-y-3",children:bt.map(me=>s.jsx(PYe,{provider:me,onEdit:He=>{K(He),j(!0)}},me.id))}):s.jsx(St,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Sf,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),s.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),s.jsxs(Me,{size:"sm",onClick:()=>{K(null),j(!0)},children:[s.jsx(er,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(Ya,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),pn?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(me=>s.jsx(St,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Q(me),children:s.jsx(Mt,{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:me.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:me.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:He=>{He.stopPropagation(),Q(me)},children:s.jsx(uN,{className:"w-4 h-4 text-bambu-gray"})})]})})},me.id))}):s.jsx(St,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ya,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),he==="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(df,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),s.jsxs(Me,{size:"sm",onClick:()=>xe(!0),className:"flex-shrink-0",children:[s.jsx(er,{className:"w-4 h-4"}),"Create Key"]})]}),H&&s.jsx(St,{className:"mb-6 border-bambu-green",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(On,{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(Me,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(H);else{const me=document.createElement("textarea");me.value=H,me.style.position="fixed",me.style.left="-999999px",document.body.appendChild(me),me.select(),document.execCommand("copy"),document.body.removeChild(me)}o("Key copied to clipboard")}catch{o("Failed to copy key","error")}},children:s.jsx(ol,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>{ue(H),o("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>ee(null),children:"Dismiss"})]})]})]})})}),Ee&&s.jsxs(St,{className:"mb-6",children:[s.jsx(ir,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(Mt,{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:me=>_e(me.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:me=>Ve(He=>({...He,can_read_status:me.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:me=>Ve(He=>({...He,can_queue:me.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:me=>Ve(He=>({...He,can_control_printer:me.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Control Printer"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(Me,{onClick:()=>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(er,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Me,{variant:"secondary",onClick:()=>xe(!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"})}):Ot&&Ot.length>0?s.jsx("div",{className:"space-y-3",children:Ot.map(me=>s.jsx(St,{children:s.jsx(Mt,{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(df,{className:`w-5 h-5 ${me.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:me.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[me.key_prefix,"••••••••",me.last_used&&` · Last used: ${bg(me.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[me.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),me.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),me.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:()=>B(me.id),children:s.jsx(un,{className:"w-4 h-4 text-red-400"})})]})]})})},me.id))}):s.jsx(St,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(df,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),s.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),s.jsxs(Me,{onClick:()=>xe(!0),children:[s.jsx(er,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(St,{className:"mt-6",children:[s.jsx(ir,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(Mt,{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(zd,{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(Mt,{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:me=>ue(me.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})]})]}),he==="virtual-printer"&&s.jsx(VYe,{}),he==="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(ir,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(Mt,{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(UD,{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:me=>lt("ams_humidity_good",parseInt(me.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:me=>lt("ams_humidity_fair",parseInt(me.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),s.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(fN,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:"Temperature"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_good??28,onChange:me=>lt("ams_temp_good",parseFloat(me.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:me=>lt("ams_temp_fair",parseFloat(me.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(iu,{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:me=>lt("ams_history_retention_days",parseInt(me.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Wr,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:"Print Modal"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:"Expand custom mapping by default"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:"When printing to multiple printers, show per-printer AMS mapping expanded"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.per_printer_mapping_expanded??!1,onChange:me=>lt("per_printer_mapping_expanded",me.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(zn,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{vn.mutate(X),B(null)},onCancel:()=>B(null)}),C&&s.jsx(kYe,{plug:U,onClose:()=>{R(!1),O(null)}}),q&&s.jsx(RYe,{provider:W,onClose:()=>{j(!1),K(null)}}),G&&s.jsx(DYe,{template:G,onClose:()=>Q(null)}),te&&s.jsx(IYe,{onClose:()=>J(!1)}),Ae&&s.jsx(zn,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{Ie(!1);try{const me=await fe.clearNotificationLogs(30);o(me.message,"success")}catch{o("Failed to clear logs","error")}},onCancel:()=>Ie(!1)}),ce&&s.jsx(zn,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{$(!1),localStorage.clear(),o("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>$(!1)}),L&&s.jsx(zn,{title:`Turn All Plugs ${L==="on"?"On":"Off"}`,message:`This will turn ${L==="on"?"ON":"OFF"} all ${Fe?.filter(me=>me.enabled).length||0} enabled smart plugs. ${L==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${L==="on"?"On":"Off"}`,variant:L==="off"?"danger":"warning",onConfirm:()=>{const me=L;Y(null),Zt.mutate(me)},onCancel:()=>Y(null)}),be&&tn?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Se(!1),children:s.jsxs(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:me=>me.stopPropagation(),children:[s.jsxs(ir,{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",tn.latest_version]}),tn.release_name&&tn.release_name!==tn.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:tn.release_name})]}),s.jsx("button",{onClick:()=>Se(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx(Mt,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:tn.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[tn.release_url&&s.jsx("a",{href:tn.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Me,{variant:"secondary",className:"w-full",children:[s.jsx(zr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Me,{onClick:()=>Se(!1),className:"flex-1",children:"Close"})]})]})}),he==="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(hf,{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(Mt,{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(sT,{className:"w-6 h-6 text-green-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Enabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is secured with authentication."})]})]}),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(Me,{onClick:()=>e("/users"),className:"w-full",variant:"secondary",children:[s.jsx(hf,{className:"w-4 h-4"}),"Manage Users"]}),c?.role==="admin"&&s.jsxs(Me,{onClick:()=>Pe(!0),className:"w-full",variant:"secondary",children:[s.jsx(qz,{className:"w-4 h-4"}),"Disable Authentication"]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?s.jsx(sT,{className:"w-6 h-6 text-green-400"}):s.jsx(qz,{className:"w-6 h-6 text-gray-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-white font-medium",children:"Authentication Disabled"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Your Bambuddy instance is currently accessible without authentication."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Enable authentication to:"}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-4",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(On,{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(On,{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(On,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Control access to printer settings and user management"})]})]}),s.jsxs(Me,{type:"button",onClick:me=>{me.preventDefault(),e("/setup")},className:"w-full",children:[s.jsx(sT,{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(wP,{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(ir,{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(wP,{className:"w-4 h-4 text-purple-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"Admin"})]})}),s.jsx(Mt,{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(On,{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(On,{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(On,{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(ir,{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(hf,{className:"w-4 h-4 text-blue-300"})}),s.jsx("h3",{className:"text-white font-medium",children:"User"})]})}),s.jsx(Mt,{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(On,{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(On,{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(On,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:"Manage filament"})]})]})})]})]})]})]}),he==="backup"&&s.jsx(KYe,{}),se&&s.jsx(zn,{title:"Disable Authentication",message:"Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.",confirmText:"Disable Authentication",variant:"danger",onConfirm:async()=>{try{await fe.disableAuth(),o("Authentication disabled successfully","success"),await u(),Pe(!1),window.location.href="/"}catch(me){const He=me instanceof Error?me.message:"Failed to disable authentication";o(He,"error")}},onCancel:()=>Pe(!1)})]})}const Hie=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"},yD=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function Wj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=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(Oo,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Lo,{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:Hie(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(SK,{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(ol,{className:"w-4 h-4"})})]})}function qj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=Gn(),[f,m]=w.useState(t?.name||""),[p,b]=w.useState(t?.k_value?Hie(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,D]=w.useState(!1),[C,R]=w.useState({current:0,total:0}),[U,O]=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 V=yD(z.name||"");J.set(z.filament_id,{id:z.filament_id,name:V||z.filament_id})}return Array.from(J.values()).sort((z,V)=>z.name.localeCompare(V.name))},[r]),j=mt({mutationFn:J=>(console.log("[KProfile] Calling API..."),fe.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)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:J=>{console.error("[KProfile] Save error:",J),d(J.message,"error"),D(!1)}}),W=mt({mutationFn:J=>(console.log("[KProfile] Deleting profile..."),fe.deleteKProfile(e,J)),onSuccess:J=>{console.log("[KProfile] Delete success:",J),d("K-profile deleted"),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:J=>{console.error("[KProfile] Delete error:",J),d(J.message,"error"),D(!1)}}),[K,G]=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})},te=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),V=`${v}-${M}`;if(t||T.length===1){const ae={name:f,k_value:z,filament_id:y,nozzle_id:V,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),j.mutate(ae);return}D(!0),R({current:1,total:T.length});const ne=T.map(ae=>({name:f,k_value:z,filament_id:y,nozzle_id:V,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 fe.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"),D(!1),R({current:0,total:0});return}R({current:T.length,total:T.length}),setTimeout(()=>{D(!1),R({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(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(Mt,{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(Ht,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:te,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),s.jsx("input",{type:"text",value:f,onChange: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 V=q.find(ne=>ne.id===z);V&&m(`${v==="HH00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!t,children:[s.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:q.find(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 V=q.find(ne=>ne.id===y);V&&m(`${z==="HS00"?"HF":"S"} ${V.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[s.jsx("option",{value:"HH00",children:"High Flow"}),s.jsx("option",{value:"HS00",children:"Standard"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),s.jsxs("select",{value:M,onChange: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=>O(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(Me,{type:"button",variant:"secondary",onClick:()=>G(!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(un,{className:"w-4 h-4"})}),s.jsx(Me,{type:"button",variant:"secondary",onClick:l,disabled:E,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{type:"submit",disabled:j.isPending||E,className:"flex-1",children:[j.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(aN,{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(Mt,{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(un,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Me,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>{G(!1),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(un,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const Qw={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function rZe(){const{showToast:t}=Gn(),[e,n]=w.useState(null),[r,i]=w.useState(()=>localStorage.getItem(Qw.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(Qw.SORT_OPTION)||"name"),[M,A]=w.useState(!1),[T,k]=w.useState(new Set),[E,D]=w.useState(!1),[C,R]=w.useState(!1),U=w.useCallback(B=>`${B.slot_id}_${B.extruder_id}`,[]);w.useEffect(()=>{localStorage.setItem(Qw.NOZZLE_DIAMETER,r)},[r]),w.useEffect(()=>{localStorage.setItem(Qw.SORT_OPTION,v)},[v]);const{data:O,isLoading:q}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:j,isLoading:W,isFetching:K,error:G,refetch:Q}=ut({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const B=await fe.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",B?.profiles?.length||0,"profiles"),B},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:te}=ut({queryKey:["kprofiles",e,"0.4"],queryFn:()=>fe.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:J,refetch:z}=ut({queryKey:["kprofile-notes",e],queryFn:()=>fe.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),V=G?.message?.includes("not connected");w.useEffect(()=>{if(!e&&O&&O.length>0){const B=O.find(I=>I.is_active);B&&n(B.id)}},[e,O]),w.useEffect(()=>{if(e){const B=setTimeout(()=>{Q()},150);return()=>clearTimeout(B)}},[e,r]);const ne=O?.filter(B=>B.is_active)||[],ae=Ur.useMemo(()=>j?.profiles?j.profiles.filter(I=>{const ue=f.toLowerCase(),Ae=!ue||I.name.toLowerCase().includes(ue)||I.filament_id.toLowerCase().includes(ue),Ie=p==="all"||p==="left"&&I.extruder_id===1||p==="right"&&I.extruder_id===0,ce=y==="all"||y==="hf"&&I.nozzle_id.startsWith("HH")||y==="s"&&I.nozzle_id.startsWith("HS");return Ae&&Ie&&ce}).sort((I,ue)=>{switch(v){case"k_value":return parseFloat(I.k_value)-parseFloat(ue.k_value);case"filament":return yD(I.name).localeCompare(yD(ue.name));default:return I.name.localeCompare(ue.name)}}):[],[j?.profiles,f,p,y,v]),he=O?.find(B=>B.id===e),pe=he?.nozzle_count===2;w.useEffect(()=>{const B=I=>{I.target instanceof HTMLInputElement||I.target instanceof HTMLTextAreaElement||I.target instanceof HTMLSelectElement||a||l||u||(I.key==="r"||I.key==="R"?(I.preventDefault(),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(!j?.profiles||j.profiles.length===0){t("No profiles to export","error");return}const B={version:1,exported_at:new Date().toISOString(),printer:he?.name||"Unknown",nozzle_diameter:r,profiles:j.profiles.map(Ie=>({name:Ie.name,k_value:Ie.k_value,filament_id:Ie.filament_id,nozzle_id:Ie.nozzle_id,nozzle_diameter:Ie.nozzle_diameter,extruder_id:Ie.extruder_id}))},I=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),ue=URL.createObjectURL(I),Ae=document.createElement("a");Ae.href=ue,Ae.download=`kprofiles_${he?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(ue),t(`Exported ${j.profiles.length} profiles`)},[j?.profiles,he,r,t]),Ee=w.useCallback(()=>{const B=document.createElement("input");B.type="file",B.accept=".json",B.onchange=async I=>{const ue=I.target.files?.[0];if(ue)try{const Ae=await ue.text(),Ie=JSON.parse(Ae);if(!Ie.profiles||!Array.isArray(Ie.profiles)){t("Invalid file format","error");return}let ce=0;for(const $ of Ie.profiles)if(!(!$.name||!$.k_value||!$.filament_id))try{await fe.setKProfile(e,{name:$.name,k_value:parseFloat($.k_value).toFixed(6),filament_id:$.filament_id,nozzle_id:$.nozzle_id||`HH00-${r}`,nozzle_diameter:$.nozzle_diameter||r,extruder_id:$.extruder_id??0,slot_id:0}),ce++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",$.name,L)}t(`Imported ${ce} of ${Ie.profiles.length} profiles`),Q()}catch(Ae){console.error("Import error:",Ae),t("Failed to parse import file","error")}},B.click()},[e,r,t,Q]),xe=w.useCallback(B=>{k(I=>{const ue=new Set(I);return ue.has(B)?ue.delete(B):ue.add(B),ue})},[]),Ne=w.useCallback(()=>{k(new Set(ae.map(B=>U(B))))},[ae,U]),_e=w.useCallback(()=>{T.size!==0&&D(!0)},[T.size]),le=w.useCallback(async()=>{const B=ae.filter(ue=>T.has(U(ue)));R(!0);let I=0;for(const ue of B)try{await fe.deleteKProfile(e,{slot_id:ue.slot_id,extruder_id:ue.extruder_id,nozzle_id:ue.nozzle_id,nozzle_diameter:ue.nozzle_diameter,filament_id:ue.filament_id,setting_id:ue.setting_id}),I++,await new Promise(Ae=>setTimeout(Ae,300))}catch(Ae){console.error("Failed to delete profile:",ue.name,Ae)}t(`Deleted ${I} profiles`),R(!1),D(!1),A(!1),k(new Set),Q()},[e,T,ae,t,Q,U]),Ve=w.useCallback(B=>{const I=[];return B.setting_id&&I.push(B.setting_id),I.push(`slot_${B.slot_id}_${B.filament_id}_${B.extruder_id}`),I.push(`name_${B.name}_${B.filament_id}`),I},[]),H=w.useCallback(async(B,I)=>{if(e)try{await fe.setKProfileNote(e,B,I),z()}catch(ue){console.error("Failed to save note:",ue),t("Failed to save note","error")}},[e,z,t]),ee=w.useCallback(B=>{if(!J?.notes)return{note:"",key:null};const I=Ve(B);for(const ue of I)if(J.notes[ue])return{note:J.notes[ue],key:ue};return{note:"",key:null}},[J,Ve]),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"})}):!O||O.length===0?s.jsx(St,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(aa,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ne.length===0?s.jsx(St,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Wr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),s.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):s.jsxs(s.Fragment,{children:[K&&!W&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(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(Me,{variant:"secondary",onClick:()=>Q(),disabled:K,children:[s.jsx(xr,{className:`w-4 h-4 ${K?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>c(!0),children:[s.jsx(er,{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(Na,{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"})]}),pe&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:p,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All Extruders"}),s.jsx("option",{value:"left",children:"Left Only"}),s.jsx("option",{value:"right",children:"Right Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:y,onChange:B=>x(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All Flow"}),s.jsx("option",{value:"hf",children:"HF Only"}),s.jsx("option",{value:"s",children:"S Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:B=>S(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:"Sort: Name"}),s.jsx("option",{value:"k_value",children:"Sort: K-Value"}),s.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(Me,{variant:"secondary",onClick:ie,disabled:!j?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Hr,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Me,{variant:"secondary",onClick:Ee,title:"Import profiles from JSON",children:[s.jsx(mi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),M?s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:Ne,title:"Select all visible profiles",children:[s.jsx(Oo,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Me,{variant:"secondary",onClick:_e,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[s.jsx(un,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>{A(!1),k(new Set)},children:[s.jsx(Ht,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Me,{variant:"secondary",onClick:()=>A(!0),disabled:!ae.length,title:"Enter selection mode for bulk delete",children:[s.jsx(Oo,{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"})}):V?s.jsx(St,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Zg,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),s.jsxs(Me,{variant:"secondary",onClick:()=>Q(),children:[s.jsx(xr,{className:"w-4 h-4"}),"Retry"]})]})}):ae.length>0?pe?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(Wj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:T.has(U(B)),onToggleSelect:()=>xe(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(Wj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:T.has(U(B)),onToggleSelect:()=>xe(U(B)),note:X(B)},U(B)))})]})]}):s.jsx("div",{className:"space-y-1",children:ae.map(B=>s.jsx(Wj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:M,isSelected:T.has(U(B)),onToggleSelect:()=>xe(U(B)),note:X(B)},U(B)))}):f||p!=="all"||y!=="all"?s.jsx(St,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Na,{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(Mt,{className:"py-12 text-center",children:[s.jsx(aN,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),s.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),s.jsxs(Me,{onClick:()=>c(!0),children:[s.jsx(er,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:B,key:I}=ee(a);return s.jsx(qj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:pe,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(qj,{printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:pe,onSaveNote:H,onClose:()=>{c(!1),Q()},onSave:()=>{c(!1),Q()}}),u&&e&&s.jsx(qj,{printerId:e,nozzleDiameter:r,existingProfiles:te?.profiles||j?.profiles,isDualNozzle:pe,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(Mt,{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(un,{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(Me,{variant:"secondary",onClick:()=>D(!1),disabled:C,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:le,disabled:C,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[C?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function bI(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 by(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function iZe(t){const e=Mi(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}=Gn(),[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:()=>fe.cloudLogin(i,o,m),onSuccess:M=>{M.success?(e("Logged in successfully"),t()):M.needs_verification?(e("Verification code sent to your email"),r("code")):e(M.message,"error")},onError:M=>e(M.message,"error")}),y=mt({mutationFn:()=>fe.cloudVerify(i,c),onSuccess:M=>{M.success?(e("Logged in successfully"),t()):e(M.message,"error")},onError:M=>e(M.message,"error")}),x=mt({mutationFn:()=>fe.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:M=>e(M.message,"error")}),v=M=>{M.preventDefault(),n==="email"?b.mutate():n==="code"?y.mutate():n==="token"&&x.mutate()},S=b.isPending||y.isPending||x.isPending;return s.jsx(St,{className:"max-w-md mx-auto",children:s.jsxs(Mt,{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(nN,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),s.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),s.jsx("input",{type:"email",value:i,onChange:M=>a(M.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:o,onChange:M=>l(M.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),s.jsxs("select",{value:m,onChange:M=>p(M.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"global",children:"Global"}),s.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),s.jsx("input",{type:"text",value:c,onChange:M=>u(M.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),s.jsx("textarea",{value:d,onChange:M=>f(M.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),s.jsxs("div",{className:"flex gap-2",children:[n==="code"&&s.jsx(Me,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Me,{type:"submit",disabled:S,className:"flex-1",children:[S?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(Kz,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(df,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Kz,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function Up({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(Di,{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(pg,{className:"w-5 h-5"})}):null}function Kj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=bI(t.name),c=by(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(ol,{className:"w-4 h-4"})})]})}function vD(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+" "+vD(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)+": "+vD(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function oZe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Gn(),o=on(),[l,c]=w.useState(!1),{data:u,isLoading:d}=ut({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>fe.getCloudSettingDetail(t.setting_id)}),f=mt({mutationFn:()=>fe.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),m=by(t.setting_id),p=bI(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(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),m&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:p.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(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:vD(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(An,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]})]}):s.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Me,{variant:"secondary",onClick:r,children:[s.jsx(ol,{className:"w-4 h-4"}),"Duplicate"]}),m&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(sa,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Me,{variant:"danger",onClick:()=>c(!0),children:s.jsx(un,{className:"w-4 h-4"})})]})]})})]})})})}function Vie(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Gie(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function lZe({onClose:t,onApply:e}){const{showToast:n}=Gn(),[r,i]=w.useState(Vie),[a,o]=w.useState("all"),[l,c]=w.useState(null),[u,d]=w.useState(""),[f,m]=w.useState(""),[p,b]=w.useState("{}"),[y,x]=w.useState(null),[v,S]=w.useState(null),M=a==="all"?r:r.filter(O=>O.type===a),A=O=>{i(O),Gie(O)},T=O=>{const q=r.filter(j=>j.id!==O);A(q),S(null),n("Template deleted")},k=O=>{c(O.id),d(O.name),m(O.description),b(JSON.stringify(O.settings,null,2)),x(null)},E=()=>{if(!(!l||!u.trim()))try{const O=JSON.parse(p),q=r.map(j=>j.id===l?{...j,name:u.trim(),description:f.trim(),settings:O}:j);A(q),c(null),n("Template updated")}catch(O){x(O.message)}},D=()=>{c(null),d(""),m(""),b("{}"),x(null)},C=O=>{const q=r.map(j=>j.id===O?{...j,showInModal:!j.showInModal}:j);A(q)},R={filament:{label:"Filament",icon:FD,color:"text-amber-400"},print:{label:"Process",icon:Zd,color:"text-blue-400"},printer:{label:"Printer",icon:Wr,color:"text-purple-400"}},U=v?r.find(O=>O.id===v):null;return w.useEffect(()=>{const O=q=>{q.key==="Escape"&&(v?S(null):l?D():t())};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[v,l,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[U&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(St,{className:"w-full max-w-md",children:s.jsxs(Mt,{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(An,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),s.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',s.jsx("span",{className:"font-medium",children:U.name}),'"?']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:()=>S(null),className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>T(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(un,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{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(j0,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(O=>s.jsx("button",{onClick:()=>o(O),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===O?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:O==="all"?"All":R[O].label},O))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:M.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(j0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:"No templates yet"}),s.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):s.jsx("div",{className:"space-y-2",children:M.map(O=>{const q=R[O.type],j=q.icon;return l===O.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:u,onChange:W=>d(W.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:f,onChange:W=>m(W.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),s.jsx("textarea",{value:p,onChange:W=>{b(W.target.value),x(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",onClick:E,disabled:!u.trim(),children:[s.jsx(ys,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:D,children:"Cancel"})]})]},O.id):s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[s.jsx(j,{className:`w-5 h-5 ${q.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:O.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:O.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(O.settings).length," fields"]}),s.jsx("button",{onClick:()=>C(O.id),className:`p-1 transition-colors ${O.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:O.showInModal?"Shown in modals":"Hidden in modals",children:O.showInModal?s.jsx(Yd,{className:"w-4 h-4"}):s.jsx(_y,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(O),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>k(O),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(sa,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S(O.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]},O.id)})})})]})})]})}function Wie({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(Mt,{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(eg,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Ht,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),s.jsx("p",{className:"text-white font-medium truncate",children:r})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),s.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(er,{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(vP,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(fP,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(aT,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Na,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:l,onChange:p=>c(p.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>o("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),s.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(aT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:d.map(p=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],y={added:s.jsx(er,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(vP,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(fP,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(aT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[y,s.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(p.right)})})]},p.key)})})]})})]})})})}function cZe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Gn(),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(""),[D,C]=w.useState(!1),[R,U]=w.useState(""),[O,q]=w.useState(!1),[j,W]=w.useState(Vie),[K,G]=w.useState(!1),[Q,te]=w.useState(""),[J,z]=w.useState(""),[V,ne]=w.useState(!0),[ae,he]=w.useState(null),[pe,ie]=w.useState(!1),Ee=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),xe=w.useMemo(()=>Ee.filter(oe=>by(oe.setting_id)),[Ee]),{data:Ne}=ut({queryKey:["cloudFields",c],queryFn:()=>fe.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:_e}=ut({queryKey:["allPresetDetails",c,xe.map(oe=>oe.setting_id).join(",")],queryFn:async()=>{const oe={};for(let je=0;je<xe.length;je+=5){const $e=xe.slice(je,je+5);(await Promise.all($e.map(async re=>{try{const ke=await fe.getCloudSettingDetail(re.setting_id);return{id:re.setting_id,detail:ke}}catch{return null}}))).forEach(re=>{re&&(oe[re.id]=re.detail)})}return oe},enabled:xe.length>0,staleTime:1e3*60*10}),{data:le,isLoading:Ve}=ut({queryKey:["cloudSettingDetail",m],queryFn:()=>fe.getCloudSettingDetail(m),enabled:!!m});w.useEffect(()=>{o!=="json"&&M(JSON.stringify(x,null,2))},[x,o]);const H=w.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(ye=>!by(ye.setting_id)).sort((ye,je)=>ye.name.localeCompare(je.name)),[n,c]);w.useEffect(()=>{if(!m)return;const oe=H.find(ye=>ye.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||[],ye=new Set(oe.map(re=>re.key)),je=new Set,$e=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);_e&&Object.values(_e).forEach(re=>{re?.setting&&Object.keys(re.setting).forEach(ke=>{!ye.has(ke)&&!$e.has(ke)&&je.add(ke)})}),Object.keys(x).forEach(re=>{!ye.has(re)&&!$e.has(re)&&je.add(re)});const ft=Array.from(je).sort().map(re=>({key:re,label:re.replace(/_/g," ").replace(/\b\w/g,ke=>ke.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...oe,...ft]},[Ne,_e,x]),X=ee.filter(oe=>oe.label.toLowerCase().includes(k.toLowerCase())||oe.key.toLowerCase().includes(k.toLowerCase())),B=()=>{if(R.trim()){const oe=R.trim().toLowerCase().replace(/\s+/g,"_");I(oe,""),U(""),q(!1),r(`Field "${oe}" added`)}},I=(oe,ye)=>{v(je=>{const $e={...je};return ye===""||ye===void 0?delete $e[oe]:$e[oe]=ye,$e})},ue=oe=>{v(ye=>({...ye,...oe.settings})),he(oe.name),r("Template applied")},Ae=()=>{if(!Q.trim())return;const oe={...x};if(delete oe.inherits,Object.keys(oe).length===0){r("No overrides to save","error");return}const ye={id:Date.now().toString(),name:Q.trim(),description:J.trim()||"Custom template",type:c,settings:oe,showInModal:V},je=[...j,ye];W(je),Gie(je),G(!1),te(""),z(""),ne(!0),r("Template saved")},Ie=w.useMemo(()=>j.filter(oe=>oe.type===c&&oe.showInModal),[c,j]),ce=oe=>{M(oe);try{const ye=JSON.parse(oe);v(ye),T(null)}catch(ye){T(ye.message)}},$=oe=>{oe.preventDefault(),C(!1);const ye=oe.dataTransfer.files[0];if(ye&&ye.name.endsWith(".json")){const je=new FileReader;je.onload=$e=>{try{const ft=$e.target?.result,re=JSON.parse(ft),ke=re.setting||re;v(ve=>({...ve,...ke})),M(JSON.stringify({...x,...ke},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},je.readAsText(ye)}},L=mt({mutationFn:()=>{const oe={...x},ye=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";oe[ye]=`"${d}"`;const je={type:c,name:d,base_id:m,setting:oe};return fe.createCloudSetting(je)},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 fe.updateCloudSetting(e.setting_id,{name:d,setting:x})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:oe=>r(oe.message,"error")}),be=a?Y:L,Se=le?.setting?.inherits,se=Se?H.find(oe=>oe.name===Se):void 0,{data:Pe}=ut({queryKey:["cloudSettingDetail",se?.setting_id],queryFn:()=>fe.getCloudSettingDetail(se.setting_id),enabled:!!se?.setting_id}),Re=w.useMemo(()=>{const oe=Pe?.setting||{},ye=le?.setting||{},je=m&&_e?.[m]?.setting?_e[m].setting:{};return{...oe,...ye,...je}},[m,le,Pe,_e]),Xe=oe=>{if(oe==null)return"";if(Array.isArray(oe)){const ye=[...new Set(oe.map(je=>String(je)))];return ye.length===1?ye[0]:oe.join(", ")}return String(oe)},et=oe=>{const ye=x[oe.key],je=Re[oe.key],$e=Xe(je),ft=Ve?"Loading...":$e||"",re="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(oe.type==="boolean"){const ke=ye==="1"||ye===void 0&&je==="1";return s.jsx("button",{type:"button",onClick:()=>I(oe.key,ye==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${ke?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${ke?"translate-x-3.5":"translate-x-0.5"}`})})}return oe.type==="select"?s.jsxs("select",{value:ye||"",onChange:ke=>I(oe.key,ke.target.value),className:re,children:[s.jsx("option",{value:"",children:ft}),oe.options?.map(ke=>s.jsx("option",{value:ke.value,children:ke.label},ke.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:oe.type==="number"?"number":"text",value:ye!==void 0?String(ye):"",onChange:ke=>I(oe.key,ke.target.value),step:oe.step,min:oe.min,max:oe.max,placeholder:ft,className:re}),oe.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:oe.unit})]})},Je=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:[pe&&m&&s.jsx(Wie,{onClose:()=>ie(!1),leftPreset:Je,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(Mt,{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(eg,{className:"w-4 h-4"}),"Compare"]}),s.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Ht,{className:"w-5 h-5"})})]})]}),D&&s.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(mi,{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(ts,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:b}),Ve&&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(Xz,{className:"w-4 h-4"}),"Common"]}),s.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(cN,{className:"w-4 h-4"}),"All Fields"]}),s.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(fK,{className:"w-4 h-4"}),"JSON",A&&s.jsx(aa,{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},ye=new Blob([JSON.stringify(oe,null,2)],{type:"application/json"}),je=URL.createObjectURL(ye),$e=document.createElement("a");$e.href=je,$e.download=`${d||"preset"}.json`,document.body.appendChild($e),$e.click(),document.body.removeChild($e),URL.revokeObjectURL(je),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(mi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:oe=>{const ye=oe.target.files?.[0];if(ye){const je=new FileReader;je.onload=$e=>{try{const ft=JSON.parse($e.target?.result),re=ft.setting||ft;v(ke=>({...ke,...re})),r("File imported")}catch{r("Invalid JSON","error")}},je.readAsText(ye)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(j0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(x).filter(oe=>oe!=="inherits").length>0&&s.jsxs("button",{onClick:()=>G(!K),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(ys,{className:"w-3 h-3"}),"Save as template"]})]}),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=>te(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(Me,{size:"sm",onClick:Ae,disabled:!Q.trim(),children:[s.jsx(ys,{className:"w-3 h-3"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>ne(!V),className:`flex items-center gap-1.5 text-xs transition-colors ${V?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[V?s.jsx(Yd,{className:"w-3.5 h-3.5"}):s.jsx(_y,{className:"w-3.5 h-3.5"}),V?"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(ts,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",s.jsx("span",{className:"font-medium",children:ae})]}),s.jsx("button",{onClick:()=>he(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Ht,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Ie.map(oe=>s.jsxs("button",{onClick:()=>ue(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)),Ie.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children: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:et(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,ye])=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[oe,": ",String(ye).slice(0,20),s.jsx("button",{onClick:()=>I(oe,void 0),className:"hover:text-white",children:s.jsx(Ht,{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:_e?`${ee.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Na,{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 ye=Re[oe.key],je=Xe(ye);return s.jsxs("div",{onClick:()=>{v($e=>({...$e,[oe.key]:je||""}))},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:[je&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:je,children:[je.slice(0,20),je.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(er,{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:O?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:R,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(Me,{size:"sm",onClick:B,disabled:!R.trim(),children:s.jsx(er,{className:"w-4 h-4"})}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{q(!1),U("")},children:s.jsx(Ht,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>q(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(er,{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,ye])=>{const je=ee.find($e=>$e.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:je?.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(Ht,{className:"w-4 h-4"})})]}),je?et(je):s.jsx("input",{type:"text",value:String(ye),onChange:$e=>I(oe,$e.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(Xz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"No overrides yet"}),s.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(x).filter(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:()=>{G(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(ys,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[A&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(aa,{className:"w-4 h-4"}),A]}),s.jsx("textarea",{value:S,onChange:oe=>ce(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(Me,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Me,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!a&&!m||!!A,className:"flex-1",children:[be.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(ys,{className:"w-4 h-4"}):s.jsx(er,{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,D]=w.useState(!1),[C,R]=w.useState(null),[U,O]=w.useState(null),[q,j]=w.useState(null),[W,K]=w.useState(!1),[G,Q]=w.useState([null,null]),[te,J]=w.useState(!1),[z,V]=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:bI(X.name)})),[t]),he=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,ue)=>parseFloat(I)-parseFloat(ue)),filaments:Array.from(X).sort(),layerHeights:Array.from(B).sort((I,ue)=>parseFloat(I)-parseFloat(ue))}},[ae,i]),pe=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=by(ee.setting_id);return u==="custom"?X:!X}).filter(ee=>{if(f==="all"||!pe)return!0;const X=ee.meta.printer?.toLowerCase()||"",B=pe.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,pe,p,y,v,a]),Ee=ee=>{if(W){const X=G[0]?.setting_id===ee.setting_id,B=G[1]?.setting_id===ee.setting_id;if(X)Q([G[1],null]);else if(B)Q([G[0],null]);else if(!G[0])Q([ee,null]);else if(G[1]){if(G[0].type!==ee.type)return;Q([G[0],ee])}else{if(G[0].type!==ee.type)return;Q([G[0],ee])}}else A(ee)},xe=ee=>{if(G[0]?.setting_id===ee.setting_id)return 0;if(G[1]?.setting_id===ee.setting_id)return 1},Ne=async ee=>{try{const X=await fe.getCloudSettingDetail(ee.setting_id),B=ee.type==="process"?"print":ee.type;R({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)}},_e=async ee=>{try{ne.removeQueries({queryKey:["cloudSettingDetail",ee.setting_id]});const X=await fe.getCloudSettingDetail(ee.setting_id),B=ee.type==="process"?"print":ee.type;O({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("")},Ve=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(Na,{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(Me,{variant:W?"primary":"secondary",onClick:()=>{W?(K(!1),Q([null,null])):K(!0)},children:[s.jsx(eg,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),s.jsxs(Me,{variant:"secondary",onClick:()=>D(!0),children:[s.jsx(j0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Me,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(xr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Me,{onClick:()=>k(!0),children:[s.jsx(er,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(iN,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(Up,{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(Up,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:ee=>d(ee)}),he.printers.length>0&&s.jsx(Up,{label:"Printer",value:f,options:[{value:"all",label:"All"},...he.printers.map(ee=>({value:ee.id,label:ee.name}))],onChange:m}),he.nozzles.length>0&&s.jsx(Up,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...he.nozzles.map(ee=>({value:ee,label:ee}))],onChange:b}),he.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(Up,{label:"Filament",value:y,options:[{value:"all",label:"All"},...he.filaments.map(ee=>({value:ee,label:ee}))],onChange:x}),he.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(Up,{label:"Layer",value:v,options:[{value:"all",label:"All"},...he.layerHeights.map(ee=>({value:ee,label:ee}))],onChange:S}),Ve&&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(eg,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),s.jsx("span",{className:"text-bambu-gray",children:G[0]?`Select another ${G[0].type} preset`:"Click two presets of the same type to compare"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[0]?G[0].name:"1. Select first"}),s.jsx(fP,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[1]?G[1].name:"2. Select second"})]}),G[0]&&G[1]&&s.jsxs(Me,{size:"sm",onClick:async()=>{try{const[ee,X]=await Promise.all([fe.getCloudSettingDetail(G[0].setting_id),fe.getCloudSettingDetail(G[1].setting_id)]);V([ee.setting||{},X.setting||{}]),J(!0)}catch{}},children:[s.jsx(eg,{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(Xn,{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(cl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Ve&&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(FD,{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(Kj,{setting:ee,onClick:()=>Ee(ee),onDuplicate:()=>Ne(ee),compareMode:W,isCompareSelected:xe(ee)!==void 0,compareIndex:xe(ee),compareDisabled:W&&!!G[0]&&G[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(Zd,{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(Kj,{setting:ee,onClick:()=>Ee(ee),onDuplicate:()=>Ne(ee),compareMode:W,isCompareSelected:xe(ee)!==void 0,compareIndex:xe(ee),compareDisabled:W&&!!G[0]&&G[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(Wr,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",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(Kj,{setting:ee,onClick:()=>Ee(ee),onDuplicate:()=>Ne(ee),compareMode:W,isCompareSelected:xe(ee)!==void 0,compareIndex:xe(ee),compareDisabled:W&&!!G[0]&&G[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:()=>_e(M)}),(T||C||U||q)&&s.jsx(cZe,{onClose:()=>{k(!1),R(null),O(null),j(null)},initialData:U||C||(q?{type:q.type,name:"",base_id:"",setting:q.setting}:void 0),allPresets:t}),E&&s.jsx(lZe,{onClose:()=>D(!1),onApply:ee=>{j({type:ee.type,setting:ee.settings}),D(!1)}}),te&&z&&G[0]&&G[1]&&s.jsx(Wie,{onClose:()=>{J(!1),V(null)},leftPreset:z[0],rightPreset:z[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function dZe(){const t=on(),{showToast:e}=Gn(),[n,r]=w.useState("cloud"),[i,a]=w.useState(),{data:o,isLoading:l}=ut({queryKey:["cloudStatus"],queryFn:fe.getCloudStatus}),{data:c=[]}=ut({queryKey:["printers"],queryFn:fe.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:m}=ut({queryKey:["cloudSettings"],queryFn:()=>fe.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});w.useEffect(()=>{m&&a(new Date(m))},[m]);const p=mt({mutationFn:fe.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(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(nN,{className:"w-4 h-4"}),"Cloud Profiles"]}),s.jsxs("button",{onClick:()=>r("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(aN,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&s.jsxs(s.Fragment,{children:[o?.is_authenticated&&s.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",s.jsx("span",{className:"text-white",children:o.email})]})]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx(yP,{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(Me,{onClick:()=>f(),children:"Retry"})]}):s.jsx(aZe,{onSuccess:b})]}),n==="kprofiles"&&s.jsx(rZe,{}),s.jsx(sZe,{})]})}const Jb={Droplet:FD,Flame:ehe,Ruler:Pfe,Sparkles:j0,Square:Lo,Cable:Xue,Wrench:Qd,Calendar:oi,Timer:Cd,Cog:Ade,Fan:mK,Zap:Vf,Wind:TK,Thermometer:fN,Layers:cl,Box:Bs,Target:MK,RefreshCw:xr,Settings:hN,Filter:iN,CircleDot:mde};function S0(t){return t&&Jb[t]||Qd}function zp(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function Xj(t,e){return e==="days"?t===1?"1 day":t===7?"1 week":t===14?"2 weeks":t===30?"1 month":t===60?"2 months":t===90?"3 months":t===180?"6 months":t===365?"1 year":`${t} days`:`${t}h`}function 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=S0(t.maintenance_type_icon),i=t.interval_type||"hours",o=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),l=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${zp(Math.abs(f),"days")}`:t.is_warning?`Due in ${zp(f,"days")}`:`${zp(f,"days")} left`}else return t.is_due?`Overdue by ${zp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${zp(t.hours_until_due,"hours")}`:`${zp(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(An,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(Xn,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(ts,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Hn,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Me,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(dm,{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(An,{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(Xn,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&s.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(ts,{className:"w-3 h-3"}),"All good"]})]})]}),s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?s.jsx(fu,{className:"w-4 h-4"}):s.jsx(Di,{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(Cd,{className:"w-4 h-4 text-bambu-gray"})}),o?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:c,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&m(),p.key==="Escape"&&l(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),s.jsx(Me,{size:"sm",onClick:m,children:"Save"}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):s.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[s.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",s.jsx($f,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=S0(f.maintenance_type_icon);return s.jsx(p,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),s.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&s.jsx(Mt,{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"),[D,C]=w.useState(""),[R,U]=w.useState(new Set),[O,q]=w.useState(null),j=w.useMemo(()=>t?t.map(B=>({id:B.printer_id,name:B.printer_name})):[],[t]),W=B=>t?t.filter(I=>I.maintenance_items.some(ue=>ue.maintenance_type_id===B)).map(I=>({printerId:I.printer_id,printerName:I.printer_name,itemId:I.maintenance_items.find(ue=>ue.maintenance_type_id===B)?.id})):[],K=B=>{if(!t)return[];const I=new Set(W(B).map(ue=>ue.printerId));return j.filter(ue=>!I.has(ue.id))},[G,Q]=w.useState(null),[te,J]=w.useState(""),[z,V]=w.useState(""),[ne,ae]=w.useState("hours"),[he,pe]=w.useState("Wrench"),[ie,Ee]=w.useState(""),xe=B=>{Q(B),J(B.name),V(B.default_interval_hours.toString()),ae(B.interval_type||"hours"),pe(B.icon||"Wrench"),Ee(B.wiki_url||"")},Ne=()=>{G&&te.trim()&&parseFloat(z)>0&&(i(G.id,{name:te.trim(),default_interval_hours:parseFloat(z),interval_type:ne,icon:he,wiki_url:ie.trim()||null}),Q(null))},_e=(B,I,ue)=>{const Ae=parseFloat(d);if(!isNaN(Ae)&&Ae>0){const Ie=Math.abs(Ae-I)<.01?null:Ae;n(B,{custom_interval_hours:Ie,custom_interval_type:m!==ue?m:null})}u(null)},le=B=>{B.preventDefault(),x.trim()&&parseFloat(S)>0&&R.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(S),interval_type:A,icon:k,wiki_url:D.trim()||null},Array.from(R)),v(""),M("100"),T("hours"),C(""),U(new Set),y(!1))},Ve=B=>{U(I=>{const ue=new Set(I);return ue.has(B)?ue.delete(B):ue.add(B),ue})},H=t?.map(B=>({printerId:B.printer_id,printerName:B.printer_name,items:B.maintenance_items.sort((I,ue)=>I.maintenance_type_id-ue.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(Me,{onClick:()=>y(!b),children:[s.jsx(er,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&s.jsx(St,{className:"mb-6",children:s.jsx(Mt,{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(Jb).map(B=>{const I=Jb[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:D,onChange:B=>C(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:j.map(B=>s.jsx("button",{type:"button",onClick:()=>Ve(B.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has(B.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:B.name},B.id))}),R.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:()=>{y(!1),U(new Set)},children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!x.trim()||R.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[ee.map(B=>{const I=S0(B.icon),ue=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:[ue==="days"?s.jsx(oi,{className:"w-3 h-3"}):s.jsx(Cd,{className:"w-3 h-3"}),Xj(B.default_interval_hours,ue)]})]})]})},B.id)}),X.map(B=>{const I=S0(B.icon),ue=B.interval_type||"hours";if(G?.id===B.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:te,onChange:L=>J(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:ne,onChange:L=>ae(L.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:z,onChange:L=>V(L.target.value),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(Jb).map(L=>{const Y=Jb[L];return s.jsx("button",{type:"button",onClick:()=>pe(L),className:`p-1.5 rounded transition-colors ${he===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(Y,{className:"w-3.5 h-3.5"})},L)})}),s.jsx("input",{type:"url",value:ie,onChange:L=>Ee(L.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"Documentation link (optional)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Me,{size:"sm",onClick:Ne,disabled:!te.trim(),children:"Save"}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>Q(null),children:"Cancel"})]})]})},B.id);const Ie=W(B.id),ce=K(B.id),$=O===B.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(I,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:B.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[ue==="days"?s.jsx(oi,{className:"w-3 h-3"}):s.jsx(Cd,{className:"w-3 h-3"}),Xj(B.default_interval_hours,ue)]})]}),s.jsxs("button",{onClick:()=>q($?null:B.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Ie.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:`${Ie.length} printer(s) assigned - click to manage`,children:[s.jsx(Wr,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:Ie.length}),s.jsx(Di,{className:`w-3 h-3 transition-transform ${$?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>xe(B),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx($f,{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(un,{className:"w-4 h-4"})})]}),$&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),Ie.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:Ie.map(L=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[L.printerName,s.jsx("button",{onClick:()=>L.itemId&&l(L.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},L.printerId))}),ce.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:"}),ce.map(L=>s.jsxs("button",{onClick:()=>o(L.id,B.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",L.name]},L.id))]})]})]},B.id)})]})]}),H.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),s.jsx("div",{className:"space-y-4",children:H.map(B=>s.jsx(St,{children:s.jsxs(Mt,{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 ue=S0(I.maintenance_type_icon),Ae=e.find(Y=>Y.id===I.maintenance_type_id),Ie=Ae?.default_interval_hours||I.interval_hours,ce=Ae?.interval_type||"hours",$=I.interval_type||"hours",L=c===I.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(ue,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:I.maintenance_type_name}),L?s.jsxs("div",{className:"flex items-center gap-1",children:[m==="days"?s.jsx(oi,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(Cd,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:m,onChange:Y=>p(Y.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:d,onChange:Y=>f(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&_e(I.id,Ie,ce),Y.key==="Escape"&&u(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),s.jsx(Me,{size:"sm",onClick:()=>_e(I.id,Ie,ce),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(Cd,{className:"w-3 h-3"}),Xj(I.interval_hours,$),s.jsx($f,{className:"w-3 h-3 text-bambu-gray"})]})]},I.id)})})]})},B.printerId))})]}),H.length===0&&s.jsx(St,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx(Xn,{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}=Gn(),[n,r]=w.useState("status"),{data:i,isLoading:a}=ut({queryKey:["maintenanceOverview"],queryFn:fe.getMaintenanceOverview}),{data:o}=ut({queryKey:["maintenanceTypes"],queryFn:fe.getMaintenanceTypes}),l=mt({mutationFn:({id:M,notes:A})=>fe.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})=>fe.updateMaintenanceItem(M,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{e(M.message,"error")}}),u=mt({mutationFn:({id:M,data:A})=>fe.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:fe.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})=>fe.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})=>fe.assignMaintenanceType(M,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:M=>{e(M.message,"error")}}),p=mt({mutationFn:fe.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:M=>{e(M.message,"error")}}),b=M=>{l.mutate({id:M})},y=(M,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(Mt,{className:"text-center py-16",children:[s.jsx(Qd,{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 fe.createMaintenanceType(M);for(const k of A)await fe.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 mq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function qie({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||mq[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:mq.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(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{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:tN,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Ja,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:Xn,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:Aa,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(Fd,{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($f,{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(un,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?s.jsxs("div",{className:"space-y-3",children:[t.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Plates"}),s.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Parts"}),s.jsxs("span",{className:a>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(a,100)}%`,background:a>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${a>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," failed"]})]}):t.completed_count>0||t.failed_count>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Ja,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," completed"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(An,{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(Xn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(m=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:m.print_name||"Unknown",children:[m.thumbnail_path?s.jsx("img",{src:fe.getArchiveThumbnail(m.id),alt:m.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(Ql,{className:"w-6 h-6"})}),m.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(An,{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(cl,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," plates"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:"Parts printed",children:[s.jsx(Ql,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," parts"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed parts",children:[s.jsx(An,{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(bP,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Zs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function bZe(){const t=pl(),e=on(),{showToast:n}=Gn(),[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:()=>fe.getProjects(l==="all"?void 0:l)}),p=mt({mutationFn:U=>fe.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:O})=>fe.updateProject(U,O),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:U=>{n(U.message,"error")}}),y=mt({mutationFn:U=>fe.deleteProject(U),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:U=>{d(null),n(U.message,"error")}}),x=mt({mutationFn:U=>fe.importProject(U),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")},onError:U=>{n(U.message,"error")}}),v=w.useRef(null),S=async()=>{try{const U=await fe.getProjects(),O=await Promise.all(U.map(async K=>await fe.exportProjectJson(K.id))),q=new Blob([JSON.stringify(O,null,2)],{type:"application/json"}),j=URL.createObjectURL(q),W=document.createElement("a");W.href=j,W.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,W.click(),URL.revokeObjectURL(j),n("Projects exported (metadata only)","success")}catch(U){n(U.message,"error")}},M=()=>{v.current?.click()},A=async U=>{const O=U.target.files?.[0];if(O){try{if(O.name.toLowerCase().endsWith(".zip")){const j=new FormData;j.append("file",O);const W=await fetch("/api/v1/projects/import/file",{method:"POST",body:j});if(!W.ok){const K=await W.json();throw new Error(K.detail||"Import failed")}e.invalidateQueries({queryKey:["projects"]}),n("Project imported","success")}else{const j=await O.text(),W=JSON.parse(j),K=Array.isArray(W)?W:[W];for(const G of K)await x.mutateAsync(G);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}`)},D=U=>{d(U)},C=()=>{u!==null&&y.mutate(u)},R=f?.reduce((U,O)=>(U[O.status]=(U[O.status]||0)+1,U.all=(U.all||0)+1,U),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:v,type:"file",accept:".json,.zip",onChange: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(Aa,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",onClick:M,title:"Import project",children:[s.jsx(mi,{className:"w-4 h-4 mr-2"}),"Import"]}),s.jsxs(Me,{variant:"secondary",onClick:S,title:"Export all projects",children:[s.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Me,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(er,{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:Xn},{key:"completed",label:"Completed",icon:tN},{key:"archived",label:"Archived",icon:Ja},{key:"all",label:"All",icon:Aa}].map(({key:U,label:O,icon:q})=>s.jsxs("button",{onClick:()=>c(U),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===U?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(q,{className:"w-4 h-4"}),s.jsx("span",{children:O}),R[U]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===U?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:R[U]})]},U))}),m?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(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(Aa,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&s.jsxs(Me,{onClick:()=>i(!0),children:[s.jsx(er,{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:()=>D(U.id)},U.id))}),u!==null&&s.jsx(zn,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:C,onCancel:()=>d(null)}),r&&s.jsx(qie,{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 pq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(St,{children:s.jsx(Mt,{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(Ql,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No prints in this project yet"})]}):s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>s.jsxs(gs,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?s.jsx("img",{src:fe.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(Ql,{className:"w-8 h-8"})}),e.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(na,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(On,{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(An,{className:"w-3 h-3"}),r]})}function MZe(t){return t?bg(t,{year:"numeric",month:"short",day:"numeric"}):""}function Yj(t){if(!t)return null;const e=Mi(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}=ED(),e=pl(),n=on(),{showToast:r}=Gn(),[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:()=>fe.getProject(d),enabled:d>0}),{data:b,isLoading:y}=ut({queryKey:["project-archives",d],queryFn:()=>fe.getProjectArchives(d),enabled:d>0}),{data:x,isLoading:v}=ut({queryKey:["project-bom",d],queryFn:()=>fe.getProjectBOM(d),enabled:d>0}),{data:S,isLoading:M}=ut({queryKey:["project-timeline",d],queryFn:()=>fe.getProjectTimeline(d,20),enabled:d>0}),{data:A}=ut({queryKey:["settings"],queryFn:fe.getSettings}),{data:T}=ut({queryKey:["project-folders",d],queryFn:()=>fe.getLibraryFoldersByProject(d),enabled:d>0}),k=A?.currency||"$",E=A?.time_format||"system",D=mt({mutationFn:ye=>fe.updateProject(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:ye=>{r(ye.message,"error")}}),C=()=>{u(f?.notes||""),l(!0)},R=()=>{D.mutate({notes:c})},U=()=>{l(!1),u("")},[O,q]=w.useState(""),[j,W]=w.useState(1),[K,G]=w.useState(""),[Q,te]=w.useState(""),[J,z]=w.useState(""),[V,ne]=w.useState(!1),[ae,he]=w.useState(!1),[pe,ie]=w.useState(null),[Ee,xe]=w.useState(""),[Ne,_e]=w.useState(1),[le,Ve]=w.useState(""),[H,ee]=w.useState(""),[X,B]=w.useState(""),[I,ue]=w.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ae=mt({mutationFn:ye=>fe.createBOMItem(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),q(""),W(1),G(""),te(""),z(""),ne(!1),r("Part added","success")},onError:ye=>r(ye.message,"error")}),Ie=mt({mutationFn:({itemId:ye,data:je})=>fe.updateBOMItem(d,ye,je),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),ie(null)},onError:ye=>r(ye.message,"error")}),ce=mt({mutationFn:ye=>fe.deleteBOMItem(d,ye),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:ye=>r(ye.message,"error")}),$=ye=>{ye.preventDefault(),O.trim()&&Ae.mutate({name:O.trim(),quantity_needed:j,unit_price:K?parseFloat(K):void 0,sourcing_url:Q.trim()||void 0,remarks:J.trim()||void 0})},L=ye=>{const je=ye.is_complete?0:ye.quantity_needed;Ie.mutate({itemId:ye.id,data:{quantity_acquired:je}})},Y=(ye,je)=>{ue({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${je}"?`,onConfirm:()=>{ue($e=>({...$e,isOpen:!1})),ce.mutate(ye)}})},be=ye=>{ie(ye),xe(ye.name),_e(ye.quantity_needed),Ve(ye.unit_price?.toString()||""),ee(ye.sourcing_url||""),B(ye.remarks||"")},Se=ye=>{ye.preventDefault(),!(!pe||!Ee.trim())&&Ie.mutate({itemId:pe.id,data:{name:Ee.trim(),quantity_needed:Ne,unit_price:le?parseFloat(le):void 0,sourcing_url:H.trim()||void 0,remarks:X.trim()||void 0}})},se=()=>{ie(null)},Pe=async()=>{try{const ye=await fetch(`/api/v1/projects/${d}/export`);if(!ye.ok)throw new Error("Export failed");const je=await ye.blob(),$e=URL.createObjectURL(je),ft=document.createElement("a");ft.href=$e;const ke=ye.headers.get("Content-Disposition")?.match(/filename="(.+)"/);ft.download=ke?.[1]||`${f?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,ft.click(),URL.revokeObjectURL($e),r("Project exported","success")}catch(ye){r(ye.message,"error")}},Re=mt({mutationFn:()=>fe.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:ye=>r(ye.message,"error")}),Xe=ye=>yg(ye,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(Me,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const et=f.stats,Je=et?.progress_percent??0,oe=et?.parts_progress_percent??0;return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(gs,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Zs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:f.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(uK,{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(Me,{variant:"secondary",onClick:Pe,title:"Export project",children:[s.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Export"]}),s.jsxs(Me,{onClick:()=>a(!0),children:[s.jsx($f,{className:"w-4 h-4 mr-2"}),"Edit"]})]})]}),(f.target_count||f.target_parts_count)&&s.jsx(St,{children:s.jsxs(Mt,{className:"p-4 space-y-4",children:[f.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Plates Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[et?.total_archives||0," / ",f.target_count," print jobs"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Je,100)}%`,backgroundColor:Je>=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:[Je.toFixed(0),"% complete"]}),et?.remaining_prints!=null&&et.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[et.remaining_prints," remaining"]})]})]}),f.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Parts Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[et?.completed_prints||0," / ",f.target_parts_count," parts"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(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"]}),et?.remaining_parts!=null&&et.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[et.remaining_parts," remaining"]})]})]})]})}),et&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(St,{children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(Ql,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Print Jobs"}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[et.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),et.failed_prints>0&&s.jsxs("p",{className:"text-sm text-status-error",children:[et.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[et.completed_prints," parts printed"]})]})]})})}),s.jsx(pq,{icon:Xn,label:"Print Time",value:yZe(et.total_print_time_hours),color:"text-yellow-400"}),s.jsx(pq,{icon:Wr,label:"Filament Used",value:vZe(et.total_filament_grams),color:"text-purple-400"})]}),et&&(et.estimated_cost>0||f.budget)&&s.jsx(St,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[k,et.estimated_cost.toFixed(2)]})]}),et.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[et.total_energy_kwh.toFixed(2)," kWh",et.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",k,et.total_energy_cost.toFixed(2),")"]})]})]}),f.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[k,f.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),s.jsxs("p",{className:`text-lg font-semibold ${f.budget-et.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[k,(f.budget-et.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(St,{children:s.jsxs(Mt,{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(ye=>s.jsxs(gs,{to:`/projects/${ye.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:ye.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:ye.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${ye.status==="completed"?"bg-status-ok/20 text-status-ok":ye.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:ye.status})]}),ye.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[ye.progress_percent.toFixed(0),"%"]})]},ye.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(cl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(gs,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),s.jsx(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)}),Yj(f.due_date)&&s.jsxs("span",{className:`text-xs ${Yj(f.due_date).color}`,children:["(",Yj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xg,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((ye,je)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:ye.trim()},je))})]})]}),s.jsx(St,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ya,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{variant:"secondary",size:"sm",onClick:U,disabled:D.isPending,children:[s.jsx(Ht,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Me,{size:"sm",onClick:R,disabled:D.isPending,children:[D.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(ys,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx($f,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(fD,{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(Mt,{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(ll,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(gs,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),T&&T.length>0?s.jsx("div",{className:"space-y-2",children:T.map(ye=>s.jsxs(gs,{to:`/files?folder=${ye.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(ll,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:ye.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[ye.file_count," file",ye.file_count!==1?"s":""]})]})]}),s.jsx(Zs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},ye.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No folders linked. Go to File Manager and link a folder to this project."})]})}),s.jsx(St,{children:s.jsxs(Mt,{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(wK,{className:"w-5 h-5"}),"Bill of Materials",et&&et.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",et.bom_completed_items,"/",et.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[x&&x.some(ye=>ye.is_complete)&&s.jsx("button",{onClick:()=>he(!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"}),!V&&s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>ne(!0),children:[s.jsx(er,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),V&&s.jsxs("form",{onSubmit:$,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:O,onChange:ye=>q(ye.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name (e.g., M3x8 screws)",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:j,onChange:ye=>W(parseInt(ye.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),s.jsx("input",{type:"number",step:"0.01",value:K,onChange:ye=>G(ye.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${k})`})]})]}),s.jsx("input",{type:"url",value:Q,onChange:ye=>te(ye.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),s.jsx("input",{type:"text",value:J,onChange:ye=>z(ye.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:()=>ne(!1),children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!O.trim()||Ae.isPending,children:Ae.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(ye=>!ae||!ye.is_complete).map(ye=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${ye.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:pe?.id===ye.id?s.jsxs("form",{onSubmit:Se,className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:Ee,onChange:je=>xe(je.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:je=>_e(parseInt(je.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:je=>Ve(je.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:je=>ee(je.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:je=>B(je.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Me,{type:"button",variant:"secondary",size:"sm",onClick:se,children:"Cancel"}),s.jsx(Me,{type:"submit",size:"sm",disabled:!Ee.trim()||Ie.isPending,children:Ie.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:()=>L(ye),disabled:Ie.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${ye.is_complete?"bg-status-ok border-status-ok text-white":"border-bambu-gray hover:border-bambu-green"}`,children:ye.is_complete&&s.jsx(On,{className:"w-3 h-3"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("p",{className:`text-sm font-medium ${ye.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[ye.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",ye.quantity_needed]})]}),ye.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[k,(ye.unit_price*ye.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>be(ye),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0",title:"Edit",children:s.jsx(sa,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Y(ye.id,ye.name),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]})]}),ye.sourcing_url&&s.jsxs("a",{href:ye.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:je=>je.stopPropagation(),children:[s.jsx(zr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(ye.sourcing_url).hostname.replace("www.","")}catch{return ye.sourcing_url}})()})]}),ye.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:ye.remarks})]})]})},ye.id)),x.some(ye=>ye.unit_price!==null)&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),s.jsxs("span",{className:"text-white font-medium",children:[k,x.reduce((ye,je)=>ye+(je.unit_price||0)*je.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(Mt,{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(C0,{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((ye,je)=>s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${ye.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":ye.event_type==="print_failed"?"bg-status-error/20 text-status-error":ye.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[ye.event_type==="print_completed"&&s.jsx(On,{className:"w-4 h-4"}),ye.event_type==="print_failed"&&s.jsx(na,{className:"w-4 h-4"}),ye.event_type==="print_started"&&s.jsx(Wr,{className:"w-4 h-4"}),ye.event_type==="queued"&&s.jsx(bP,{className:"w-4 h-4"}),ye.event_type==="project_created"&&s.jsx(er,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:ye.title}),ye.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:ye.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:Xe(ye.timestamp)})]})]},je))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!f.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>Re.mutate(),disabled:Re.isPending,children:[Re.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(ol,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),et&&(et.queued_prints>0||et.in_progress_prints>0)&&s.jsx(St,{children:s.jsxs(Mt,{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(bP,{className:"w-5 h-5"}),"Queue"]}),s.jsx(gs,{to:`/queue?project=${d}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[et.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[et.in_progress_prints," printing"]}),et.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[et.queued_prints," queued"]})]})]})}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-4",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ql,{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(qie,{project:{...f,archive_count:et?.total_archives||0,total_items:et?.total_items||0,completed_count:et?.completed_prints||0,failed_count:et?.failed_prints||0,queue_count:et?.queued_prints||0,progress_percent:et?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:ye=>D.mutate(ye),isLoading:D.isPending}),I.isOpen&&s.jsx(zn,{title:I.title,message:I.message,confirmText:"Delete",variant:"danger",onConfirm:I.onConfirm,onCancel:()=>ue(ye=>({...ye,isOpen:!1}))})]})}function qp(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(Me,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{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(Me,{type:"button",variant:"secondary",onClick:n,children:"Cancel"}),s.jsx(Me,{type:"submit",disabled:!a.trim()||a.trim()===e||i,children:i?s.jsx(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(ll,{className:"w-4 h-4"}),d.name,d.id===n&&s.jsx("span",{className:"text-xs text-bambu-gray ml-auto",children:"(current)"})]},d.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Me,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Me,{onClick:()=>i(o),disabled:a,children:a?s.jsx(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:()=>fe.getProjects()}),{data:u}=ut({queryKey:["archives-for-link"],queryFn:()=>fe.getArchives(void 0,void 0,100)}),d=()=>{n(i==="project"?{project_id:o,archive_id:0}:{project_id:0,archive_id:o})},f=()=>{n({project_id:0,archive_id:0})},m=t.project_id||t.archive_id;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Gl,{className:"w-5 h-5 text-bambu-green"}),"Link Folder"]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:['Link "',s.jsx("span",{className:"text-white",children:t.name}),'" to a project or archive for quick access.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>{a("project"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(hK,{className:"w-4 h-4"}),"Project"]}),s.jsxs("button",{onClick:()=>{a("archive"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(Ja,{className:"w-4 h-4"}),"Archive"]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:i==="project"?c&&c.length>0?c.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:p.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:p.name})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(p=>s.jsxs("button",{onClick:()=>l(p.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===p.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(Mf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:p.print_name||p.filename})]},p.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No archives found"})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&s.jsxs(Me,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(HD,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Me,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Me,{onClick:d,disabled:!o||r,children:r?s.jsx(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=R=>{R.preventDefault(),o(!0)},y=R=>{R.preventDefault(),o(!1)},x=R=>{R.preventDefault(),o(!1);const U=Array.from(R.dataTransfer.files);S(U)},v=R=>{R.target.files&&S(Array.from(R.target.files))},S=R=>{const U=R.map(O=>({file:O,status:"pending",isZip:O.name.toLowerCase().endsWith(".zip")}));i(O=>[...O,...U])},M=R=>{i(U=>U.filter((O,q)=>q!==R))},A=r.some(R=>R.isZip&&R.status==="pending"),T=async()=>{if(r.length!==0){c(!0);for(let R=0;R<r.length;R++)if(r[R].status==="pending"){i(U=>U.map((O,q)=>q===R?{...O,status:"uploading"}:O));try{if(r[R].isZip){const U=await fe.extractZipFile(r[R].file,t,u,f);i(O=>O.map((q,j)=>j===R?{...q,status:U.errors.length>0&&U.extracted===0?"error":"success",extractedCount:U.extracted,error:U.errors.length>0?`${U.errors.length} files failed`:void 0}:q))}else await fe.uploadLibraryFile(r[R].file,t),i(U=>U.map((O,q)=>q===R?{...O,status:"success"}:O))}catch(U){i(O=>O.map((q,j)=>j===R?{...q,status:"error",error:U instanceof Error?U.message:"Upload failed"}:q))}}c(!1),n(),e()}},k=r.filter(R=>R.status==="pending").length,E=r.filter(R=>R.status==="success").length,D=r.filter(R=>R.status==="error").length,C=r.length>0&&k===0&&!l;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Upload Files"}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:b,onDragLeave:y,onDrop:x,onClick:()=>p.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${a?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[s.jsx(mi,{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(Ja,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-blue-300 font-medium",children:"ZIP files detected"}),s.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:"ZIP files will be extracted. Choose how to handle folder structure:"}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:R=>d(R.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:"Preserve folder structure from ZIP"})]}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:f,onChange:R=>m(R.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:"Create folder from ZIP filename"})]})]})]})}),r.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((R,U)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[R.isZip?s.jsx(Ja,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(rN,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:R.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(R.file.size/1024/1024).toFixed(2)," MB",R.isZip&&R.status==="pending"&&s.jsx("span",{className:"text-blue-400 ml-2",children:"• Will be extracted"}),R.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",R.extractedCount," files extracted"]})]})]}),R.status==="pending"&&s.jsx("button",{onClick:()=>M(U),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Ht,{className:"w-4 h-4 text-bambu-gray"})}),R.status==="uploading"&&s.jsx(dt,{className:"w-4 h-4 text-bambu-green animate-spin"}),R.status==="success"&&s.jsx(On,{className:"w-4 h-4 text-green-500"}),R.status==="error"&&s.jsx("span",{title:R.error,children:s.jsx(na,{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",D>0&&s.jsxs("span",{className:"text-red-400",children:[", ",D," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Me,{variant:"secondary",onClick:e,children:C?"Close":"Cancel"}),!C&&s.jsx(Me,{onClick: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(mi,{className:"w-4 h-4 mr-2"}),"Upload ",k>0?`(${k})`:""]})})]})]})})}function Kie({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0}){const[l,c]=w.useState(!0),[u,d]=w.useState(!1),f=t.children.length>0,m=t.project_id||t.archive_id;return s.jsxs("div",{children:[s.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(t.id),children:[f?s.jsx("button",{onClick:p=>{p.stopPropagation(),c(!l)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Zs,{className:`w-3.5 h-3.5 transition-transform ${l?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(ll,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm truncate flex-1",title:t.name,children:t.name}),m&&s.jsxs("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[s.jsx(Gl,{className:"w-3 h-3"}),t.project_name?s.jsx(hK,{className:"w-3 h-3"}):s.jsx(Ja,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.file_count}),!m&&s.jsx("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:s.jsx(Gl,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:p=>p.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>d(!u),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(Fd,{className:"w-3.5 h-3.5 text-bambu-gray"})}),u&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>d(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t),d(!1)},children:[s.jsx(sa,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t),d(!1)},children:[s.jsx(Gl,{className:"w-3.5 h-3.5"}),m?"Change Link...":"Link to..."]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),d(!1)},children:[s.jsx(un,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),f&&l&&s.jsx("div",{children:t.children.map(p=>s.jsx(Kie,{folder:p,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1},p.id))})]})}function _D(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:fe.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(Mf,{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:qp(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Xn,{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(Fd,{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&&_D(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-bambu-green hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{o(t),u(!1)},children:[s.jsx(Wr,{className:"w-3.5 h-3.5"}),"Print"]}),a&&_D(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(Xn,{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(sa,{className:"w-3.5 h-3.5"}),"Rename"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),u(!1)},children:[s.jsx(un,{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}=Gn(),[n]=Wq(),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,D]=w.useState(null),[C,R]=w.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[U,O]=w.useState(""),[q,j]=w.useState("all"),[W,K]=w.useState("date"),[G,Q]=w.useState("desc");w.useEffect(()=>{const se=n.get("folder");if(se){const Pe=parseInt(se,10);o(Pe)}},[n]);const{data:te}=ut({queryKey:["settings"],queryFn:()=>fe.getSettings()}),{data:J,isLoading:z}=ut({queryKey:["library-folders"],queryFn:()=>fe.getLibraryFolders()}),{data:V,isLoading:ne}=ut({queryKey:["library-files",a],queryFn:()=>fe.getLibraryFiles(a,a===null)}),{data:ae}=ut({queryKey:["library-stats"],queryFn:()=>fe.getLibraryStats()}),he=w.useMemo(()=>{if(!V)return[];const se=new Set(V.map(Pe=>Pe.file_type));return Array.from(se).sort()},[V]),pe=w.useMemo(()=>{if(!V)return[];let se=[...V];if(U.trim()){const Pe=U.toLowerCase();se=se.filter(Re=>Re.filename.toLowerCase().includes(Pe)||Re.print_name&&Re.print_name.toLowerCase().includes(Pe))}return q!=="all"&&(se=se.filter(Pe=>Pe.file_type===q)),se.sort((Pe,Re)=>{let Xe=0;switch(W){case"name":Xe=(Pe.print_name||Pe.filename).localeCompare(Re.print_name||Re.filename);break;case"date":Xe=new Date(Pe.created_at).getTime()-new Date(Re.created_at).getTime();break;case"size":Xe=Pe.file_size-Re.file_size;break;case"type":Xe=Pe.file_type.localeCompare(Re.file_type);break;case"prints":Xe=Pe.print_count-Re.print_count;break}return G==="asc"?Xe:-Xe}),se},[V,U,q,W,G]),ie=w.useMemo(()=>{if(!ae||!te)return!1;const se=(te.library_disk_warning_gb||5)*1024*1024*1024;return ae.disk_free_bytes<se},[ae,te]),Ee=mt({mutationFn:se=>fe.createLibraryFolder(se),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:se=>e(se.message,"error")}),xe=mt({mutationFn:se=>fe.deleteLibraryFolder(se),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:se=>{S(null),e(se.message,"error")}}),Ne=mt({mutationFn:se=>fe.deleteLibraryFile(se),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(se=>se.filter(Pe=>Pe!==v?.id)),S(null),e("File deleted","success")},onError:se=>{S(null),e(se.message,"error")}}),_e=mt({mutationFn:se=>fe.bulkDeleteLibrary(se,[]),onSuccess:(se,Pe)=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${Pe.length} files`,"success"),c([]),S(null)},onError:se=>{S(null),e(se.message,"error")}}),le=mt({mutationFn:({fileIds:se,folderId:Pe})=>fe.moveLibraryFiles(se,Pe),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),m(!1),e("Files moved","success")},onError:se=>e(se.message,"error")}),Ve=mt({mutationFn:({id:se,data:Pe})=>fe.updateLibraryFolder(se,Pe),onSuccess:(se,Pe)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),x(null);const Re=Pe.data.project_id===0&&Pe.data.archive_id===0;e(Re?"Folder unlinked":"Folder linked","success")},onError:se=>e(se.message,"error")}),H=mt({mutationFn:se=>fe.addLibraryFilesToQueue(se),onSuccess:se=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),se.added.length>0&&se.errors.length===0?e(`Added ${se.added.length} file${se.added.length>1?"s":""} to queue`,"success"):se.added.length>0&&se.errors.length>0?e(`Added ${se.added.length} file${se.added.length>1?"s":""}, ${se.errors.length} failed`,"success"):e(`Failed to add files: ${se.errors[0]?.error||"Unknown error"}`,"error")},onError:se=>e(se.message,"error")}),ee=mt({mutationFn:({id:se,filename:Pe})=>fe.updateLibraryFile(se,{filename:Pe}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),D(null),e("File renamed","success")},onError:se=>{D(null),e(se.message,"error")}}),X=mt({mutationFn:({id:se,name:Pe})=>fe.updateLibraryFolder(se,{name:Pe}),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),D(null),e("Folder renamed","success")},onError:se=>{D(null),e(se.message,"error")}}),B=w.useCallback(se=>{const Pe=se.toLowerCase();return Pe.endsWith(".gcode")||Pe.includes(".gcode.")},[]),I=w.useMemo(()=>V?V.filter(se=>l.includes(se.id)&&B(se.filename)):[],[V,l,B]),ue=w.useCallback(se=>{c(Pe=>Pe.includes(se)?Pe.filter(Re=>Re!==se):[...Pe,se])},[]),Ae=w.useCallback(()=>{pe.length>0&&c(pe.map(se=>se.id))},[pe]),Ie=w.useCallback(()=>{c([])},[]),ce=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},$=se=>{window.open(fe.getLibraryFileDownloadUrl(se),"_blank")},L=()=>{v&&(v.type==="file"?Ne.mutate(v.id):v.type==="folder"?xe.mutate(v.id):v.type==="bulk"&&_e.mutate(l))},Y=xe.isPending||Ne.isPending||_e.isPending,be=se=>{R(se),localStorage.setItem("library-view-mode",se)},Se=z||ne;return s.jsxs("div",{className:"p-4 md:p-8 h-[calc(100vh-64px)] flex flex-col",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(ll,{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:()=>be("grid"),className:`p-1.5 rounded transition-colors ${C==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(lN,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>be("list"),className:`p-1.5 rounded transition-colors ${C==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(cN,{className:"w-4 h-4"})})]}),s.jsxs(Me,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(ihe,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(Me,{onClick:()=>b(!0),children:[s.jsx(mi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),ie&&ae&&te&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(An,{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 ",qp(ae.disk_free_bytes)," free of ",qp(ae.disk_total_bytes)," total. Threshold is set to ",te.library_disk_warning_gb," GB in settings."]})]})]}),ae&&s.jsxs("div",{className:"flex items-center gap-6 mb-6 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(rN,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-bambu-gray",children:"Files:"}),s.jsx("span",{className:"text-white font-medium",children:ae.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(ll,{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:ae.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(sN,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Size:"}),s.jsx("span",{className:"text-white font-medium",children:qp(ae.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 ${ie?"text-amber-500":"text-white"}`,children:qp(ae.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex gap-6 min-h-0",children:[s.jsxs("div",{className:"w-64 flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex flex-col",children:[s.jsx("div",{className:"p-3 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[s.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${a===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>o(null),children:[s.jsx(Mf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),J?.map(se=>s.jsx(Kie,{folder:se,selectedFolderId:a,onSelect:o,onDelete:Pe=>S({type:"folder",id:Pe}),onLink:x,onRename:Pe=>D({type:"folder",id:Pe.id,name:Pe.name})},se.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[V&&V.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(Na,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search files...",value:U,onChange:se=>O(se.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(iN,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:q,onChange:se=>j(se.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"all",children:"All types"}),he.map(se=>s.jsx("option",{value:se,children:se.toUpperCase()},se))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:W,onChange:se=>K(se.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:()=>Q(se=>se==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:G==="asc"?"Ascending":"Descending",children:G==="asc"?s.jsx(Lue,{className:"w-4 h-4 text-white"}):s.jsx(kue,{className:"w-4 h-4 text-white"})})]}),(U||q!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[pe.length," of ",V.length," files"]})]}),pe.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===pe.length&&l.length>0?s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ie,children:[s.jsx(Lo,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Me,{variant:"secondary",size:"sm",onClick:Ae,children:[s.jsx(Oo,{className:"w-4 h-4 mr-1"}),"Select All"]}),l.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray ml-2",children:[l.length," selected"]}),s.jsx("div",{className:"flex-1"}),I.length===1&&s.jsxs(Me,{variant:"primary",size:"sm",onClick:()=>k(I[0]),children:[s.jsx(Do,{className:"w-4 h-4 mr-1"}),"Print"]}),I.length>0&&s.jsxs(Me,{variant:I.length===1?"secondary":"primary",size:"sm",onClick:()=>H.mutate(I.map(se=>se.id)),disabled:H.isPending,children:[s.jsx(Xn,{className:"w-4 h-4 mr-1"}),H.isPending?"Adding...":`Add to Queue${I.length<l.length?` (${I.length})`:""}`]}),s.jsxs(Me,{variant:"secondary",size:"sm",onClick:()=>m(!0),children:[s.jsx(hfe,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(Me,{variant:"danger",size:"sm",onClick:()=>{l.length===1?S({type:"file",id:l[0]}):S({type:"bulk",id:0,count:l.length})},children:[s.jsx(un,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(Me,{variant:"secondary",size:"sm",onClick:Ie,children:"Clear"})]})]}),Se?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(dt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):V?.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Mf,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:a!==null?"Folder is empty":"No files yet"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:a!==null?"Upload files or move files into this folder to get started.":"Upload files to start organizing your print-related files."}),s.jsxs(Me,{onClick:()=>b(!0),children:[s.jsx(er,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):pe.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(Na,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No matching files"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:"No files match your current search or filter criteria."}),s.jsx(Me,{variant:"secondary",onClick:()=>{O(""),j("all")},children:"Clear filters"})]}):C==="grid"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:pe.map(se=>s.jsx(PZe,{file:se,isSelected:l.includes(se.id),onSelect:ue,onDelete:Pe=>S({type:"file",id:Pe}),onDownload:$,onAddToQueue:Pe=>H.mutate([Pe]),onPrint:A,onRename:Pe=>D({type:"file",id:Pe.id,name:Pe.filename})},se.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",{})]}),pe.map(se=>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(se.id)?"bg-bambu-green/10":""}`,onClick:()=>ue(se.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(se.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(se.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:se.thumbnail_path?s.jsx("img",{src:fe.getLibraryFileThumbnailUrl(se.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(Mf,{className:"w-5 h-5 text-bambu-gray/50"})})}),se.thumbnail_path&&s.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:s.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:s.jsx("img",{src:fe.getLibraryFileThumbnailUrl(se.id),alt:se.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:se.print_name||se.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${se.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":se.file_type==="gcode"?"bg-blue-500/20 text-blue-400":se.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:se.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:qp(se.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:se.print_count>0?`${se.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:Pe=>Pe.stopPropagation(),children:[_D(se.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>A(se),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Print",children:s.jsx(Wr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>H.mutate([se.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Add to Queue",disabled:H.isPending,children:s.jsx(Xn,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>$(se.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:()=>D({type:"file",id:se.id,name:se.filename}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename",children:s.jsx(sa,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>S({type:"file",id:se.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(un,{className:"w-4 h-4"})})]})]},se.id))]})})]})]}),u&&s.jsx(AZe,{parentId:a,onClose:()=>d(!1),onSave:se=>Ee.mutate(se),isLoading:Ee.isPending}),f&&J&&s.jsx(CZe,{folders:J,selectedFiles:l,currentFolderId:a,onClose:()=>m(!1),onMove:se=>le.mutate({fileIds:l,folderId:se}),isLoading:le.isPending}),p&&s.jsx(jZe,{folderId:a,onClose:()=>b(!1),onUploadComplete:ce}),y&&s.jsx(kZe,{folder:y,onClose:()=>x(null),onLink:se=>Ve.mutate({id:y.id,data:se}),isLoading:Ve.isPending}),v&&s.jsx(zn,{title:v.type==="folder"?"Delete Folder":v.type==="bulk"?`Delete ${v.count} Files`:"Delete File",message:v.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":v.type==="bulk"?`Are you sure you want to delete ${v.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",isLoading:Y,loadingText:"Deleting...",onConfirm:L,onCancel:()=>S(null)}),M&&s.jsx(oh,{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(oh,{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:()=>D(null),onSave:se=>{E.type==="file"?ee.mutate({id:E.id,filename:se}):X.mutate({id:E.id,name:se})},isLoading:ee.isPending||X.isPending})]})}const Zj=5,DZe=2e3,OZe=3e4,LZe=5e3;function IZe(){const{printerId:t}=ED(),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}),[D,C]=w.useState(!1),[R,U]=w.useState({x:0,y:0}),[O,q]=w.useState(null),[j,W]=w.useState(null),K=w.useRef(null),G=w.useRef(null),Q=w.useRef(null),te=w.useRef(null),J=w.useRef(null),{data:z}=ut({queryKey:["printer",e],queryFn:()=>fe.getPrinter(e),enabled:e>0});w.useEffect(()=>(z&&(document.title=`${z.name} - Camera`),()=>{document.title="Bambuddy"}),[z]);const V=w.useRef(!1);w.useEffect(()=>{const Y=`/api/v1/printers/${e}/camera/stop`;V.current=!1;const be=()=>{e>0&&!V.current&&(V.current=!0,navigator.sendBeacon(Y))},Se=()=>{be()};window.addEventListener("beforeunload",Se);const se=K.current;return()=>{window.removeEventListener("beforeunload",Se),se&&(se.src=""),be()}},[e]),w.useEffect(()=>{if(o&&!d){const be=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(be)}},[n,o,c,d]),w.useEffect(()=>{const Y=()=>{const be=!!document.fullscreenElement;p(be),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 be=()=>{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",be),()=>{clearTimeout(Y),window.removeEventListener("resize",be)}},[]),w.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current),te.current&&clearInterval(te.current),J.current&&clearInterval(J.current)},[]);const ne=w.useCallback(()=>{if(b>=Zj){v(!1),a(!0);return}const Y=Math.min(DZe*Math.pow(2,b),OZe);v(!0),M(Math.ceil(Y/1e3)),te.current=setInterval(()=>{M(be=>be<=1?(te.current&&clearInterval(te.current),0):be-1)},1e3),Q.current=setTimeout(()=>{y(be=>be+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 be=await Y.json();(be.stalled||!be.active&&!i)&&(console.log(`Stream issue detected: stalled=${be.stalled}, active=${be.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<Zj?ne():a(!0)},he=()=>{if(l(!1),a(!1),y(0),v(!1),Q.current&&clearTimeout(Q.current),te.current&&clearInterval(te.current),K.current&&!localStorage.getItem("cameraWindowState")){const Y=K.current,be=Y.naturalWidth,Se=Y.naturalHeight;if(be>0&&Se>0){const Re=window.outerWidth-window.innerWidth,Xe=window.outerHeight-window.innerHeight,et=be+16+Re,Je=Se+45+16+Xe;try{window.resizeTo(et,Je)}catch{}}}},pe=()=>{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),te.current&&clearInterval(te.current),K.current&&(K.current.src=""),n==="stream"&&pe(),setTimeout(()=>{r(Y),u(Date.now()),f(!1)},100))},Ee=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),Q.current&&clearTimeout(Q.current),te.current&&clearInterval(te.current),K.current&&(K.current.src=""),n==="stream"&&pe(),setTimeout(()=>{u(Date.now()),f(!1)},100))},xe=()=>{G.current&&(document.fullscreenElement?document.exitFullscreen():G.current.requestFullscreen())},Ne=()=>{T(Y=>Math.min(Y+.5,4))},_e=()=>{T(Y=>{const be=Math.max(Y-.5,1);return be===1&&E({x:0,y:0}),be})},le=Y=>{Y.preventDefault(),Y.deltaY<0?Ne():_e()},Ve=Y=>{A>1&&(Y.preventDefault(),C(!0),U({x:Y.clientX-k.x,y:Y.clientY-k.y}))},H=w.useCallback(()=>{if(!G.current)return{x:300,y:200};const Y=G.current.getBoundingClientRect(),be=Y.width*(A-1)/2,Se=Y.height*(A-1)/2;return{x:Math.max(50,be),y:Math.max(50,Se)}},[A]),ee=Y=>{if(D&&A>1){const be=Y.clientX-R.x,Se=Y.clientY-R.y,se=H();E({x:Math.max(-se.x,Math.min(se.x,be)),y:Math.max(-se.y,Math.min(se.y,Se))})}},X=()=>{C(!1)},B=Y=>{if(Y.length<2)return 0;const be=Y[0].clientX-Y[1].clientX,Se=Y[0].clientY-Y[1].clientY;return Math.sqrt(be*be+Se*Se)},I=Y=>Y.length<2?{x:Y[0].clientX,y:Y[0].clientY}:{x:(Y[0].clientX+Y[1].clientX)/2,y:(Y[0].clientY+Y[1].clientY)/2},ue=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}))},Ae=Y=>{if(Y.touches.length===2&&O!==null){Y.preventDefault();const be=B(Y.touches),Se=be/O;T(Pe=>{const Re=Math.max(1,Math.min(4,Pe*Se));return Re===1&&E({x:0,y:0}),Re}),q(be);const se=I(Y.touches);if(j){const Pe=H();E(Re=>({x:Math.max(-Pe.x,Math.min(Pe.x,Re.x+(se.x-j.x))),y:Math.max(-Pe.y,Math.min(Pe.y,Re.y+(se.y-j.y)))}))}W(se)}else if(Y.touches.length===1&&D&&A>1){Y.preventDefault();const be=Y.touches[0].clientX-R.x,Se=Y.touches[0].clientY-R.y,se=H();E({x:Math.max(-se.x,Math.min(se.x,be)),y:Math.max(-se.y,Math.min(se.y,Se))})}},Ie=Y=>{Y.touches.length<2&&(q(null),W(null)),Y.touches.length===0&&C(!1)},ce=()=>{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}`,L=o||d||x;return e?s.jsxs("div",{ref:G,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(zf,{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:L,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),s.jsx("button",{onClick:()=>ie("snapshot"),disabled:L,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),s.jsx("button",{onClick:Ee,disabled:L,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(xr,{className:`w-4 h-4 text-bambu-gray ${L?"animate-spin":""}`})}),s.jsx("button",{onClick:xe,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?s.jsx(vK,{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:ue,onTouchMove:Ae,onTouchEnd:Ie,style:{touchAction:"none"},children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!x&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(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(Zg,{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,"/",Zj,")"]}),s.jsx("button",{onClick:Ee,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(An,{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:Ee,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?D?"grabbing":"grab":"default"},onError:$?ae:void 0,onLoad:$?he:void 0,onMouseDown:Ve,draggable:!1},c),s.jsxs("div",{className:"absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5",children:[s.jsx("button",{onClick:_e,disabled:A<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(WD,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:ce,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(GD,{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}=ED(),{mode:e}=uh(),{data:n,isLoading:r,error:i}=ut({queryKey:["external-link",t],queryFn:()=>fe.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(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(An,{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 gq=["DEBUG","INFO","WARNING","ERROR"],Qj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},UZe={DEBUG:eN,INFO:Zl,WARNING:An,ERROR:aa};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:()=>ng.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:()=>ng.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(D=>{const C=new Set(D);return C.has(E)?C.delete(E):C.add(E),C})},M=E=>{const D=E.split(" ");return D.length>=2?D[1]:E},A=w.useMemo(()=>b?.entries??[],[b?.entries]),T=w.useMemo(()=>[...A].reverse(),[A]),k=({level:E})=>{const D=UZe[E]||Zl;return s.jsx(D,{className:`w-3.5 h-3.5 ${Qj[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(eN,{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(fu,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Di,{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(Lo,{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(Do,{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(un,{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(Na,{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(Ht,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),gq.map((E,D)=>s.jsx("button",{onClick:()=>c(E),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===gq.length-1?"rounded-r":""} ${l===E?`${Qj[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,D)=>{const C=r.has(D),R=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:()=>R&&S(D),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:M(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 ${Qj[E.level]||"text-white/80"} ${!C&&R?"truncate":""}`,children:C?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:E.message}):E.message.split(`
- `)[0]}),R&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:C?s.jsx(fu,{className:"w-3.5 h-3.5"}):s.jsx(Di,{className:"w-3.5 h-3.5"})})]})},D)})})}),s.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):s.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function 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 xq({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 pd({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}=Wg(),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:fe.getSystemInfo,refetchInterval:3e4}),{data:m}=ut({queryKey:["debugLogging"],queryFn:ng.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ut({queryKey:["settings"],queryFn:fe.getSettings}),{data:b}=ut({queryKey:["library-stats"],queryFn:fe.getLibraryStats}),y=p?.time_format||"system",x=async()=>{l(!0);try{const A=await ng.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 ng.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(pd,{title:t("system.application","Application"),icon:Zh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(ti,{icon:Zh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(ti,{icon:Xn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(ti,{icon:Zh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(pd,{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(eN,{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(pd,{title:t("system.database","Database"),icon:iu,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(ti,{icon:Ja,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(ti,{icon:tN,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(ti,{icon:na,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:Wr,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(ti,{icon:zD,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(ti,{icon:Aa,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(ti,{icon:Ws,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(ti,{icon:Xn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(ti,{icon:Ja,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(pd,{title:t("system.connectedPrinters","Connected Printers"),icon:Wr,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(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(pd,{title:t("system.storage","Storage"),icon:sN,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),s.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),s.jsx(xq,{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:Ja,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(ti,{icon:iu,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),b&&s.jsx(ti,{icon:ll,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(pd,{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(xq,{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(pd,{title:t("system.cpu","CPU"),icon:x_,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(ti,{icon:x_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(ti,{icon:x_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(pd,{title:t("system.systemDetails","System Details"),icon:Zh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(ti,{icon:Zh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(ti,{icon:x_,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(ti,{icon:Zh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(ti,{icon:Xn,label:t("system.bootTime","Boot Time"),value:yg(c.system.boot_time,y)})]})})]})}function HZe(){const t=pl(),{login:e}=dh(),{showToast:n}=Gn(),{mode:r}=uh(),[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=pl(),{showToast:e}=Gn(),{mode:n}=uh(),{refreshAuth:r}=dh(),[i,a]=w.useState(!1),[o,l]=w.useState(""),[c,u]=w.useState(""),[d,f]=w.useState(""),m=mt({mutationFn:()=>fe.setupAuth({auth_enabled:i,admin_username:i?o:void 0,admin_password:i?c:void 0}),onSuccess:async b=>{await r(),b.auth_enabled?b.admin_created?(e("Authentication enabled and admin user created"),t("/login")):(e("Authentication enabled using existing admin users"),t("/login")):(e("Setup completed"),t("/"))},onError:b=>{e(b.message,"error")}}),p=b=>{if(b.preventDefault(),i&&(o||c)){if(!o||!c){e("Please enter both admin username and password, or leave both empty to use existing admin users","error");return}if(c!==d){e("Passwords do not match","error");return}if(c.length<6){e("Password must be at least 6 characters","error");return}}m.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:"Bambuddy Setup"}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"Configure authentication for your Bambuddy instance"})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("input",{id:"auth-enabled",type:"checkbox",checked:i,onChange:b=>a(b.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),s.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:"Enable Authentication"})]}),i&&s.jsxs("div",{className:"space-y-4 mt-4",children:[s.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Zl,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Admin Account"}),s.jsx("p",{children:"If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user."})]})]})}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:["Admin Username ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-username",type:"text",value:o,onChange:b=>l(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin username (optional)",autoComplete:"username"})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:["Admin Password ",s.jsx("span",{className:"text-bambu-gray text-xs",children:"(optional if admin users exist)"})]}),s.jsx("input",{id:"admin-password",type:"password",value:c,onChange:b=>u(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Enter admin password (optional)",minLength:6,autoComplete:"new-password"})]}),c&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:"Confirm Password"}),s.jsx("input",{id:"confirm-password",type:"password",value:d,onChange:b=>f(b.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:"Confirm admin password",minLength:6,autoComplete:"new-password"})]})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:m.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:m.isPending?"Setting up...":"Complete Setup"})})]})]})})}function GZe(){const t=pl(),{user:e}=dh(),{showToast:n}=Gn(),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:()=>fe.getUsers()}),b=mt({mutationFn:T=>fe.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})=>fe.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=>fe.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(Mt,{className:"py-6",children:s.jsxs("div",{className:"flex items-center gap-3 text-red-400",children:[s.jsx(wP,{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(uK,{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(hf,{className:"w-6 h-6 text-bambu-green"}),"User Management"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Manage users and their access to your Bambuddy instance"})]})]}),s.jsxs(Me,{onClick:()=>{a(!0),f({username:"",password:"",role:"user"})},children:[s.jsx(er,{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(Me,{size:"sm",onClick:()=>S(T.id),disabled:y.isPending,children:[y.isPending?s.jsx(dt,{className:"w-4 h-4 animate-spin"}):s.jsx(ys,{className:"w-4 h-4"}),"Save"]}),s.jsx(Me,{size:"sm",variant:"secondary",onClick:()=>{l(null),f({username:"",password:"",role:"user"})},children:"Cancel"})]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>A(T),children:[s.jsx(uN,{className:"w-4 h-4"}),"Edit"]}),T.id!==e?.id&&s.jsxs(Me,{size:"sm",variant:"ghost",onClick:()=>M(T.id),children:[s.jsx(un,{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(ir,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(hf,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Create User"})]}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:s.jsx(Ht,{className:"w-5 h-5"})})]})}),s.jsxs(Mt,{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(Me,{variant:"secondary",onClick:()=>{a(!1),f({username:"",password:"",role:"user"})},children:"Cancel"}),s.jsx(Me,{onClick:v,disabled:b.isPending||!d.username||!d.password,children:b.isPending?s.jsxs(s.Fragment,{children:[s.jsx(dt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(er,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),c!==null&&s.jsx(zn,{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirmText:"Delete User",variant:"danger",onConfirm:()=>{x.mutate(c),u(null)},onCancel:()=>u(null)})]})}function 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],D=>{const C={...D,...k};return C.wifi_signal==null&&D?.wifi_signal!=null&&(C.wifi_signal=D.wifi_signal),C})})})},100))},[n]),y=w.useCallback(S=>{a.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const M=Array.from(a.current);a.current.clear(),o.current=null;let 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}=dh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(j1,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function YZe({children:t}){const{authEnabled:e,loading:n,user:r}=dh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?r.role!=="admin"?s.jsx(j1,{to:"/",replace:!0}):s.jsx(s.Fragment,{children:t}):s.jsx(j1,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function ZZe({children:t}){const{authEnabled:e,loading:n}=dh();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(j1,{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(qi,{path:"/setup",element:s.jsx(ZZe,{children:s.jsx(VZe,{})})}),s.jsx(qi,{path:"/login",element:s.jsx(HZe,{})}),s.jsx(qi,{path:"/camera/:printerId",element:s.jsx(IZe,{})}),s.jsxs(qi,{element:s.jsx(XZe,{children:s.jsx(KZe,{children:s.jsx(Xme,{})})}),children:[s.jsx(qi,{index:!0,element:s.jsx(JPe,{})}),s.jsx(qi,{path:"archives",element:s.jsx(CKe,{})}),s.jsx(qi,{path:"queue",element:s.jsx(mYe,{})}),s.jsx(qi,{path:"stats",element:s.jsx(TYe,{})}),s.jsx(qi,{path:"profiles",element:s.jsx(dZe,{})}),s.jsx(qi,{path:"maintenance",element:s.jsx(gZe,{})}),s.jsx(qi,{path:"projects",element:s.jsx(bZe,{})}),s.jsx(qi,{path:"projects/:id",element:s.jsx(NZe,{})}),s.jsx(qi,{path:"files",element:s.jsx(RZe,{})}),s.jsx(qi,{path:"settings",element:s.jsx(YZe,{children:s.jsx(eZe,{})})}),s.jsx(qi,{path:"users",element:s.jsx(GZe,{})}),s.jsx(qi,{path:"system",element:s.jsx($Ze,{})}),s.jsx(qi,{path:"external/:id",element:s.jsx(FZe,{})})]})]})})})})})})}coe.createRoot(document.getElementById("root")).render(s.jsx(w.StrictMode,{children:s.jsx(QZe,{})}));
|