| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663 |
- function _ie(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 Pv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qN={exports:{}},wx={};var DF;function wie(){if(DF)return wx;DF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:a}}return wx.Fragment=e,wx.jsx=n,wx.jsxs=n,wx}var OF;function Sie(){return OF||(OF=1,qN.exports=wie()),qN.exports}var s=Sie(),KN={exports:{}},on={};var LF;function Mie(){if(LF)return on;LF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function p(F){return F===null||typeof F!="object"?null:(F=g&&F[g]||F["@@iterator"],typeof F=="function"?F:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,b={};function v(F,V,te){this.props=F,this.context=V,this.refs=b,this.updater=te||x}v.prototype.isReactComponent={},v.prototype.setState=function(F,V){if(typeof F!="object"&&typeof F!="function"&&F!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,F,V,"setState")},v.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function E(){}E.prototype=v.prototype;function w(F,V,te){this.props=F,this.context=V,this.refs=b,this.updater=te||x}var A=w.prototype=new E;A.constructor=w,y(A,v.prototype),A.isPureReactComponent=!0;var N=Array.isArray;function C(){}var T={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function k(F,V,te){var re=te.ref;return{$$typeof:t,type:F,key:V,ref:re!==void 0?re:null,props:te}}function R(F,V){return k(F.type,V,F.props)}function z(F){return typeof F=="object"&&F!==null&&F.$$typeof===t}function D(F){var V={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(te){return V[te]})}var K=/\/+/g;function P(F,V){return typeof F=="object"&&F!==null&&F.key!=null?D(""+F.key):V.toString(36)}function W(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(C,C):(F.status="pending",F.then(function(V){F.status==="pending"&&(F.status="fulfilled",F.value=V)},function(V){F.status==="pending"&&(F.status="rejected",F.reason=V)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function Z(F,V,te,re,ae){var he=typeof F;(he==="undefined"||he==="boolean")&&(F=null);var ue=!1;if(F===null)ue=!0;else switch(he){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(F.$$typeof){case t:case e:ue=!0;break;case d:return ue=F._init,Z(ue(F._payload),V,te,re,ae)}}if(ue)return ae=ae(F),ue=re===""?"."+P(F,0):re,N(ae)?(te="",ue!=null&&(te=ue.replace(K,"$&/")+"/"),Z(ae,V,te,"",function(pe){return pe})):ae!=null&&(z(ae)&&(ae=R(ae,te+(ae.key==null||F&&F.key===ae.key?"":(""+ae.key).replace(K,"$&/")+"/")+ue)),V.push(ae)),1;ue=0;var ce=re===""?".":re+":";if(N(F))for(var fe=0;fe<F.length;fe++)re=F[fe],he=ce+P(re,fe),ue+=Z(re,V,te,he,ae);else if(fe=p(F),typeof fe=="function")for(F=fe.call(F),fe=0;!(re=F.next()).done;)re=re.value,he=ce+P(re,fe++),ue+=Z(re,V,te,he,ae);else if(he==="object"){if(typeof F.then=="function")return Z(W(F),V,te,re,ae);throw V=String(F),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return ue}function G(F,V,te){if(F==null)return F;var re=[],ae=0;return Z(F,re,"","",function(he){return V.call(te,he,ae++)}),re}function Y(F){if(F._status===-1){var V=F._result;V=V(),V.then(function(te){(F._status===0||F._status===-1)&&(F._status=1,F._result=te)},function(te){(F._status===0||F._status===-1)&&(F._status=2,F._result=te)}),F._status===-1&&(F._status=0,F._result=V)}if(F._status===1)return F._result.default;throw F._result}var X=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},q={map:G,forEach:function(F,V,te){G(F,function(){V.apply(this,arguments)},te)},count:function(F){var V=0;return G(F,function(){V++}),V},toArray:function(F){return G(F,function(V){return V})||[]},only:function(F){if(!z(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return on.Activity=f,on.Children=q,on.Component=v,on.Fragment=n,on.Profiler=i,on.PureComponent=w,on.StrictMode=r,on.Suspense=c,on.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,on.__COMPILER_RUNTIME={__proto__:null,c:function(F){return T.H.useMemoCache(F)}},on.cache=function(F){return function(){return F.apply(null,arguments)}},on.cacheSignal=function(){return null},on.cloneElement=function(F,V,te){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var re=y({},F.props),ae=F.key;if(V!=null)for(he in V.key!==void 0&&(ae=""+V.key),V)!O.call(V,he)||he==="key"||he==="__self"||he==="__source"||he==="ref"&&V.ref===void 0||(re[he]=V[he]);var he=arguments.length-2;if(he===1)re.children=te;else if(1<he){for(var ue=Array(he),ce=0;ce<he;ce++)ue[ce]=arguments[ce+2];re.children=ue}return k(F.type,ae,re)},on.createContext=function(F){return F={$$typeof:o,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:a,_context:F},F},on.createElement=function(F,V,te){var re,ae={},he=null;if(V!=null)for(re in V.key!==void 0&&(he=""+V.key),V)O.call(V,re)&&re!=="key"&&re!=="__self"&&re!=="__source"&&(ae[re]=V[re]);var ue=arguments.length-2;if(ue===1)ae.children=te;else if(1<ue){for(var ce=Array(ue),fe=0;fe<ue;fe++)ce[fe]=arguments[fe+2];ae.children=ce}if(F&&F.defaultProps)for(re in ue=F.defaultProps,ue)ae[re]===void 0&&(ae[re]=ue[re]);return k(F,he,ae)},on.createRef=function(){return{current:null}},on.forwardRef=function(F){return{$$typeof:l,render:F}},on.isValidElement=z,on.lazy=function(F){return{$$typeof:d,_payload:{_status:-1,_result:F},_init:Y}},on.memo=function(F,V){return{$$typeof:u,type:F,compare:V===void 0?null:V}},on.startTransition=function(F){var V=T.T,te={};T.T=te;try{var re=F(),ae=T.S;ae!==null&&ae(te,re),typeof re=="object"&&re!==null&&typeof re.then=="function"&&re.then(C,X)}catch(he){X(he)}finally{V!==null&&te.types!==null&&(V.types=te.types),T.T=V}},on.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},on.use=function(F){return T.H.use(F)},on.useActionState=function(F,V,te){return T.H.useActionState(F,V,te)},on.useCallback=function(F,V){return T.H.useCallback(F,V)},on.useContext=function(F){return T.H.useContext(F)},on.useDebugValue=function(){},on.useDeferredValue=function(F,V){return T.H.useDeferredValue(F,V)},on.useEffect=function(F,V){return T.H.useEffect(F,V)},on.useEffectEvent=function(F){return T.H.useEffectEvent(F)},on.useId=function(){return T.H.useId()},on.useImperativeHandle=function(F,V,te){return T.H.useImperativeHandle(F,V,te)},on.useInsertionEffect=function(F,V){return T.H.useInsertionEffect(F,V)},on.useLayoutEffect=function(F,V){return T.H.useLayoutEffect(F,V)},on.useMemo=function(F,V){return T.H.useMemo(F,V)},on.useOptimistic=function(F,V){return T.H.useOptimistic(F,V)},on.useReducer=function(F,V,te){return T.H.useReducer(F,V,te)},on.useRef=function(F){return T.H.useRef(F)},on.useState=function(F){return T.H.useState(F)},on.useSyncExternalStore=function(F,V,te){return T.H.useSyncExternalStore(F,V,te)},on.useTransition=function(){return T.H.useTransition()},on.version="19.2.0",on}var IF;function lg(){return IF||(IF=1,KN.exports=Mie()),KN.exports}var S=lg();const Cr=_o(S),Eie=_ie({__proto__:null,default:Cr},[S]);var XN={exports:{}},Sx={},YN={exports:{}},ZN={};var FF;function Nie(){return FF||(FF=1,(function(t){function e(Z,G){var Y=Z.length;Z.push(G);e:for(;0<Y;){var X=Y-1>>>1,q=Z[X];if(0<i(q,G))Z[X]=G,Z[Y]=q,Y=X;else break e}}function n(Z){return Z.length===0?null:Z[0]}function r(Z){if(Z.length===0)return null;var G=Z[0],Y=Z.pop();if(Y!==G){Z[0]=Y;e:for(var X=0,q=Z.length,F=q>>>1;X<F;){var V=2*(X+1)-1,te=Z[V],re=V+1,ae=Z[re];if(0>i(te,Y))re<q&&0>i(ae,te)?(Z[X]=ae,Z[re]=Y,X=re):(Z[X]=te,Z[V]=Y,X=V);else if(re<q&&0>i(ae,Y))Z[X]=ae,Z[re]=Y,X=re;else break e}}return G}function i(Z,G){var Y=Z.sortIndex-G.sortIndex;return Y!==0?Y:Z.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,g=3,p=!1,x=!1,y=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(Z){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=Z)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function N(Z){if(y=!1,A(Z),!x)if(n(c)!==null)x=!0,C||(C=!0,D());else{var G=n(u);G!==null&&W(N,G.startTime-Z)}}var C=!1,T=-1,O=5,k=-1;function R(){return b?!0:!(t.unstable_now()-k<O)}function z(){if(b=!1,C){var Z=t.unstable_now();k=Z;var G=!0;try{e:{x=!1,y&&(y=!1,E(T),T=-1),p=!0;var Y=g;try{t:{for(A(Z),f=n(c);f!==null&&!(f.expirationTime>Z&&R());){var X=f.callback;if(typeof X=="function"){f.callback=null,g=f.priorityLevel;var q=X(f.expirationTime<=Z);if(Z=t.unstable_now(),typeof q=="function"){f.callback=q,A(Z),G=!0;break t}f===n(c)&&r(c),A(Z)}else r(c);f=n(c)}if(f!==null)G=!0;else{var F=n(u);F!==null&&W(N,F.startTime-Z),G=!1}}break e}finally{f=null,g=Y,p=!1}G=void 0}}finally{G?D():C=!1}}}var D;if(typeof w=="function")D=function(){w(z)};else if(typeof MessageChannel<"u"){var K=new MessageChannel,P=K.port2;K.port1.onmessage=z,D=function(){P.postMessage(null)}}else D=function(){v(z,0)};function W(Z,G){T=v(function(){Z(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(Z){Z.callback=null},t.unstable_forceFrameRate=function(Z){0>Z||125<Z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<Z?Math.floor(1e3/Z):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(Z){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var Y=g;g=G;try{return Z()}finally{g=Y}},t.unstable_requestPaint=function(){b=!0},t.unstable_runWithPriority=function(Z,G){switch(Z){case 1:case 2:case 3:case 4:case 5:break;default:Z=3}var Y=g;g=Z;try{return G()}finally{g=Y}},t.unstable_scheduleCallback=function(Z,G,Y){var X=t.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?X+Y:X):Y=X,Z){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=Y+q,Z={id:d++,callback:G,priorityLevel:Z,startTime:Y,expirationTime:q,sortIndex:-1},Y>X?(Z.sortIndex=Y,e(u,Z),n(c)===null&&Z===n(u)&&(y?(E(T),T=-1):y=!0,W(N,Y-X))):(Z.sortIndex=q,e(c,Z),x||p||(x=!0,C||(C=!0,D()))),Z},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(Z){var G=g;return function(){var Y=g;g=G;try{return Z.apply(this,arguments)}finally{g=Y}}}})(ZN)),ZN}var UF;function Aie(){return UF||(UF=1,YN.exports=Nie()),YN.exports}var QN={exports:{}},ma={};var zF;function Tie(){if(zF)return ma;zF=1;var t=lg();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return ma.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,ma.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},ma.flushSync=function(c){var u=o.T,d=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=u,r.p=d,r.d.f()}},ma.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},ma.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},ma.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,p=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:p}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:p,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},ma.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},ma.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},ma.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},ma.requestFormReset=function(c){r.d.r(c)},ma.unstable_batchedUpdates=function(c,u){return c(u)},ma.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},ma.useFormStatus=function(){return o.H.useHostTransitionStatus()},ma.version="19.2.0",ma}var BF;function lG(){if(BF)return QN.exports;BF=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),QN.exports=Tie(),QN.exports}var HF;function Cie(){if(HF)return Sx;HF=1;var t=Aie(),e=lg(),n=lG();function r(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)m+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var m=h,_=h;if(h.alternate)for(;m.return;)m=m.return;else{h=m;do m=h,(m.flags&4098)!==0&&(_=m.return),h=m.return;while(h)}return m.tag===3?_:null}function o(h){if(h.tag===13){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function l(h){if(h.tag===31){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var m=h.alternate;if(!m){if(m=a(h),m===null)throw Error(r(188));return m!==h?null:h}for(var _=h,M=m;;){var j=_.return;if(j===null)break;var L=j.alternate;if(L===null){if(M=j.return,M!==null){_=M;continue}break}if(j.child===L.child){for(L=j.child;L;){if(L===_)return c(j),h;if(L===M)return c(j),m;L=L.sibling}throw Error(r(188))}if(_.return!==M.return)_=j,M=L;else{for(var Q=!1,me=j.child;me;){if(me===_){Q=!0,_=j,M=L;break}if(me===M){Q=!0,M=j,_=L;break}me=me.sibling}if(!Q){for(me=L.child;me;){if(me===_){Q=!0,_=L,M=j;break}if(me===M){Q=!0,M=L,_=j;break}me=me.sibling}if(!Q)throw Error(r(189))}}if(_.alternate!==M)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:m}function d(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h;for(h=h.child;h!==null;){if(m=d(h),m!==null)return m;h=h.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),w=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),R=Symbol.for("react.memo_cache_sentinel"),z=Symbol.iterator;function D(h){return h===null||typeof h!="object"?null:(h=z&&h[z]||h["@@iterator"],typeof h=="function"?h:null)}var K=Symbol.for("react.client.reference");function P(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===K?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case y:return"Fragment";case v:return"Profiler";case b:return"StrictMode";case N:return"Suspense";case C:return"SuspenseList";case k:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case w:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case A:var m=h.render;return h=h.displayName,h||(h=m.displayName||m.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case T:return m=h.displayName||null,m!==null?m:P(h.type)||"Memo";case O:m=h._payload,h=h._init;try{return P(h(m))}catch{}}return null}var W=Array.isArray,Z=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,Y={pending:!1,data:null,method:null,action:null},X=[],q=-1;function F(h){return{current:h}}function V(h){0>q||(h.current=X[q],X[q]=null,q--)}function te(h,m){q++,X[q]=h.current,h.current=m}var re=F(null),ae=F(null),he=F(null),ue=F(null);function ce(h,m){switch(te(he,m),te(ae,h),te(re,null),m.nodeType){case 9:case 11:h=(h=m.documentElement)&&(h=h.namespaceURI)?rF(h):0;break;default:if(h=m.tagName,m=m.namespaceURI)m=rF(m),h=iF(m,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}V(re),te(re,h)}function fe(){V(re),V(ae),V(he)}function pe(h){h.memoizedState!==null&&te(ue,h);var m=re.current,_=iF(m,h.type);m!==_&&(te(ae,h),te(re,_))}function _e(h){ae.current===h&&(V(re),V(ae)),ue.current===h&&(V(ue),bx._currentValue=Y)}var ne,He;function B(h){if(ne===void 0)try{throw Error()}catch(_){var m=_.stack.trim().match(/\n( *(at )?)/);ne=m&&m[1]||"",He=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ne+h+He}var H=!1;function le(h,m){if(!h||H)return"";H=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(m){var pt=function(){throw Error()};if(Object.defineProperty(pt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pt,[])}catch(st){var rt=st}Reflect.construct(h,[],pt)}else{try{pt.call()}catch(st){rt=st}h.call(pt.prototype)}}else{try{throw Error()}catch(st){rt=st}(pt=h())&&typeof pt.catch=="function"&&pt.catch(function(){})}}catch(st){if(st&&rt&&typeof st.stack=="string")return[st.stack,rt.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=M.DetermineComponentFrameRoot(),Q=L[0],me=L[1];if(Q&&me){var Ce=Q.split(`
- `),tt=me.split(`
- `);for(j=M=0;M<Ce.length&&!Ce[M].includes("DetermineComponentFrameRoot");)M++;for(;j<tt.length&&!tt[j].includes("DetermineComponentFrameRoot");)j++;if(M===Ce.length||j===tt.length)for(M=Ce.length-1,j=tt.length-1;1<=M&&0<=j&&Ce[M]!==tt[j];)j--;for(;1<=M&&0<=j;M--,j--)if(Ce[M]!==tt[j]){if(M!==1||j!==1)do if(M--,j--,0>j||Ce[M]!==tt[j]){var ot=`
- `+Ce[M].replace(" at new "," at ");return h.displayName&&ot.includes("<anonymous>")&&(ot=ot.replace("<anonymous>",h.displayName)),ot}while(1<=M&&0<=j);break}}}finally{H=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?B(_):""}function $(h,m){switch(h.tag){case 26:case 27:case 5:return B(h.type);case 16:return B("Lazy");case 13:return h.child!==m&&m!==null?B("Suspense Fallback"):B("Suspense");case 19:return B("SuspenseList");case 0:case 15:return le(h.type,!1);case 11:return le(h.type.render,!1);case 1:return le(h.type,!0);case 31:return B("Activity");default:return""}}function ee(h){try{var m="",_=null;do m+=$(h,_),_=h,h=h.return;while(h);return m}catch(M){return`
- Error generating stack: `+M.message+`
- `+M.stack}}var de=Object.prototype.hasOwnProperty,ke=t.unstable_scheduleCallback,we=t.unstable_cancelCallback,Ee=t.unstable_shouldYield,U=t.unstable_requestPaint,I=t.unstable_now,se=t.unstable_getCurrentPriorityLevel,ye=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,ve=t.unstable_NormalPriority,Be=t.unstable_LowPriority,Ge=t.unstable_IdlePriority,Ke=t.log,ct=t.unstable_setDisableYieldValue,$e=null,ge=null;function Je(h){if(typeof Ke=="function"&&ct(h),ge&&typeof ge.setStrictMode=="function")try{ge.setStrictMode($e,h)}catch{}}var qe=Math.clz32?Math.clz32:ie,Ze=Math.log,lt=Math.LN2;function ie(h){return h>>>=0,h===0?32:31-(Ze(h)/lt|0)|0}var Ie=256,xe=262144,Ue=4194304;function Pe(h){var m=h&42;if(m!==0)return m;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function Me(h,m,_){var M=h.pendingLanes;if(M===0)return 0;var j=0,L=h.suspendedLanes,Q=h.pingedLanes;h=h.warmLanes;var me=M&134217727;return me!==0?(M=me&~L,M!==0?j=Pe(M):(Q&=me,Q!==0?j=Pe(Q):_||(_=me&~h,_!==0&&(j=Pe(_))))):(me=M&~L,me!==0?j=Pe(me):Q!==0?j=Pe(Q):_||(_=M&~h,_!==0&&(j=Pe(_)))),j===0?0:m!==0&&m!==j&&(m&L)===0&&(L=j&-j,_=m&-m,L>=_||L===32&&(_&4194048)!==0)?m:j}function Xe(h,m){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&m)===0}function ut(h,m){switch(h){case 1:case 2:case 4:case 8:case 64:return m+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return m+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function At(){var h=Ue;return Ue<<=1,(Ue&62914560)===0&&(Ue=4194304),h}function St(h){for(var m=[],_=0;31>_;_++)m.push(h);return m}function Yt(h,m){h.pendingLanes|=m,m!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Pt(h,m,_,M,j,L){var Q=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var me=h.entanglements,Ce=h.expirationTimes,tt=h.hiddenUpdates;for(_=Q&~_;0<_;){var ot=31-qe(_),pt=1<<ot;me[ot]=0,Ce[ot]=-1;var rt=tt[ot];if(rt!==null)for(tt[ot]=null,ot=0;ot<rt.length;ot++){var st=rt[ot];st!==null&&(st.lane&=-536870913)}_&=~pt}M!==0&&Jt(h,M,0),L!==0&&j===0&&h.tag!==0&&(h.suspendedLanes|=L&~(Q&~m))}function Jt(h,m,_){h.pendingLanes|=m,h.suspendedLanes&=~m;var M=31-qe(m);h.entangledLanes|=m,h.entanglements[M]=h.entanglements[M]|1073741824|_&261930}function Fn(h,m){var _=h.entangledLanes|=m;for(h=h.entanglements;_;){var M=31-qe(_),j=1<<M;j&m|h[M]&m&&(h[M]|=m),_&=~j}}function Sn(h,m){var _=m&-m;return _=(_&42)!==0?1:vr(_),(_&(h.suspendedLanes|m))!==0?0:_}function vr(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 ft(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Ht(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:AF(h.type))}function Qt(h,m){var _=G.p;try{return G.p=h,m()}finally{G.p=_}}var mt=Math.random().toString(36).slice(2),$t="__reactFiber$"+mt,cn="__reactProps$"+mt,Mn="__reactContainer$"+mt,qt="__reactEvents$"+mt,J="__reactListeners$"+mt,Ne="__reactHandles$"+mt,ze="__reactResources$"+mt,Ye="__reactMarker$"+mt;function nt(h){delete h[$t],delete h[cn],delete h[qt],delete h[J],delete h[Ne]}function Et(h){var m=h[$t];if(m)return m;for(var _=h.parentNode;_;){if(m=_[Mn]||_[$t]){if(_=m.alternate,m.child!==null||_!==null&&_.child!==null)for(h=dF(h);h!==null;){if(_=h[$t])return _;h=dF(h)}return m}h=_,_=h.parentNode}return null}function oe(h){if(h=h[$t]||h[Mn]){var m=h.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return h}return null}function Ae(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h.stateNode;throw Error(r(33))}function Re(h){var m=h[ze];return m||(m=h[ze]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function De(h){h[Ye]=!0}var je=new Set,at={};function bt(h,m){Tt(h,m),Tt(h+"Capture",m)}function Tt(h,m){for(at[h]=m,h=0;h<m.length;h++)je.add(m[h])}var Nt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Ft={},jt={};function _t(h){return de.call(jt,h)?!0:de.call(Ft,h)?!1:Nt.test(h)?jt[h]=!0:(Ft[h]=!0,!1)}function nn(h,m,_){if(_t(m))if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(m);return;case"boolean":var M=m.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){h.removeAttribute(m);return}}h.setAttribute(m,""+_)}}function Vt(h,m,_){if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(m);return}h.setAttribute(m,""+_)}}function fn(h,m,_,M){if(M===null)h.removeAttribute(_);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(m,_,""+M)}}function _n(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function jn(h){var m=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function Bt(h,m,_){var M=Object.getOwnPropertyDescriptor(h.constructor.prototype,m);if(!h.hasOwnProperty(m)&&typeof M<"u"&&typeof M.get=="function"&&typeof M.set=="function"){var j=M.get,L=M.set;return Object.defineProperty(h,m,{configurable:!0,get:function(){return j.call(this)},set:function(Q){_=""+Q,L.call(this,Q)}}),Object.defineProperty(h,m,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(Q){_=""+Q},stopTracking:function(){h._valueTracker=null,delete h[m]}}}}function sn(h){if(!h._valueTracker){var m=jn(h)?"checked":"value";h._valueTracker=Bt(h,m,""+h[m])}}function un(h){if(!h)return!1;var m=h._valueTracker;if(!m)return!0;var _=m.getValue(),M="";return h&&(M=jn(h)?h.checked?"true":"false":h.value),h=M,h!==_?(m.setValue(h),!0):!1}function zr(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var Yr=/[\n"\\]/g;function Gn(h){return h.replace(Yr,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function So(h,m,_,M,j,L,Q,me){h.name="",Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"?h.type=Q:h.removeAttribute("type"),m!=null?Q==="number"?(m===0&&h.value===""||h.value!=m)&&(h.value=""+_n(m)):h.value!==""+_n(m)&&(h.value=""+_n(m)):Q!=="submit"&&Q!=="reset"||h.removeAttribute("value"),m!=null?Li(h,Q,_n(m)):_!=null?Li(h,Q,_n(_)):M!=null&&h.removeAttribute("value"),j==null&&L!=null&&(h.defaultChecked=!!L),j!=null&&(h.checked=j&&typeof j!="function"&&typeof j!="symbol"),me!=null&&typeof me!="function"&&typeof me!="symbol"&&typeof me!="boolean"?h.name=""+_n(me):h.removeAttribute("name")}function qn(h,m,_,M,j,L,Q,me){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(h.type=L),m!=null||_!=null){if(!(L!=="submit"&&L!=="reset"||m!=null)){sn(h);return}_=_!=null?""+_n(_):"",m=m!=null?""+_n(m):_,me||m===h.value||(h.value=m),h.defaultValue=m}M=M??j,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=me?h.checked:!!M,h.defaultChecked=!!M,Q!=null&&typeof Q!="function"&&typeof Q!="symbol"&&typeof Q!="boolean"&&(h.name=Q),sn(h)}function Li(h,m,_){m==="number"&&zr(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function bi(h,m,_,M){if(h=h.options,m){m={};for(var j=0;j<_.length;j++)m["$"+_[j]]=!0;for(_=0;_<h.length;_++)j=m.hasOwnProperty("$"+h[_].value),h[_].selected!==j&&(h[_].selected=j),j&&M&&(h[_].defaultSelected=!0)}else{for(_=""+_n(_),m=null,j=0;j<h.length;j++){if(h[j].value===_){h[j].selected=!0,M&&(h[j].defaultSelected=!0);return}m!==null||h[j].disabled||(m=h[j])}m!==null&&(m.selected=!0)}}function Ii(h,m,_){if(m!=null&&(m=""+_n(m),m!==h.value&&(h.value=m),_==null)){h.defaultValue!==m&&(h.defaultValue=m);return}h.defaultValue=_!=null?""+_n(_):""}function Zi(h,m,_,M){if(m==null){if(M!=null){if(_!=null)throw Error(r(92));if(W(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),m=_}_=_n(m),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),sn(h)}function el(h,m){if(m){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=m;return}}h.textContent=m}var zl=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function eL(h,m,_){var M=m.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?M?h.setProperty(m,""):m==="float"?h.cssFloat="":h[m]="":M?h.setProperty(m,_):typeof _!="number"||_===0||zl.has(m)?m==="float"?h.cssFloat=_:h[m]=(""+_).trim():h[m]=_+"px"}function tL(h,m,_){if(m!=null&&typeof m!="object")throw Error(r(62));if(h=h.style,_!=null){for(var M in _)!_.hasOwnProperty(M)||m!=null&&m.hasOwnProperty(M)||(M.indexOf("--")===0?h.setProperty(M,""):M==="float"?h.cssFloat="":h[M]="");for(var j in m)M=m[j],m.hasOwnProperty(j)&&_[j]!==M&&eL(h,j,M)}else for(var L in m)m.hasOwnProperty(L)&&eL(h,L,m[L])}function $2(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 xne=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"]]),bne=/^[\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 Sy(h){return bne.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Bl(){}var V2=null;function G2(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var If=null,Ff=null;function nL(h){var m=oe(h);if(m&&(h=m.stateNode)){var _=h[cn]||null;e:switch(h=m.stateNode,m.type){case"input":if(So(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),m=_.name,_.type==="radio"&&m!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Gn(""+m)+'"][type="radio"]'),m=0;m<_.length;m++){var M=_[m];if(M!==h&&M.form===h.form){var j=M[cn]||null;if(!j)throw Error(r(90));So(M,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(m=0;m<_.length;m++)M=_[m],M.form===h.form&&un(M)}break e;case"textarea":Ii(h,_.value,_.defaultValue);break e;case"select":m=_.value,m!=null&&bi(h,!!_.multiple,m,!1)}}}var W2=!1;function rL(h,m,_){if(W2)return h(m,_);W2=!0;try{var M=h(m);return M}finally{if(W2=!1,(If!==null||Ff!==null)&&(uv(),If&&(m=If,h=Ff,Ff=If=null,nL(m),h)))for(m=0;m<h.length;m++)nL(h[m])}}function Og(h,m){var _=h.stateNode;if(_===null)return null;var M=_[cn]||null;if(M===null)return null;_=M[m];e:switch(m){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(h=h.type,M=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!M;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,m,typeof _));return _}var Hl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),q2=!1;if(Hl)try{var Lg={};Object.defineProperty(Lg,"passive",{get:function(){q2=!0}}),window.addEventListener("test",Lg,Lg),window.removeEventListener("test",Lg,Lg)}catch{q2=!1}var ou=null,K2=null,My=null;function iL(){if(My)return My;var h,m=K2,_=m.length,M,j="value"in ou?ou.value:ou.textContent,L=j.length;for(h=0;h<_&&m[h]===j[h];h++);var Q=_-h;for(M=1;M<=Q&&m[_-M]===j[L-M];M++);return My=j.slice(h,1<M?1-M:void 0)}function Ey(h){var m=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&m===13&&(h=13)):h=m,h===10&&(h=13),32<=h||h===13?h:0}function Ny(){return!0}function aL(){return!1}function Wa(h){function m(_,M,j,L,Q){this._reactName=_,this._targetInst=j,this.type=M,this.nativeEvent=L,this.target=Q,this.currentTarget=null;for(var me in h)h.hasOwnProperty(me)&&(_=h[me],this[me]=_?_(L):L[me]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Ny:aL,this.isPropagationStopped=aL,this}return f(m.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Ny)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Ny)},persist:function(){},isPersistent:Ny}),m}var Kd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ay=Wa(Kd),Ig=f({},Kd,{view:0,detail:0}),yne=Wa(Ig),X2,Y2,Fg,Ty=f({},Ig,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Q2,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!==Fg&&(Fg&&h.type==="mousemove"?(X2=h.screenX-Fg.screenX,Y2=h.screenY-Fg.screenY):Y2=X2=0,Fg=h),X2)},movementY:function(h){return"movementY"in h?h.movementY:Y2}}),sL=Wa(Ty),vne=f({},Ty,{dataTransfer:0}),_ne=Wa(vne),wne=f({},Ig,{relatedTarget:0}),Z2=Wa(wne),Sne=f({},Kd,{animationName:0,elapsedTime:0,pseudoElement:0}),Mne=Wa(Sne),Ene=f({},Kd,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Nne=Wa(Ene),Ane=f({},Kd,{data:0}),oL=Wa(Ane),Tne={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Cne={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"},kne={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function jne(h){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(h):(h=kne[h])?!!m[h]:!1}function Q2(){return jne}var Pne=f({},Ig,{key:function(h){if(h.key){var m=Tne[h.key]||h.key;if(m!=="Unidentified")return m}return h.type==="keypress"?(h=Ey(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Cne[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Q2,charCode:function(h){return h.type==="keypress"?Ey(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Ey(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Rne=Wa(Pne),Dne=f({},Ty,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),lL=Wa(Dne),One=f({},Ig,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Q2}),Lne=Wa(One),Ine=f({},Kd,{propertyName:0,elapsedTime:0,pseudoElement:0}),Fne=Wa(Ine),Une=f({},Ty,{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}),zne=Wa(Une),Bne=f({},Kd,{newState:0,oldState:0}),Hne=Wa(Bne),$ne=[9,13,27,32],J2=Hl&&"CompositionEvent"in window,Ug=null;Hl&&"documentMode"in document&&(Ug=document.documentMode);var Vne=Hl&&"TextEvent"in window&&!Ug,cL=Hl&&(!J2||Ug&&8<Ug&&11>=Ug),uL=" ",dL=!1;function hL(h,m){switch(h){case"keyup":return $ne.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Uf=!1;function Gne(h,m){switch(h){case"compositionend":return fL(m);case"keypress":return m.which!==32?null:(dL=!0,uL);case"textInput":return h=m.data,h===uL&&dL?null:h;default:return null}}function Wne(h,m){if(Uf)return h==="compositionend"||!J2&&hL(h,m)?(h=iL(),My=K2=ou=null,Uf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1<m.char.length)return m.char;if(m.which)return String.fromCharCode(m.which)}return null;case"compositionend":return cL&&m.locale!=="ko"?null:m.data;default:return null}}var qne={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function mL(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m==="input"?!!qne[h.type]:m==="textarea"}function pL(h,m,_,M){If?Ff?Ff.push(M):Ff=[M]:If=M,m=xv(m,"onChange"),0<m.length&&(_=new Ay("onChange","change",null,_,M),h.push({event:_,listeners:m}))}var zg=null,Bg=null;function Kne(h){Z5(h,0)}function Cy(h){var m=Ae(h);if(un(m))return h}function gL(h,m){if(h==="change")return m}var xL=!1;if(Hl){var eE;if(Hl){var tE="oninput"in document;if(!tE){var bL=document.createElement("div");bL.setAttribute("oninput","return;"),tE=typeof bL.oninput=="function"}eE=tE}else eE=!1;xL=eE&&(!document.documentMode||9<document.documentMode)}function yL(){zg&&(zg.detachEvent("onpropertychange",vL),Bg=zg=null)}function vL(h){if(h.propertyName==="value"&&Cy(Bg)){var m=[];pL(m,Bg,h,G2(h)),rL(Kne,m)}}function Xne(h,m,_){h==="focusin"?(yL(),zg=m,Bg=_,zg.attachEvent("onpropertychange",vL)):h==="focusout"&&yL()}function Yne(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Cy(Bg)}function Zne(h,m){if(h==="click")return Cy(m)}function Qne(h,m){if(h==="input"||h==="change")return Cy(m)}function Jne(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var gs=typeof Object.is=="function"?Object.is:Jne;function Hg(h,m){if(gs(h,m))return!0;if(typeof h!="object"||h===null||typeof m!="object"||m===null)return!1;var _=Object.keys(h),M=Object.keys(m);if(_.length!==M.length)return!1;for(M=0;M<_.length;M++){var j=_[M];if(!de.call(m,j)||!gs(h[j],m[j]))return!1}return!0}function _L(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function wL(h,m){var _=_L(h);h=0;for(var M;_;){if(_.nodeType===3){if(M=h+_.textContent.length,h<=m&&M>=m)return{node:_,offset:m-h};h=M}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=_L(_)}}function SL(h,m){return h&&m?h===m?!0:h&&h.nodeType===3?!1:m&&m.nodeType===3?SL(h,m.parentNode):"contains"in h?h.contains(m):h.compareDocumentPosition?!!(h.compareDocumentPosition(m)&16):!1:!1}function ML(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var m=zr(h.document);m instanceof h.HTMLIFrameElement;){try{var _=typeof m.contentWindow.location.href=="string"}catch{_=!1}if(_)h=m.contentWindow;else break;m=zr(h.document)}return m}function nE(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m&&(m==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||m==="textarea"||h.contentEditable==="true")}var ere=Hl&&"documentMode"in document&&11>=document.documentMode,zf=null,rE=null,$g=null,iE=!1;function EL(h,m,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;iE||zf==null||zf!==zr(M)||(M=zf,"selectionStart"in M&&nE(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),$g&&Hg($g,M)||($g=M,M=xv(rE,"onSelect"),0<M.length&&(m=new Ay("onSelect","select",null,m,_),h.push({event:m,listeners:M}),m.target=zf)))}function Xd(h,m){var _={};return _[h.toLowerCase()]=m.toLowerCase(),_["Webkit"+h]="webkit"+m,_["Moz"+h]="moz"+m,_}var Bf={animationend:Xd("Animation","AnimationEnd"),animationiteration:Xd("Animation","AnimationIteration"),animationstart:Xd("Animation","AnimationStart"),transitionrun:Xd("Transition","TransitionRun"),transitionstart:Xd("Transition","TransitionStart"),transitioncancel:Xd("Transition","TransitionCancel"),transitionend:Xd("Transition","TransitionEnd")},aE={},NL={};Hl&&(NL=document.createElement("div").style,"AnimationEvent"in window||(delete Bf.animationend.animation,delete Bf.animationiteration.animation,delete Bf.animationstart.animation),"TransitionEvent"in window||delete Bf.transitionend.transition);function Yd(h){if(aE[h])return aE[h];if(!Bf[h])return h;var m=Bf[h],_;for(_ in m)if(m.hasOwnProperty(_)&&_ in NL)return aE[h]=m[_];return h}var AL=Yd("animationend"),TL=Yd("animationiteration"),CL=Yd("animationstart"),tre=Yd("transitionrun"),nre=Yd("transitionstart"),rre=Yd("transitioncancel"),kL=Yd("transitionend"),jL=new Map,sE="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(" ");sE.push("scrollEnd");function Mo(h,m){jL.set(h,m),bt(m,[h])}var ky=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var m=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(m))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Us=[],Hf=0,oE=0;function jy(){for(var h=Hf,m=oE=Hf=0;m<h;){var _=Us[m];Us[m++]=null;var M=Us[m];Us[m++]=null;var j=Us[m];Us[m++]=null;var L=Us[m];if(Us[m++]=null,M!==null&&j!==null){var Q=M.pending;Q===null?j.next=j:(j.next=Q.next,Q.next=j),M.pending=j}L!==0&&PL(_,j,L)}}function Py(h,m,_,M){Us[Hf++]=h,Us[Hf++]=m,Us[Hf++]=_,Us[Hf++]=M,oE|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function lE(h,m,_,M){return Py(h,m,_,M),Ry(h)}function Zd(h,m){return Py(h,null,null,m),Ry(h)}function PL(h,m,_){h.lanes|=_;var M=h.alternate;M!==null&&(M.lanes|=_);for(var j=!1,L=h.return;L!==null;)L.childLanes|=_,M=L.alternate,M!==null&&(M.childLanes|=_),L.tag===22&&(h=L.stateNode,h===null||h._visibility&1||(j=!0)),h=L,L=L.return;return h.tag===3?(L=h.stateNode,j&&m!==null&&(j=31-qe(_),h=L.hiddenUpdates,M=h[j],M===null?h[j]=[m]:M.push(m),m.lane=_|536870912),L):null}function Ry(h){if(50<dx)throw dx=0,xN=null,Error(r(185));for(var m=h.return;m!==null;)h=m,m=h.return;return h.tag===3?h.stateNode:null}var $f={};function ire(h,m,_,M){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function xs(h,m,_,M){return new ire(h,m,_,M)}function cE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function $l(h,m){var _=h.alternate;return _===null?(_=xs(h.tag,m,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=m,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,m=h.dependencies,_.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function RL(h,m){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=m,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,m=_.dependencies,h.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext}),h}function Dy(h,m,_,M,j,L){var Q=0;if(M=h,typeof h=="function")cE(h)&&(Q=1);else if(typeof h=="string")Q=cie(h,_,re.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case k:return h=xs(31,_,m,j),h.elementType=k,h.lanes=L,h;case y:return Qd(_.children,j,L,m);case b:Q=8,j|=24;break;case v:return h=xs(12,_,m,j|2),h.elementType=v,h.lanes=L,h;case N:return h=xs(13,_,m,j),h.elementType=N,h.lanes=L,h;case C:return h=xs(19,_,m,j),h.elementType=C,h.lanes=L,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case w:Q=10;break e;case E:Q=9;break e;case A:Q=11;break e;case T:Q=14;break e;case O:Q=16,M=null;break e}Q=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return m=xs(Q,_,m,j),m.elementType=h,m.type=M,m.lanes=L,m}function Qd(h,m,_,M){return h=xs(7,h,M,m),h.lanes=_,h}function uE(h,m,_){return h=xs(6,h,null,m),h.lanes=_,h}function DL(h){var m=xs(18,null,null,0);return m.stateNode=h,m}function dE(h,m,_){return m=xs(4,h.children!==null?h.children:[],h.key,m),m.lanes=_,m.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},m}var OL=new WeakMap;function zs(h,m){if(typeof h=="object"&&h!==null){var _=OL.get(h);return _!==void 0?_:(m={value:h,source:m,stack:ee(m)},OL.set(h,m),m)}return{value:h,source:m,stack:ee(m)}}var Vf=[],Gf=0,Oy=null,Vg=0,Bs=[],Hs=0,lu=null,tl=1,nl="";function Vl(h,m){Vf[Gf++]=Vg,Vf[Gf++]=Oy,Oy=h,Vg=m}function LL(h,m,_){Bs[Hs++]=tl,Bs[Hs++]=nl,Bs[Hs++]=lu,lu=h;var M=tl;h=nl;var j=32-qe(M)-1;M&=~(1<<j),_+=1;var L=32-qe(m)+j;if(30<L){var Q=j-j%5;L=(M&(1<<Q)-1).toString(32),M>>=Q,j-=Q,tl=1<<32-qe(m)+j|_<<j|M,nl=L+h}else tl=1<<L|_<<j|M,nl=h}function hE(h){h.return!==null&&(Vl(h,1),LL(h,1,0))}function fE(h){for(;h===Oy;)Oy=Vf[--Gf],Vf[Gf]=null,Vg=Vf[--Gf],Vf[Gf]=null;for(;h===lu;)lu=Bs[--Hs],Bs[Hs]=null,nl=Bs[--Hs],Bs[Hs]=null,tl=Bs[--Hs],Bs[Hs]=null}function IL(h,m){Bs[Hs++]=tl,Bs[Hs++]=nl,Bs[Hs++]=lu,tl=m.id,nl=m.overflow,lu=h}var Qi=null,_r=null,Dn=!1,cu=null,$s=!1,mE=Error(r(519));function uu(h){var m=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Gg(zs(m,h)),mE}function FL(h){var m=h.stateNode,_=h.type,M=h.memoizedProps;switch(m[$t]=h,m[cn]=M,_){case"dialog":Nn("cancel",m),Nn("close",m);break;case"iframe":case"object":case"embed":Nn("load",m);break;case"video":case"audio":for(_=0;_<fx.length;_++)Nn(fx[_],m);break;case"source":Nn("error",m);break;case"img":case"image":case"link":Nn("error",m),Nn("load",m);break;case"details":Nn("toggle",m);break;case"input":Nn("invalid",m),qn(m,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":Nn("invalid",m);break;case"textarea":Nn("invalid",m),Zi(m,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||m.textContent===""+_||M.suppressHydrationWarning===!0||tF(m.textContent,_)?(M.popover!=null&&(Nn("beforetoggle",m),Nn("toggle",m)),M.onScroll!=null&&Nn("scroll",m),M.onScrollEnd!=null&&Nn("scrollend",m),M.onClick!=null&&(m.onclick=Bl),m=!0):m=!1,m||uu(h,!0)}function UL(h){for(Qi=h.return;Qi;)switch(Qi.tag){case 5:case 31:case 13:$s=!1;return;case 27:case 3:$s=!0;return;default:Qi=Qi.return}}function Wf(h){if(h!==Qi)return!1;if(!Dn)return UL(h),Dn=!0,!1;var m=h.tag,_;if((_=m!==3&&m!==27)&&((_=m===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||PN(h.type,h.memoizedProps)),_=!_),_&&_r&&uu(h),UL(h),m===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=uF(h)}else if(m===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=uF(h)}else m===27?(m=_r,Mu(h.type)?(h=IN,IN=null,_r=h):_r=m):_r=Qi?Gs(h.stateNode.nextSibling):null;return!0}function Jd(){_r=Qi=null,Dn=!1}function pE(){var h=cu;return h!==null&&(Ya===null?Ya=h:Ya.push.apply(Ya,h),cu=null),h}function Gg(h){cu===null?cu=[h]:cu.push(h)}var gE=F(null),eh=null,Gl=null;function du(h,m,_){te(gE,m._currentValue),m._currentValue=_}function Wl(h){h._currentValue=gE.current,V(gE)}function xE(h,m,_){for(;h!==null;){var M=h.alternate;if((h.childLanes&m)!==m?(h.childLanes|=m,M!==null&&(M.childLanes|=m)):M!==null&&(M.childLanes&m)!==m&&(M.childLanes|=m),h===_)break;h=h.return}}function bE(h,m,_,M){var j=h.child;for(j!==null&&(j.return=h);j!==null;){var L=j.dependencies;if(L!==null){var Q=j.child;L=L.firstContext;e:for(;L!==null;){var me=L;L=j;for(var Ce=0;Ce<m.length;Ce++)if(me.context===m[Ce]){L.lanes|=_,me=L.alternate,me!==null&&(me.lanes|=_),xE(L.return,_,h),M||(Q=null);break e}L=me.next}}else if(j.tag===18){if(Q=j.return,Q===null)throw Error(r(341));Q.lanes|=_,L=Q.alternate,L!==null&&(L.lanes|=_),xE(Q,_,h),Q=null}else Q=j.child;if(Q!==null)Q.return=j;else for(Q=j;Q!==null;){if(Q===h){Q=null;break}if(j=Q.sibling,j!==null){j.return=Q.return,Q=j;break}Q=Q.return}j=Q}}function qf(h,m,_,M){h=null;for(var j=m,L=!1;j!==null;){if(!L){if((j.flags&524288)!==0)L=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var Q=j.alternate;if(Q===null)throw Error(r(387));if(Q=Q.memoizedProps,Q!==null){var me=j.type;gs(j.pendingProps.value,Q.value)||(h!==null?h.push(me):h=[me])}}else if(j===ue.current){if(Q=j.alternate,Q===null)throw Error(r(387));Q.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(h!==null?h.push(bx):h=[bx])}j=j.return}h!==null&&bE(m,h,_,M),m.flags|=262144}function Ly(h){for(h=h.firstContext;h!==null;){if(!gs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function th(h){eh=h,Gl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Ji(h){return zL(eh,h)}function Iy(h,m){return eh===null&&th(h),zL(h,m)}function zL(h,m){var _=m._currentValue;if(m={context:m,memoizedValue:_,next:null},Gl===null){if(h===null)throw Error(r(308));Gl=m,h.dependencies={lanes:0,firstContext:m},h.flags|=524288}else Gl=Gl.next=m;return _}var are=typeof AbortController<"u"?AbortController:function(){var h=[],m=this.signal={aborted:!1,addEventListener:function(_,M){h.push(M)}};this.abort=function(){m.aborted=!0,h.forEach(function(_){return _()})}},sre=t.unstable_scheduleCallback,ore=t.unstable_NormalPriority,ri={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function yE(){return{controller:new are,data:new Map,refCount:0}}function Wg(h){h.refCount--,h.refCount===0&&sre(ore,function(){h.controller.abort()})}var qg=null,vE=0,Kf=0,Xf=null;function lre(h,m){if(qg===null){var _=qg=[];vE=0,Kf=SN(),Xf={status:"pending",value:void 0,then:function(M){_.push(M)}}}return vE++,m.then(BL,BL),m}function BL(){if(--vE===0&&qg!==null){Xf!==null&&(Xf.status="fulfilled");var h=qg;qg=null,Kf=0,Xf=null;for(var m=0;m<h.length;m++)(0,h[m])()}}function cre(h,m){var _=[],M={status:"pending",value:null,reason:null,then:function(j){_.push(j)}};return h.then(function(){M.status="fulfilled",M.value=m;for(var j=0;j<_.length;j++)(0,_[j])(m)},function(j){for(M.status="rejected",M.reason=j,j=0;j<_.length;j++)(0,_[j])(void 0)}),M}var HL=Z.S;Z.S=function(h,m){E5=I(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&lre(h,m),HL!==null&&HL(h,m)};var nh=F(null);function _E(){var h=nh.current;return h!==null?h:fr.pooledCache}function Fy(h,m){m===null?te(nh,nh.current):te(nh,m.pool)}function $L(){var h=_E();return h===null?null:{parent:ri._currentValue,pool:h}}var Yf=Error(r(460)),wE=Error(r(474)),Uy=Error(r(542)),zy={then:function(){}};function VL(h){return h=h.status,h==="fulfilled"||h==="rejected"}function GL(h,m,_){switch(_=h[_],_===void 0?h.push(m):_!==m&&(m.then(Bl,Bl),m=_),m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,qL(h),h;default:if(typeof m.status=="string")m.then(Bl,Bl);else{if(h=fr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=m,h.status="pending",h.then(function(M){if(m.status==="pending"){var j=m;j.status="fulfilled",j.value=M}},function(M){if(m.status==="pending"){var j=m;j.status="rejected",j.reason=M}})}switch(m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,qL(h),h}throw ih=m,Yf}}function rh(h){try{var m=h._init;return m(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(ih=_,Yf):_}}var ih=null;function WL(){if(ih===null)throw Error(r(459));var h=ih;return ih=null,h}function qL(h){if(h===Yf||h===Uy)throw Error(r(483))}var Zf=null,Kg=0;function By(h){var m=Kg;return Kg+=1,Zf===null&&(Zf=[]),GL(Zf,h,m)}function Xg(h,m){m=m.props.ref,h.ref=m!==void 0?m:null}function Hy(h,m){throw m.$$typeof===g?Error(r(525)):(h=Object.prototype.toString.call(m),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(m).join(", ")+"}":h)))}function KL(h){function m(Ve,Oe){if(h){var et=Ve.deletions;et===null?(Ve.deletions=[Oe],Ve.flags|=16):et.push(Oe)}}function _(Ve,Oe){if(!h)return null;for(;Oe!==null;)m(Ve,Oe),Oe=Oe.sibling;return null}function M(Ve){for(var Oe=new Map;Ve!==null;)Ve.key!==null?Oe.set(Ve.key,Ve):Oe.set(Ve.index,Ve),Ve=Ve.sibling;return Oe}function j(Ve,Oe){return Ve=$l(Ve,Oe),Ve.index=0,Ve.sibling=null,Ve}function L(Ve,Oe,et){return Ve.index=et,h?(et=Ve.alternate,et!==null?(et=et.index,et<Oe?(Ve.flags|=67108866,Oe):et):(Ve.flags|=67108866,Oe)):(Ve.flags|=1048576,Oe)}function Q(Ve){return h&&Ve.alternate===null&&(Ve.flags|=67108866),Ve}function me(Ve,Oe,et,dt){return Oe===null||Oe.tag!==6?(Oe=uE(et,Ve.mode,dt),Oe.return=Ve,Oe):(Oe=j(Oe,et),Oe.return=Ve,Oe)}function Ce(Ve,Oe,et,dt){var Gt=et.type;return Gt===y?ot(Ve,Oe,et.props.children,dt,et.key):Oe!==null&&(Oe.elementType===Gt||typeof Gt=="object"&&Gt!==null&&Gt.$$typeof===O&&rh(Gt)===Oe.type)?(Oe=j(Oe,et.props),Xg(Oe,et),Oe.return=Ve,Oe):(Oe=Dy(et.type,et.key,et.props,null,Ve.mode,dt),Xg(Oe,et),Oe.return=Ve,Oe)}function tt(Ve,Oe,et,dt){return Oe===null||Oe.tag!==4||Oe.stateNode.containerInfo!==et.containerInfo||Oe.stateNode.implementation!==et.implementation?(Oe=dE(et,Ve.mode,dt),Oe.return=Ve,Oe):(Oe=j(Oe,et.children||[]),Oe.return=Ve,Oe)}function ot(Ve,Oe,et,dt,Gt){return Oe===null||Oe.tag!==7?(Oe=Qd(et,Ve.mode,dt,Gt),Oe.return=Ve,Oe):(Oe=j(Oe,et),Oe.return=Ve,Oe)}function pt(Ve,Oe,et){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number"||typeof Oe=="bigint")return Oe=uE(""+Oe,Ve.mode,et),Oe.return=Ve,Oe;if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case p:return et=Dy(Oe.type,Oe.key,Oe.props,null,Ve.mode,et),Xg(et,Oe),et.return=Ve,et;case x:return Oe=dE(Oe,Ve.mode,et),Oe.return=Ve,Oe;case O:return Oe=rh(Oe),pt(Ve,Oe,et)}if(W(Oe)||D(Oe))return Oe=Qd(Oe,Ve.mode,et,null),Oe.return=Ve,Oe;if(typeof Oe.then=="function")return pt(Ve,By(Oe),et);if(Oe.$$typeof===w)return pt(Ve,Iy(Ve,Oe),et);Hy(Ve,Oe)}return null}function rt(Ve,Oe,et,dt){var Gt=Oe!==null?Oe.key:null;if(typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint")return Gt!==null?null:me(Ve,Oe,""+et,dt);if(typeof et=="object"&&et!==null){switch(et.$$typeof){case p:return et.key===Gt?Ce(Ve,Oe,et,dt):null;case x:return et.key===Gt?tt(Ve,Oe,et,dt):null;case O:return et=rh(et),rt(Ve,Oe,et,dt)}if(W(et)||D(et))return Gt!==null?null:ot(Ve,Oe,et,dt,null);if(typeof et.then=="function")return rt(Ve,Oe,By(et),dt);if(et.$$typeof===w)return rt(Ve,Oe,Iy(Ve,et),dt);Hy(Ve,et)}return null}function st(Ve,Oe,et,dt,Gt){if(typeof dt=="string"&&dt!==""||typeof dt=="number"||typeof dt=="bigint")return Ve=Ve.get(et)||null,me(Oe,Ve,""+dt,Gt);if(typeof dt=="object"&&dt!==null){switch(dt.$$typeof){case p:return Ve=Ve.get(dt.key===null?et:dt.key)||null,Ce(Oe,Ve,dt,Gt);case x:return Ve=Ve.get(dt.key===null?et:dt.key)||null,tt(Oe,Ve,dt,Gt);case O:return dt=rh(dt),st(Ve,Oe,et,dt,Gt)}if(W(dt)||D(dt))return Ve=Ve.get(et)||null,ot(Oe,Ve,dt,Gt,null);if(typeof dt.then=="function")return st(Ve,Oe,et,By(dt),Gt);if(dt.$$typeof===w)return st(Ve,Oe,et,Iy(Oe,dt),Gt);Hy(Oe,dt)}return null}function It(Ve,Oe,et,dt){for(var Gt=null,Un=null,Ut=Oe,hn=Oe=0,Rn=null;Ut!==null&&hn<et.length;hn++){Ut.index>hn?(Rn=Ut,Ut=null):Rn=Ut.sibling;var zn=rt(Ve,Ut,et[hn],dt);if(zn===null){Ut===null&&(Ut=Rn);break}h&&Ut&&zn.alternate===null&&m(Ve,Ut),Oe=L(zn,Oe,hn),Un===null?Gt=zn:Un.sibling=zn,Un=zn,Ut=Rn}if(hn===et.length)return _(Ve,Ut),Dn&&Vl(Ve,hn),Gt;if(Ut===null){for(;hn<et.length;hn++)Ut=pt(Ve,et[hn],dt),Ut!==null&&(Oe=L(Ut,Oe,hn),Un===null?Gt=Ut:Un.sibling=Ut,Un=Ut);return Dn&&Vl(Ve,hn),Gt}for(Ut=M(Ut);hn<et.length;hn++)Rn=st(Ut,Ve,hn,et[hn],dt),Rn!==null&&(h&&Rn.alternate!==null&&Ut.delete(Rn.key===null?hn:Rn.key),Oe=L(Rn,Oe,hn),Un===null?Gt=Rn:Un.sibling=Rn,Un=Rn);return h&&Ut.forEach(function(Cu){return m(Ve,Cu)}),Dn&&Vl(Ve,hn),Gt}function Zt(Ve,Oe,et,dt){if(et==null)throw Error(r(151));for(var Gt=null,Un=null,Ut=Oe,hn=Oe=0,Rn=null,zn=et.next();Ut!==null&&!zn.done;hn++,zn=et.next()){Ut.index>hn?(Rn=Ut,Ut=null):Rn=Ut.sibling;var Cu=rt(Ve,Ut,zn.value,dt);if(Cu===null){Ut===null&&(Ut=Rn);break}h&&Ut&&Cu.alternate===null&&m(Ve,Ut),Oe=L(Cu,Oe,hn),Un===null?Gt=Cu:Un.sibling=Cu,Un=Cu,Ut=Rn}if(zn.done)return _(Ve,Ut),Dn&&Vl(Ve,hn),Gt;if(Ut===null){for(;!zn.done;hn++,zn=et.next())zn=pt(Ve,zn.value,dt),zn!==null&&(Oe=L(zn,Oe,hn),Un===null?Gt=zn:Un.sibling=zn,Un=zn);return Dn&&Vl(Ve,hn),Gt}for(Ut=M(Ut);!zn.done;hn++,zn=et.next())zn=st(Ut,Ve,hn,zn.value,dt),zn!==null&&(h&&zn.alternate!==null&&Ut.delete(zn.key===null?hn:zn.key),Oe=L(zn,Oe,hn),Un===null?Gt=zn:Un.sibling=zn,Un=zn);return h&&Ut.forEach(function(vie){return m(Ve,vie)}),Dn&&Vl(Ve,hn),Gt}function rr(Ve,Oe,et,dt){if(typeof et=="object"&&et!==null&&et.type===y&&et.key===null&&(et=et.props.children),typeof et=="object"&&et!==null){switch(et.$$typeof){case p:e:{for(var Gt=et.key;Oe!==null;){if(Oe.key===Gt){if(Gt=et.type,Gt===y){if(Oe.tag===7){_(Ve,Oe.sibling),dt=j(Oe,et.props.children),dt.return=Ve,Ve=dt;break e}}else if(Oe.elementType===Gt||typeof Gt=="object"&&Gt!==null&&Gt.$$typeof===O&&rh(Gt)===Oe.type){_(Ve,Oe.sibling),dt=j(Oe,et.props),Xg(dt,et),dt.return=Ve,Ve=dt;break e}_(Ve,Oe);break}else m(Ve,Oe);Oe=Oe.sibling}et.type===y?(dt=Qd(et.props.children,Ve.mode,dt,et.key),dt.return=Ve,Ve=dt):(dt=Dy(et.type,et.key,et.props,null,Ve.mode,dt),Xg(dt,et),dt.return=Ve,Ve=dt)}return Q(Ve);case x:e:{for(Gt=et.key;Oe!==null;){if(Oe.key===Gt)if(Oe.tag===4&&Oe.stateNode.containerInfo===et.containerInfo&&Oe.stateNode.implementation===et.implementation){_(Ve,Oe.sibling),dt=j(Oe,et.children||[]),dt.return=Ve,Ve=dt;break e}else{_(Ve,Oe);break}else m(Ve,Oe);Oe=Oe.sibling}dt=dE(et,Ve.mode,dt),dt.return=Ve,Ve=dt}return Q(Ve);case O:return et=rh(et),rr(Ve,Oe,et,dt)}if(W(et))return It(Ve,Oe,et,dt);if(D(et)){if(Gt=D(et),typeof Gt!="function")throw Error(r(150));return et=Gt.call(et),Zt(Ve,Oe,et,dt)}if(typeof et.then=="function")return rr(Ve,Oe,By(et),dt);if(et.$$typeof===w)return rr(Ve,Oe,Iy(Ve,et),dt);Hy(Ve,et)}return typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint"?(et=""+et,Oe!==null&&Oe.tag===6?(_(Ve,Oe.sibling),dt=j(Oe,et),dt.return=Ve,Ve=dt):(_(Ve,Oe),dt=uE(et,Ve.mode,dt),dt.return=Ve,Ve=dt),Q(Ve)):_(Ve,Oe)}return function(Ve,Oe,et,dt){try{Kg=0;var Gt=rr(Ve,Oe,et,dt);return Zf=null,Gt}catch(Ut){if(Ut===Yf||Ut===Uy)throw Ut;var Un=xs(29,Ut,null,Ve.mode);return Un.lanes=dt,Un.return=Ve,Un}finally{}}}var ah=KL(!0),XL=KL(!1),hu=!1;function SE(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ME(h,m){h=h.updateQueue,m.updateQueue===h&&(m.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function fu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function mu(h,m,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,($n&2)!==0){var j=M.pending;return j===null?m.next=m:(m.next=j.next,j.next=m),M.pending=m,m=Ry(h),PL(h,null,_),m}return Py(h,M,m,_),Ry(h)}function Yg(h,m,_){if(m=m.updateQueue,m!==null&&(m=m.shared,(_&4194048)!==0)){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,Fn(h,_)}}function EE(h,m){var _=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var j=null,L=null;if(_=_.firstBaseUpdate,_!==null){do{var Q={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};L===null?j=L=Q:L=L.next=Q,_=_.next}while(_!==null);L===null?j=L=m:L=L.next=m}else j=L=m;_={baseState:M.baseState,firstBaseUpdate:j,lastBaseUpdate:L,shared:M.shared,callbacks:M.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=m:h.next=m,_.lastBaseUpdate=m}var NE=!1;function Zg(){if(NE){var h=Xf;if(h!==null)throw h}}function Qg(h,m,_,M){NE=!1;var j=h.updateQueue;hu=!1;var L=j.firstBaseUpdate,Q=j.lastBaseUpdate,me=j.shared.pending;if(me!==null){j.shared.pending=null;var Ce=me,tt=Ce.next;Ce.next=null,Q===null?L=tt:Q.next=tt,Q=Ce;var ot=h.alternate;ot!==null&&(ot=ot.updateQueue,me=ot.lastBaseUpdate,me!==Q&&(me===null?ot.firstBaseUpdate=tt:me.next=tt,ot.lastBaseUpdate=Ce))}if(L!==null){var pt=j.baseState;Q=0,ot=tt=Ce=null,me=L;do{var rt=me.lane&-536870913,st=rt!==me.lane;if(st?(Pn&rt)===rt:(M&rt)===rt){rt!==0&&rt===Kf&&(NE=!0),ot!==null&&(ot=ot.next={lane:0,tag:me.tag,payload:me.payload,callback:null,next:null});e:{var It=h,Zt=me;rt=m;var rr=_;switch(Zt.tag){case 1:if(It=Zt.payload,typeof It=="function"){pt=It.call(rr,pt,rt);break e}pt=It;break e;case 3:It.flags=It.flags&-65537|128;case 0:if(It=Zt.payload,rt=typeof It=="function"?It.call(rr,pt,rt):It,rt==null)break e;pt=f({},pt,rt);break e;case 2:hu=!0}}rt=me.callback,rt!==null&&(h.flags|=64,st&&(h.flags|=8192),st=j.callbacks,st===null?j.callbacks=[rt]:st.push(rt))}else st={lane:rt,tag:me.tag,payload:me.payload,callback:me.callback,next:null},ot===null?(tt=ot=st,Ce=pt):ot=ot.next=st,Q|=rt;if(me=me.next,me===null){if(me=j.shared.pending,me===null)break;st=me,me=st.next,st.next=null,j.lastBaseUpdate=st,j.shared.pending=null}}while(!0);ot===null&&(Ce=pt),j.baseState=Ce,j.firstBaseUpdate=tt,j.lastBaseUpdate=ot,L===null&&(j.shared.lanes=0),yu|=Q,h.lanes=Q,h.memoizedState=pt}}function YL(h,m){if(typeof h!="function")throw Error(r(191,h));h.call(m)}function ZL(h,m){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)YL(_[h],m)}var Qf=F(null),$y=F(0);function QL(h,m){h=tc,te($y,h),te(Qf,m),tc=h|m.baseLanes}function AE(){te($y,tc),te(Qf,Qf.current)}function TE(){tc=$y.current,V(Qf),V($y)}var bs=F(null),Vs=null;function pu(h){var m=h.alternate;te(Zr,Zr.current&1),te(bs,h),Vs===null&&(m===null||Qf.current!==null||m.memoizedState!==null)&&(Vs=h)}function CE(h){te(Zr,Zr.current),te(bs,h),Vs===null&&(Vs=h)}function JL(h){h.tag===22?(te(Zr,Zr.current),te(bs,h),Vs===null&&(Vs=h)):gu()}function gu(){te(Zr,Zr.current),te(bs,bs.current)}function ys(h){V(bs),Vs===h&&(Vs=null),V(Zr)}var Zr=F(0);function Vy(h){for(var m=h;m!==null;){if(m.tag===13){var _=m.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||ON(_)||LN(_)))return m}else if(m.tag===19&&(m.memoizedProps.revealOrder==="forwards"||m.memoizedProps.revealOrder==="backwards"||m.memoizedProps.revealOrder==="unstable_legacy-backwards"||m.memoizedProps.revealOrder==="together")){if((m.flags&128)!==0)return m}else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return null;m=m.return}m.sibling.return=m.return,m=m.sibling}return null}var ql=0,dn=null,tr=null,ii=null,Gy=!1,Jf=!1,sh=!1,Wy=0,Jg=0,em=null,ure=0;function Br(){throw Error(r(321))}function kE(h,m){if(m===null)return!1;for(var _=0;_<m.length&&_<h.length;_++)if(!gs(h[_],m[_]))return!1;return!0}function jE(h,m,_,M,j,L){return ql=L,dn=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,Z.H=h===null||h.memoizedState===null?LI:WE,sh=!1,L=_(M,j),sh=!1,Jf&&(L=tI(m,_,M,j)),eI(h),L}function eI(h){Z.H=nx;var m=tr!==null&&tr.next!==null;if(ql=0,ii=tr=dn=null,Gy=!1,Jg=0,em=null,m)throw Error(r(300));h===null||ai||(h=h.dependencies,h!==null&&Ly(h)&&(ai=!0))}function tI(h,m,_,M){dn=h;var j=0;do{if(Jf&&(em=null),Jg=0,Jf=!1,25<=j)throw Error(r(301));if(j+=1,ii=tr=null,h.updateQueue!=null){var L=h.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}Z.H=II,L=m(_,M)}while(Jf);return L}function dre(){var h=Z.H,m=h.useState()[0];return m=typeof m.then=="function"?ex(m):m,h=h.useState()[0],(tr!==null?tr.memoizedState:null)!==h&&(dn.flags|=1024),m}function PE(){var h=Wy!==0;return Wy=0,h}function RE(h,m,_){m.updateQueue=h.updateQueue,m.flags&=-2053,h.lanes&=~_}function DE(h){if(Gy){for(h=h.memoizedState;h!==null;){var m=h.queue;m!==null&&(m.pending=null),h=h.next}Gy=!1}ql=0,ii=tr=dn=null,Jf=!1,Jg=Wy=0,em=null}function ja(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ii===null?dn.memoizedState=ii=h:ii=ii.next=h,ii}function Qr(){if(tr===null){var h=dn.alternate;h=h!==null?h.memoizedState:null}else h=tr.next;var m=ii===null?dn.memoizedState:ii.next;if(m!==null)ii=m,tr=h;else{if(h===null)throw dn.alternate===null?Error(r(467)):Error(r(310));tr=h,h={memoizedState:tr.memoizedState,baseState:tr.baseState,baseQueue:tr.baseQueue,queue:tr.queue,next:null},ii===null?dn.memoizedState=ii=h:ii=ii.next=h}return ii}function qy(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ex(h){var m=Jg;return Jg+=1,em===null&&(em=[]),h=GL(em,h,m),m=dn,(ii===null?m.memoizedState:ii.next)===null&&(m=m.alternate,Z.H=m===null||m.memoizedState===null?LI:WE),h}function Ky(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return ex(h);if(h.$$typeof===w)return Ji(h)}throw Error(r(438,String(h)))}function OE(h){var m=null,_=dn.updateQueue;if(_!==null&&(m=_.memoCache),m==null){var M=dn.alternate;M!==null&&(M=M.updateQueue,M!==null&&(M=M.memoCache,M!=null&&(m={data:M.data.map(function(j){return j.slice()}),index:0})))}if(m==null&&(m={data:[],index:0}),_===null&&(_=qy(),dn.updateQueue=_),_.memoCache=m,_=m.data[m.index],_===void 0)for(_=m.data[m.index]=Array(h),M=0;M<h;M++)_[M]=R;return m.index++,_}function Kl(h,m){return typeof m=="function"?m(h):m}function Xy(h){var m=Qr();return LE(m,tr,h)}function LE(h,m,_){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=_;var j=h.baseQueue,L=M.pending;if(L!==null){if(j!==null){var Q=j.next;j.next=L.next,L.next=Q}m.baseQueue=j=L,M.pending=null}if(L=h.baseState,j===null)h.memoizedState=L;else{m=j.next;var me=Q=null,Ce=null,tt=m,ot=!1;do{var pt=tt.lane&-536870913;if(pt!==tt.lane?(Pn&pt)===pt:(ql&pt)===pt){var rt=tt.revertLane;if(rt===0)Ce!==null&&(Ce=Ce.next={lane:0,revertLane:0,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null}),pt===Kf&&(ot=!0);else if((ql&rt)===rt){tt=tt.next,rt===Kf&&(ot=!0);continue}else pt={lane:0,revertLane:tt.revertLane,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},Ce===null?(me=Ce=pt,Q=L):Ce=Ce.next=pt,dn.lanes|=rt,yu|=rt;pt=tt.action,sh&&_(L,pt),L=tt.hasEagerState?tt.eagerState:_(L,pt)}else rt={lane:pt,revertLane:tt.revertLane,gesture:tt.gesture,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},Ce===null?(me=Ce=rt,Q=L):Ce=Ce.next=rt,dn.lanes|=pt,yu|=pt;tt=tt.next}while(tt!==null&&tt!==m);if(Ce===null?Q=L:Ce.next=me,!gs(L,h.memoizedState)&&(ai=!0,ot&&(_=Xf,_!==null)))throw _;h.memoizedState=L,h.baseState=Q,h.baseQueue=Ce,M.lastRenderedState=L}return j===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function IE(h){var m=Qr(),_=m.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var M=_.dispatch,j=_.pending,L=m.memoizedState;if(j!==null){_.pending=null;var Q=j=j.next;do L=h(L,Q.action),Q=Q.next;while(Q!==j);gs(L,m.memoizedState)||(ai=!0),m.memoizedState=L,m.baseQueue===null&&(m.baseState=L),_.lastRenderedState=L}return[L,M]}function nI(h,m,_){var M=dn,j=Qr(),L=Dn;if(L){if(_===void 0)throw Error(r(407));_=_()}else _=m();var Q=!gs((tr||j).memoizedState,_);if(Q&&(j.memoizedState=_,ai=!0),j=j.queue,zE(aI.bind(null,M,j,h),[h]),j.getSnapshot!==m||Q||ii!==null&&ii.memoizedState.tag&1){if(M.flags|=2048,tm(9,{destroy:void 0},iI.bind(null,M,j,_,m),null),fr===null)throw Error(r(349));L||(ql&127)!==0||rI(M,m,_)}return _}function rI(h,m,_){h.flags|=16384,h={getSnapshot:m,value:_},m=dn.updateQueue,m===null?(m=qy(),dn.updateQueue=m,m.stores=[h]):(_=m.stores,_===null?m.stores=[h]:_.push(h))}function iI(h,m,_,M){m.value=_,m.getSnapshot=M,sI(m)&&oI(h)}function aI(h,m,_){return _(function(){sI(m)&&oI(h)})}function sI(h){var m=h.getSnapshot;h=h.value;try{var _=m();return!gs(h,_)}catch{return!0}}function oI(h){var m=Zd(h,2);m!==null&&Za(m,h,2)}function FE(h){var m=ja();if(typeof h=="function"){var _=h;if(h=_(),sh){Je(!0);try{_()}finally{Je(!1)}}}return m.memoizedState=m.baseState=h,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kl,lastRenderedState:h},m}function lI(h,m,_,M){return h.baseState=_,LE(h,tr,typeof M=="function"?M:Kl)}function hre(h,m,_,M,j){if(Qy(h))throw Error(r(485));if(h=m.action,h!==null){var L={payload:j,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Q){L.listeners.push(Q)}};Z.T!==null?_(!0):L.isTransition=!1,M(L),_=m.pending,_===null?(L.next=m.pending=L,cI(m,L)):(L.next=_.next,m.pending=_.next=L)}}function cI(h,m){var _=m.action,M=m.payload,j=h.state;if(m.isTransition){var L=Z.T,Q={};Z.T=Q;try{var me=_(j,M),Ce=Z.S;Ce!==null&&Ce(Q,me),uI(h,m,me)}catch(tt){UE(h,m,tt)}finally{L!==null&&Q.types!==null&&(L.types=Q.types),Z.T=L}}else try{L=_(j,M),uI(h,m,L)}catch(tt){UE(h,m,tt)}}function uI(h,m,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){dI(h,m,M)},function(M){return UE(h,m,M)}):dI(h,m,_)}function dI(h,m,_){m.status="fulfilled",m.value=_,hI(m),h.state=_,m=h.pending,m!==null&&(_=m.next,_===m?h.pending=null:(_=_.next,m.next=_,cI(h,_)))}function UE(h,m,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do m.status="rejected",m.reason=_,hI(m),m=m.next;while(m!==M)}h.action=null}function hI(h){h=h.listeners;for(var m=0;m<h.length;m++)(0,h[m])()}function fI(h,m){return m}function mI(h,m){if(Dn){var _=fr.formState;if(_!==null){e:{var M=dn;if(Dn){if(_r){t:{for(var j=_r,L=$s;j.nodeType!==8;){if(!L){j=null;break t}if(j=Gs(j.nextSibling),j===null){j=null;break t}}L=j.data,j=L==="F!"||L==="F"?j:null}if(j){_r=Gs(j.nextSibling),M=j.data==="F!";break e}}uu(M)}M=!1}M&&(m=_[0])}}return _=ja(),_.memoizedState=_.baseState=m,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fI,lastRenderedState:m},_.queue=M,_=RI.bind(null,dn,M),M.dispatch=_,M=FE(!1),L=GE.bind(null,dn,!1,M.queue),M=ja(),j={state:m,dispatch:null,action:h,pending:null},M.queue=j,_=hre.bind(null,dn,j,L,_),j.dispatch=_,M.memoizedState=h,[m,_,!1]}function pI(h){var m=Qr();return gI(m,tr,h)}function gI(h,m,_){if(m=LE(h,m,fI)[0],h=Xy(Kl)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var M=ex(m)}catch(Q){throw Q===Yf?Uy:Q}else M=m;m=Qr();var j=m.queue,L=j.dispatch;return _!==m.memoizedState&&(dn.flags|=2048,tm(9,{destroy:void 0},fre.bind(null,j,_),null)),[M,L,h]}function fre(h,m){h.action=m}function xI(h){var m=Qr(),_=tr;if(_!==null)return gI(m,_,h);Qr(),m=m.memoizedState,_=Qr();var M=_.queue.dispatch;return _.memoizedState=h,[m,M,!1]}function tm(h,m,_,M){return h={tag:h,create:_,deps:M,inst:m,next:null},m=dn.updateQueue,m===null&&(m=qy(),dn.updateQueue=m),_=m.lastEffect,_===null?m.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,m.lastEffect=h),h}function bI(){return Qr().memoizedState}function Yy(h,m,_,M){var j=ja();dn.flags|=h,j.memoizedState=tm(1|m,{destroy:void 0},_,M===void 0?null:M)}function Zy(h,m,_,M){var j=Qr();M=M===void 0?null:M;var L=j.memoizedState.inst;tr!==null&&M!==null&&kE(M,tr.memoizedState.deps)?j.memoizedState=tm(m,L,_,M):(dn.flags|=h,j.memoizedState=tm(1|m,L,_,M))}function yI(h,m){Yy(8390656,8,h,m)}function zE(h,m){Zy(2048,8,h,m)}function mre(h){dn.flags|=4;var m=dn.updateQueue;if(m===null)m=qy(),dn.updateQueue=m,m.events=[h];else{var _=m.events;_===null?m.events=[h]:_.push(h)}}function vI(h){var m=Qr().memoizedState;return mre({ref:m,nextImpl:h}),function(){if(($n&2)!==0)throw Error(r(440));return m.impl.apply(void 0,arguments)}}function _I(h,m){return Zy(4,2,h,m)}function wI(h,m){return Zy(4,4,h,m)}function SI(h,m){if(typeof m=="function"){h=h();var _=m(h);return function(){typeof _=="function"?_():m(null)}}if(m!=null)return h=h(),m.current=h,function(){m.current=null}}function MI(h,m,_){_=_!=null?_.concat([h]):null,Zy(4,4,SI.bind(null,m,h),_)}function BE(){}function EI(h,m){var _=Qr();m=m===void 0?null:m;var M=_.memoizedState;return m!==null&&kE(m,M[1])?M[0]:(_.memoizedState=[h,m],h)}function NI(h,m){var _=Qr();m=m===void 0?null:m;var M=_.memoizedState;if(m!==null&&kE(m,M[1]))return M[0];if(M=h(),sh){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[M,m],M}function HE(h,m,_){return _===void 0||(ql&1073741824)!==0&&(Pn&261930)===0?h.memoizedState=m:(h.memoizedState=_,h=A5(),dn.lanes|=h,yu|=h,_)}function AI(h,m,_,M){return gs(_,m)?_:Qf.current!==null?(h=HE(h,_,M),gs(h,m)||(ai=!0),h):(ql&42)===0||(ql&1073741824)!==0&&(Pn&261930)===0?(ai=!0,h.memoizedState=_):(h=A5(),dn.lanes|=h,yu|=h,m)}function TI(h,m,_,M,j){var L=G.p;G.p=L!==0&&8>L?L:8;var Q=Z.T,me={};Z.T=me,GE(h,!1,m,_);try{var Ce=j(),tt=Z.S;if(tt!==null&&tt(me,Ce),Ce!==null&&typeof Ce=="object"&&typeof Ce.then=="function"){var ot=cre(Ce,M);tx(h,m,ot,ws(h))}else tx(h,m,M,ws(h))}catch(pt){tx(h,m,{then:function(){},status:"rejected",reason:pt},ws())}finally{G.p=L,Q!==null&&me.types!==null&&(Q.types=me.types),Z.T=Q}}function pre(){}function $E(h,m,_,M){if(h.tag!==5)throw Error(r(476));var j=CI(h).queue;TI(h,j,m,Y,_===null?pre:function(){return kI(h),_(M)})}function CI(h){var m=h.memoizedState;if(m!==null)return m;m={memoizedState:Y,baseState:Y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kl,lastRenderedState:Y},next:null};var _={};return m.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kl,lastRenderedState:_},next:null},h.memoizedState=m,h=h.alternate,h!==null&&(h.memoizedState=m),m}function kI(h){var m=CI(h);m.next===null&&(m=h.alternate.memoizedState),tx(h,m.next.queue,{},ws())}function VE(){return Ji(bx)}function jI(){return Qr().memoizedState}function PI(){return Qr().memoizedState}function gre(h){for(var m=h.return;m!==null;){switch(m.tag){case 24:case 3:var _=ws();h=fu(_);var M=mu(m,h,_);M!==null&&(Za(M,m,_),Yg(M,m,_)),m={cache:yE()},h.payload=m;return}m=m.return}}function xre(h,m,_){var M=ws();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Qy(h)?DI(m,_):(_=lE(h,m,_,M),_!==null&&(Za(_,h,M),OI(_,m,M)))}function RI(h,m,_){var M=ws();tx(h,m,_,M)}function tx(h,m,_,M){var j={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(Qy(h))DI(m,j);else{var L=h.alternate;if(h.lanes===0&&(L===null||L.lanes===0)&&(L=m.lastRenderedReducer,L!==null))try{var Q=m.lastRenderedState,me=L(Q,_);if(j.hasEagerState=!0,j.eagerState=me,gs(me,Q))return Py(h,m,j,0),fr===null&&jy(),!1}catch{}finally{}if(_=lE(h,m,j,M),_!==null)return Za(_,h,M),OI(_,m,M),!0}return!1}function GE(h,m,_,M){if(M={lane:2,revertLane:SN(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Qy(h)){if(m)throw Error(r(479))}else m=lE(h,_,M,2),m!==null&&Za(m,h,2)}function Qy(h){var m=h.alternate;return h===dn||m!==null&&m===dn}function DI(h,m){Jf=Gy=!0;var _=h.pending;_===null?m.next=m:(m.next=_.next,_.next=m),h.pending=m}function OI(h,m,_){if((_&4194048)!==0){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,Fn(h,_)}}var nx={readContext:Ji,use:Ky,useCallback:Br,useContext:Br,useEffect:Br,useImperativeHandle:Br,useLayoutEffect:Br,useInsertionEffect:Br,useMemo:Br,useReducer:Br,useRef:Br,useState:Br,useDebugValue:Br,useDeferredValue:Br,useTransition:Br,useSyncExternalStore:Br,useId:Br,useHostTransitionStatus:Br,useFormState:Br,useActionState:Br,useOptimistic:Br,useMemoCache:Br,useCacheRefresh:Br};nx.useEffectEvent=Br;var LI={readContext:Ji,use:Ky,useCallback:function(h,m){return ja().memoizedState=[h,m===void 0?null:m],h},useContext:Ji,useEffect:yI,useImperativeHandle:function(h,m,_){_=_!=null?_.concat([h]):null,Yy(4194308,4,SI.bind(null,m,h),_)},useLayoutEffect:function(h,m){return Yy(4194308,4,h,m)},useInsertionEffect:function(h,m){Yy(4,2,h,m)},useMemo:function(h,m){var _=ja();m=m===void 0?null:m;var M=h();if(sh){Je(!0);try{h()}finally{Je(!1)}}return _.memoizedState=[M,m],M},useReducer:function(h,m,_){var M=ja();if(_!==void 0){var j=_(m);if(sh){Je(!0);try{_(m)}finally{Je(!1)}}}else j=m;return M.memoizedState=M.baseState=j,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:j},M.queue=h,h=h.dispatch=xre.bind(null,dn,h),[M.memoizedState,h]},useRef:function(h){var m=ja();return h={current:h},m.memoizedState=h},useState:function(h){h=FE(h);var m=h.queue,_=RI.bind(null,dn,m);return m.dispatch=_,[h.memoizedState,_]},useDebugValue:BE,useDeferredValue:function(h,m){var _=ja();return HE(_,h,m)},useTransition:function(){var h=FE(!1);return h=TI.bind(null,dn,h.queue,!0,!1),ja().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,m,_){var M=dn,j=ja();if(Dn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=m(),fr===null)throw Error(r(349));(Pn&127)!==0||rI(M,m,_)}j.memoizedState=_;var L={value:_,getSnapshot:m};return j.queue=L,yI(aI.bind(null,M,L,h),[h]),M.flags|=2048,tm(9,{destroy:void 0},iI.bind(null,M,L,_,m),null),_},useId:function(){var h=ja(),m=fr.identifierPrefix;if(Dn){var _=nl,M=tl;_=(M&~(1<<32-qe(M)-1)).toString(32)+_,m="_"+m+"R_"+_,_=Wy++,0<_&&(m+="H"+_.toString(32)),m+="_"}else _=ure++,m="_"+m+"r_"+_.toString(32)+"_";return h.memoizedState=m},useHostTransitionStatus:VE,useFormState:mI,useActionState:mI,useOptimistic:function(h){var m=ja();m.memoizedState=m.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=_,m=GE.bind(null,dn,!0,_),_.dispatch=m,[h,m]},useMemoCache:OE,useCacheRefresh:function(){return ja().memoizedState=gre.bind(null,dn)},useEffectEvent:function(h){var m=ja(),_={impl:h};return m.memoizedState=_,function(){if(($n&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},WE={readContext:Ji,use:Ky,useCallback:EI,useContext:Ji,useEffect:zE,useImperativeHandle:MI,useInsertionEffect:_I,useLayoutEffect:wI,useMemo:NI,useReducer:Xy,useRef:bI,useState:function(){return Xy(Kl)},useDebugValue:BE,useDeferredValue:function(h,m){var _=Qr();return AI(_,tr.memoizedState,h,m)},useTransition:function(){var h=Xy(Kl)[0],m=Qr().memoizedState;return[typeof h=="boolean"?h:ex(h),m]},useSyncExternalStore:nI,useId:jI,useHostTransitionStatus:VE,useFormState:pI,useActionState:pI,useOptimistic:function(h,m){var _=Qr();return lI(_,tr,h,m)},useMemoCache:OE,useCacheRefresh:PI};WE.useEffectEvent=vI;var II={readContext:Ji,use:Ky,useCallback:EI,useContext:Ji,useEffect:zE,useImperativeHandle:MI,useInsertionEffect:_I,useLayoutEffect:wI,useMemo:NI,useReducer:IE,useRef:bI,useState:function(){return IE(Kl)},useDebugValue:BE,useDeferredValue:function(h,m){var _=Qr();return tr===null?HE(_,h,m):AI(_,tr.memoizedState,h,m)},useTransition:function(){var h=IE(Kl)[0],m=Qr().memoizedState;return[typeof h=="boolean"?h:ex(h),m]},useSyncExternalStore:nI,useId:jI,useHostTransitionStatus:VE,useFormState:xI,useActionState:xI,useOptimistic:function(h,m){var _=Qr();return tr!==null?lI(_,tr,h,m):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:OE,useCacheRefresh:PI};II.useEffectEvent=vI;function qE(h,m,_,M){m=h.memoizedState,_=_(M,m),_=_==null?m:f({},m,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var KE={enqueueSetState:function(h,m,_){h=h._reactInternals;var M=ws(),j=fu(M);j.payload=m,_!=null&&(j.callback=_),m=mu(h,j,M),m!==null&&(Za(m,h,M),Yg(m,h,M))},enqueueReplaceState:function(h,m,_){h=h._reactInternals;var M=ws(),j=fu(M);j.tag=1,j.payload=m,_!=null&&(j.callback=_),m=mu(h,j,M),m!==null&&(Za(m,h,M),Yg(m,h,M))},enqueueForceUpdate:function(h,m){h=h._reactInternals;var _=ws(),M=fu(_);M.tag=2,m!=null&&(M.callback=m),m=mu(h,M,_),m!==null&&(Za(m,h,_),Yg(m,h,_))}};function FI(h,m,_,M,j,L,Q){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,L,Q):m.prototype&&m.prototype.isPureReactComponent?!Hg(_,M)||!Hg(j,L):!0}function UI(h,m,_,M){h=m.state,typeof m.componentWillReceiveProps=="function"&&m.componentWillReceiveProps(_,M),typeof m.UNSAFE_componentWillReceiveProps=="function"&&m.UNSAFE_componentWillReceiveProps(_,M),m.state!==h&&KE.enqueueReplaceState(m,m.state,null)}function oh(h,m){var _=m;if("ref"in m){_={};for(var M in m)M!=="ref"&&(_[M]=m[M])}if(h=h.defaultProps){_===m&&(_=f({},_));for(var j in h)_[j]===void 0&&(_[j]=h[j])}return _}function zI(h){ky(h)}function BI(h){console.error(h)}function HI(h){ky(h)}function Jy(h,m){try{var _=h.onUncaughtError;_(m.value,{componentStack:m.stack})}catch(M){setTimeout(function(){throw M})}}function $I(h,m,_){try{var M=h.onCaughtError;M(_.value,{componentStack:_.stack,errorBoundary:m.tag===1?m.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function XE(h,m,_){return _=fu(_),_.tag=3,_.payload={element:null},_.callback=function(){Jy(h,m)},_}function VI(h){return h=fu(h),h.tag=3,h}function GI(h,m,_,M){var j=_.type.getDerivedStateFromError;if(typeof j=="function"){var L=M.value;h.payload=function(){return j(L)},h.callback=function(){$I(m,_,M)}}var Q=_.stateNode;Q!==null&&typeof Q.componentDidCatch=="function"&&(h.callback=function(){$I(m,_,M),typeof j!="function"&&(vu===null?vu=new Set([this]):vu.add(this));var me=M.stack;this.componentDidCatch(M.value,{componentStack:me!==null?me:""})})}function bre(h,m,_,M,j){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(m=_.alternate,m!==null&&qf(m,_,j,!0),_=bs.current,_!==null){switch(_.tag){case 31:case 13:return Vs===null?dv():_.alternate===null&&Hr===0&&(Hr=3),_.flags&=-257,_.flags|=65536,_.lanes=j,M===zy?_.flags|=16384:(m=_.updateQueue,m===null?_.updateQueue=new Set([M]):m.add(M),vN(h,M,j)),!1;case 22:return _.flags|=65536,M===zy?_.flags|=16384:(m=_.updateQueue,m===null?(m={transitions:null,markerInstances:null,retryQueue:new Set([M])},_.updateQueue=m):(_=m.retryQueue,_===null?m.retryQueue=new Set([M]):_.add(M)),vN(h,M,j)),!1}throw Error(r(435,_.tag))}return vN(h,M,j),dv(),!1}if(Dn)return m=bs.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=j,M!==mE&&(h=Error(r(422),{cause:M}),Gg(zs(h,_)))):(M!==mE&&(m=Error(r(423),{cause:M}),Gg(zs(m,_))),h=h.current.alternate,h.flags|=65536,j&=-j,h.lanes|=j,M=zs(M,_),j=XE(h.stateNode,M,j),EE(h,j),Hr!==4&&(Hr=2)),!1;var L=Error(r(520),{cause:M});if(L=zs(L,_),ux===null?ux=[L]:ux.push(L),Hr!==4&&(Hr=2),m===null)return!0;M=zs(M,_),_=m;do{switch(_.tag){case 3:return _.flags|=65536,h=j&-j,_.lanes|=h,h=XE(_.stateNode,M,h),EE(_,h),!1;case 1:if(m=_.type,L=_.stateNode,(_.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(vu===null||!vu.has(L))))return _.flags|=65536,j&=-j,_.lanes|=j,j=VI(j),GI(j,h,_,M),EE(_,j),!1}_=_.return}while(_!==null);return!1}var YE=Error(r(461)),ai=!1;function ea(h,m,_,M){m.child=h===null?XL(m,null,_,M):ah(m,h.child,_,M)}function WI(h,m,_,M,j){_=_.render;var L=m.ref;if("ref"in M){var Q={};for(var me in M)me!=="ref"&&(Q[me]=M[me])}else Q=M;return th(m),M=jE(h,m,_,Q,L,j),me=PE(),h!==null&&!ai?(RE(h,m,j),Xl(h,m,j)):(Dn&&me&&hE(m),m.flags|=1,ea(h,m,M,j),m.child)}function qI(h,m,_,M,j){if(h===null){var L=_.type;return typeof L=="function"&&!cE(L)&&L.defaultProps===void 0&&_.compare===null?(m.tag=15,m.type=L,KI(h,m,L,M,j)):(h=Dy(_.type,null,M,m,m.mode,j),h.ref=m.ref,h.return=m,m.child=h)}if(L=h.child,!iN(h,j)){var Q=L.memoizedProps;if(_=_.compare,_=_!==null?_:Hg,_(Q,M)&&h.ref===m.ref)return Xl(h,m,j)}return m.flags|=1,h=$l(L,M),h.ref=m.ref,h.return=m,m.child=h}function KI(h,m,_,M,j){if(h!==null){var L=h.memoizedProps;if(Hg(L,M)&&h.ref===m.ref)if(ai=!1,m.pendingProps=M=L,iN(h,j))(h.flags&131072)!==0&&(ai=!0);else return m.lanes=h.lanes,Xl(h,m,j)}return ZE(h,m,_,M,j)}function XI(h,m,_,M){var j=M.children,L=h!==null?h.memoizedState:null;if(h===null&&m.stateNode===null&&(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((m.flags&128)!==0){if(L=L!==null?L.baseLanes|_:_,h!==null){for(M=m.child=h.child,j=0;M!==null;)j=j|M.lanes|M.childLanes,M=M.sibling;M=j&~L}else M=0,m.child=null;return YI(h,m,L,_,M)}if((_&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},h!==null&&Fy(m,L!==null?L.cachePool:null),L!==null?QL(m,L):AE(),JL(m);else return M=m.lanes=536870912,YI(h,m,L!==null?L.baseLanes|_:_,_,M)}else L!==null?(Fy(m,L.cachePool),QL(m,L),gu(),m.memoizedState=null):(h!==null&&Fy(m,null),AE(),gu());return ea(h,m,j,_),m.child}function rx(h,m){return h!==null&&h.tag===22||m.stateNode!==null||(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.sibling}function YI(h,m,_,M,j){var L=_E();return L=L===null?null:{parent:ri._currentValue,pool:L},m.memoizedState={baseLanes:_,cachePool:L},h!==null&&Fy(m,null),AE(),JL(m),h!==null&&qf(h,m,M,!0),m.childLanes=j,null}function ev(h,m){return m=nv({mode:m.mode,children:m.children},h.mode),m.ref=h.ref,h.child=m,m.return=h,m}function ZI(h,m,_){return ah(m,h.child,null,_),h=ev(m,m.pendingProps),h.flags|=2,ys(m),m.memoizedState=null,h}function yre(h,m,_){var M=m.pendingProps,j=(m.flags&128)!==0;if(m.flags&=-129,h===null){if(Dn){if(M.mode==="hidden")return h=ev(m,M),m.lanes=536870912,rx(null,h);if(CE(m),(h=_r)?(h=cF(h,$s),h=h!==null&&h.data==="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:lu!==null?{id:tl,overflow:nl}:null,retryLane:536870912,hydrationErrors:null},_=DL(h),_.return=m,m.child=_,Qi=m,_r=null)):h=null,h===null)throw uu(m);return m.lanes=536870912,null}return ev(m,M)}var L=h.memoizedState;if(L!==null){var Q=L.dehydrated;if(CE(m),j)if(m.flags&256)m.flags&=-257,m=ZI(h,m,_);else if(m.memoizedState!==null)m.child=h.child,m.flags|=128,m=null;else throw Error(r(558));else if(ai||qf(h,m,_,!1),j=(_&h.childLanes)!==0,ai||j){if(M=fr,M!==null&&(Q=Sn(M,_),Q!==0&&Q!==L.retryLane))throw L.retryLane=Q,Zd(h,Q),Za(M,h,Q),YE;dv(),m=ZI(h,m,_)}else h=L.treeContext,_r=Gs(Q.nextSibling),Qi=m,Dn=!0,cu=null,$s=!1,h!==null&&IL(m,h),m=ev(m,M),m.flags|=4096;return m}return h=$l(h.child,{mode:M.mode,children:M.children}),h.ref=m.ref,m.child=h,h.return=m,h}function tv(h,m){var _=m.ref;if(_===null)h!==null&&h.ref!==null&&(m.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(m.flags|=4194816)}}function ZE(h,m,_,M,j){return th(m),_=jE(h,m,_,M,void 0,j),M=PE(),h!==null&&!ai?(RE(h,m,j),Xl(h,m,j)):(Dn&&M&&hE(m),m.flags|=1,ea(h,m,_,j),m.child)}function QI(h,m,_,M,j,L){return th(m),m.updateQueue=null,_=tI(m,M,_,j),eI(h),M=PE(),h!==null&&!ai?(RE(h,m,L),Xl(h,m,L)):(Dn&&M&&hE(m),m.flags|=1,ea(h,m,_,L),m.child)}function JI(h,m,_,M,j){if(th(m),m.stateNode===null){var L=$f,Q=_.contextType;typeof Q=="object"&&Q!==null&&(L=Ji(Q)),L=new _(M,L),m.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=KE,m.stateNode=L,L._reactInternals=m,L=m.stateNode,L.props=M,L.state=m.memoizedState,L.refs={},SE(m),Q=_.contextType,L.context=typeof Q=="object"&&Q!==null?Ji(Q):$f,L.state=m.memoizedState,Q=_.getDerivedStateFromProps,typeof Q=="function"&&(qE(m,_,Q,M),L.state=m.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(Q=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),Q!==L.state&&KE.enqueueReplaceState(L,L.state,null),Qg(m,M,L,j),Zg(),L.state=m.memoizedState),typeof L.componentDidMount=="function"&&(m.flags|=4194308),M=!0}else if(h===null){L=m.stateNode;var me=m.memoizedProps,Ce=oh(_,me);L.props=Ce;var tt=L.context,ot=_.contextType;Q=$f,typeof ot=="object"&&ot!==null&&(Q=Ji(ot));var pt=_.getDerivedStateFromProps;ot=typeof pt=="function"||typeof L.getSnapshotBeforeUpdate=="function",me=m.pendingProps!==me,ot||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(me||tt!==Q)&&UI(m,L,M,Q),hu=!1;var rt=m.memoizedState;L.state=rt,Qg(m,M,L,j),Zg(),tt=m.memoizedState,me||rt!==tt||hu?(typeof pt=="function"&&(qE(m,_,pt,M),tt=m.memoizedState),(Ce=hu||FI(m,_,Ce,M,rt,tt,Q))?(ot||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(m.flags|=4194308)):(typeof L.componentDidMount=="function"&&(m.flags|=4194308),m.memoizedProps=M,m.memoizedState=tt),L.props=M,L.state=tt,L.context=Q,M=Ce):(typeof L.componentDidMount=="function"&&(m.flags|=4194308),M=!1)}else{L=m.stateNode,ME(h,m),Q=m.memoizedProps,ot=oh(_,Q),L.props=ot,pt=m.pendingProps,rt=L.context,tt=_.contextType,Ce=$f,typeof tt=="object"&&tt!==null&&(Ce=Ji(tt)),me=_.getDerivedStateFromProps,(tt=typeof me=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(Q!==pt||rt!==Ce)&&UI(m,L,M,Ce),hu=!1,rt=m.memoizedState,L.state=rt,Qg(m,M,L,j),Zg();var st=m.memoizedState;Q!==pt||rt!==st||hu||h!==null&&h.dependencies!==null&&Ly(h.dependencies)?(typeof me=="function"&&(qE(m,_,me,M),st=m.memoizedState),(ot=hu||FI(m,_,ot,M,rt,st,Ce)||h!==null&&h.dependencies!==null&&Ly(h.dependencies))?(tt||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(M,st,Ce),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(M,st,Ce)),typeof L.componentDidUpdate=="function"&&(m.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof L.componentDidUpdate!="function"||Q===h.memoizedProps&&rt===h.memoizedState||(m.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||Q===h.memoizedProps&&rt===h.memoizedState||(m.flags|=1024),m.memoizedProps=M,m.memoizedState=st),L.props=M,L.state=st,L.context=Ce,M=ot):(typeof L.componentDidUpdate!="function"||Q===h.memoizedProps&&rt===h.memoizedState||(m.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||Q===h.memoizedProps&&rt===h.memoizedState||(m.flags|=1024),M=!1)}return L=M,tv(h,m),M=(m.flags&128)!==0,L||M?(L=m.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:L.render(),m.flags|=1,h!==null&&M?(m.child=ah(m,h.child,null,j),m.child=ah(m,null,_,j)):ea(h,m,_,j),m.memoizedState=L.state,h=m.child):h=Xl(h,m,j),h}function e5(h,m,_,M){return Jd(),m.flags|=256,ea(h,m,_,M),m.child}var QE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function JE(h){return{baseLanes:h,cachePool:$L()}}function eN(h,m,_){return h=h!==null?h.childLanes&~_:0,m&&(h|=_s),h}function t5(h,m,_){var M=m.pendingProps,j=!1,L=(m.flags&128)!==0,Q;if((Q=L)||(Q=h!==null&&h.memoizedState===null?!1:(Zr.current&2)!==0),Q&&(j=!0,m.flags&=-129),Q=(m.flags&32)!==0,m.flags&=-33,h===null){if(Dn){if(j?pu(m):gu(),(h=_r)?(h=cF(h,$s),h=h!==null&&h.data!=="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:lu!==null?{id:tl,overflow:nl}:null,retryLane:536870912,hydrationErrors:null},_=DL(h),_.return=m,m.child=_,Qi=m,_r=null)):h=null,h===null)throw uu(m);return LN(h)?m.lanes=32:m.lanes=536870912,null}var me=M.children;return M=M.fallback,j?(gu(),j=m.mode,me=nv({mode:"hidden",children:me},j),M=Qd(M,j,_,null),me.return=m,M.return=m,me.sibling=M,m.child=me,M=m.child,M.memoizedState=JE(_),M.childLanes=eN(h,Q,_),m.memoizedState=QE,rx(null,M)):(pu(m),tN(m,me))}var Ce=h.memoizedState;if(Ce!==null&&(me=Ce.dehydrated,me!==null)){if(L)m.flags&256?(pu(m),m.flags&=-257,m=nN(h,m,_)):m.memoizedState!==null?(gu(),m.child=h.child,m.flags|=128,m=null):(gu(),me=M.fallback,j=m.mode,M=nv({mode:"visible",children:M.children},j),me=Qd(me,j,_,null),me.flags|=2,M.return=m,me.return=m,M.sibling=me,m.child=M,ah(m,h.child,null,_),M=m.child,M.memoizedState=JE(_),M.childLanes=eN(h,Q,_),m.memoizedState=QE,m=rx(null,M));else if(pu(m),LN(me)){if(Q=me.nextSibling&&me.nextSibling.dataset,Q)var tt=Q.dgst;Q=tt,M=Error(r(419)),M.stack="",M.digest=Q,Gg({value:M,source:null,stack:null}),m=nN(h,m,_)}else if(ai||qf(h,m,_,!1),Q=(_&h.childLanes)!==0,ai||Q){if(Q=fr,Q!==null&&(M=Sn(Q,_),M!==0&&M!==Ce.retryLane))throw Ce.retryLane=M,Zd(h,M),Za(Q,h,M),YE;ON(me)||dv(),m=nN(h,m,_)}else ON(me)?(m.flags|=192,m.child=h.child,m=null):(h=Ce.treeContext,_r=Gs(me.nextSibling),Qi=m,Dn=!0,cu=null,$s=!1,h!==null&&IL(m,h),m=tN(m,M.children),m.flags|=4096);return m}return j?(gu(),me=M.fallback,j=m.mode,Ce=h.child,tt=Ce.sibling,M=$l(Ce,{mode:"hidden",children:M.children}),M.subtreeFlags=Ce.subtreeFlags&65011712,tt!==null?me=$l(tt,me):(me=Qd(me,j,_,null),me.flags|=2),me.return=m,M.return=m,M.sibling=me,m.child=M,rx(null,M),M=m.child,me=h.child.memoizedState,me===null?me=JE(_):(j=me.cachePool,j!==null?(Ce=ri._currentValue,j=j.parent!==Ce?{parent:Ce,pool:Ce}:j):j=$L(),me={baseLanes:me.baseLanes|_,cachePool:j}),M.memoizedState=me,M.childLanes=eN(h,Q,_),m.memoizedState=QE,rx(h.child,M)):(pu(m),_=h.child,h=_.sibling,_=$l(_,{mode:"visible",children:M.children}),_.return=m,_.sibling=null,h!==null&&(Q=m.deletions,Q===null?(m.deletions=[h],m.flags|=16):Q.push(h)),m.child=_,m.memoizedState=null,_)}function tN(h,m){return m=nv({mode:"visible",children:m},h.mode),m.return=h,h.child=m}function nv(h,m){return h=xs(22,h,null,m),h.lanes=0,h}function nN(h,m,_){return ah(m,h.child,null,_),h=tN(m,m.pendingProps.children),h.flags|=2,m.memoizedState=null,h}function n5(h,m,_){h.lanes|=m;var M=h.alternate;M!==null&&(M.lanes|=m),xE(h.return,m,_)}function rN(h,m,_,M,j,L){var Q=h.memoizedState;Q===null?h.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:j,treeForkCount:L}:(Q.isBackwards=m,Q.rendering=null,Q.renderingStartTime=0,Q.last=M,Q.tail=_,Q.tailMode=j,Q.treeForkCount=L)}function r5(h,m,_){var M=m.pendingProps,j=M.revealOrder,L=M.tail;M=M.children;var Q=Zr.current,me=(Q&2)!==0;if(me?(Q=Q&1|2,m.flags|=128):Q&=1,te(Zr,Q),ea(h,m,M,_),M=Dn?Vg:0,!me&&h!==null&&(h.flags&128)!==0)e:for(h=m.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&n5(h,_,m);else if(h.tag===19)n5(h,_,m);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===m)break e;for(;h.sibling===null;){if(h.return===null||h.return===m)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(j){case"forwards":for(_=m.child,j=null;_!==null;)h=_.alternate,h!==null&&Vy(h)===null&&(j=_),_=_.sibling;_=j,_===null?(j=m.child,m.child=null):(j=_.sibling,_.sibling=null),rN(m,!1,j,_,L,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,j=m.child,m.child=null;j!==null;){if(h=j.alternate,h!==null&&Vy(h)===null){m.child=j;break}h=j.sibling,j.sibling=_,_=j,j=h}rN(m,!0,_,null,L,M);break;case"together":rN(m,!1,null,null,void 0,M);break;default:m.memoizedState=null}return m.child}function Xl(h,m,_){if(h!==null&&(m.dependencies=h.dependencies),yu|=m.lanes,(_&m.childLanes)===0)if(h!==null){if(qf(h,m,_,!1),(_&m.childLanes)===0)return null}else return null;if(h!==null&&m.child!==h.child)throw Error(r(153));if(m.child!==null){for(h=m.child,_=$l(h,h.pendingProps),m.child=_,_.return=m;h.sibling!==null;)h=h.sibling,_=_.sibling=$l(h,h.pendingProps),_.return=m;_.sibling=null}return m.child}function iN(h,m){return(h.lanes&m)!==0?!0:(h=h.dependencies,!!(h!==null&&Ly(h)))}function vre(h,m,_){switch(m.tag){case 3:ce(m,m.stateNode.containerInfo),du(m,ri,h.memoizedState.cache),Jd();break;case 27:case 5:pe(m);break;case 4:ce(m,m.stateNode.containerInfo);break;case 10:du(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,CE(m),null;break;case 13:var M=m.memoizedState;if(M!==null)return M.dehydrated!==null?(pu(m),m.flags|=128,null):(_&m.child.childLanes)!==0?t5(h,m,_):(pu(m),h=Xl(h,m,_),h!==null?h.sibling:null);pu(m);break;case 19:var j=(h.flags&128)!==0;if(M=(_&m.childLanes)!==0,M||(qf(h,m,_,!1),M=(_&m.childLanes)!==0),j){if(M)return r5(h,m,_);m.flags|=128}if(j=m.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),te(Zr,Zr.current),M)break;return null;case 22:return m.lanes=0,XI(h,m,_,m.pendingProps);case 24:du(m,ri,h.memoizedState.cache)}return Xl(h,m,_)}function i5(h,m,_){if(h!==null)if(h.memoizedProps!==m.pendingProps)ai=!0;else{if(!iN(h,_)&&(m.flags&128)===0)return ai=!1,vre(h,m,_);ai=(h.flags&131072)!==0}else ai=!1,Dn&&(m.flags&1048576)!==0&&LL(m,Vg,m.index);switch(m.lanes=0,m.tag){case 16:e:{var M=m.pendingProps;if(h=rh(m.elementType),m.type=h,typeof h=="function")cE(h)?(M=oh(h,M),m.tag=1,m=JI(null,m,h,M,_)):(m.tag=0,m=ZE(null,m,h,M,_));else{if(h!=null){var j=h.$$typeof;if(j===A){m.tag=11,m=WI(null,m,h,M,_);break e}else if(j===T){m.tag=14,m=qI(null,m,h,M,_);break e}}throw m=P(h)||h,Error(r(306,m,""))}}return m;case 0:return ZE(h,m,m.type,m.pendingProps,_);case 1:return M=m.type,j=oh(M,m.pendingProps),JI(h,m,M,j,_);case 3:e:{if(ce(m,m.stateNode.containerInfo),h===null)throw Error(r(387));M=m.pendingProps;var L=m.memoizedState;j=L.element,ME(h,m),Qg(m,M,null,_);var Q=m.memoizedState;if(M=Q.cache,du(m,ri,M),M!==L.cache&&bE(m,[ri],_,!0),Zg(),M=Q.element,L.isDehydrated)if(L={element:M,isDehydrated:!1,cache:Q.cache},m.updateQueue.baseState=L,m.memoizedState=L,m.flags&256){m=e5(h,m,M,_);break e}else if(M!==j){j=zs(Error(r(424)),m),Gg(j),m=e5(h,m,M,_);break e}else{switch(h=m.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(_r=Gs(h.firstChild),Qi=m,Dn=!0,cu=null,$s=!0,_=XL(m,null,M,_),m.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(Jd(),M===j){m=Xl(h,m,_);break e}ea(h,m,M,_)}m=m.child}return m;case 26:return tv(h,m),h===null?(_=pF(m.type,null,m.pendingProps,null))?m.memoizedState=_:Dn||(_=m.type,h=m.pendingProps,M=bv(he.current).createElement(_),M[$t]=m,M[cn]=h,ta(M,_,h),De(M),m.stateNode=M):m.memoizedState=pF(m.type,h.memoizedProps,m.pendingProps,h.memoizedState),null;case 27:return pe(m),h===null&&Dn&&(M=m.stateNode=hF(m.type,m.pendingProps,he.current),Qi=m,$s=!0,j=_r,Mu(m.type)?(IN=j,_r=Gs(M.firstChild)):_r=j),ea(h,m,m.pendingProps.children,_),tv(h,m),h===null&&(m.flags|=4194304),m.child;case 5:return h===null&&Dn&&((j=M=_r)&&(M=Yre(M,m.type,m.pendingProps,$s),M!==null?(m.stateNode=M,Qi=m,_r=Gs(M.firstChild),$s=!1,j=!0):j=!1),j||uu(m)),pe(m),j=m.type,L=m.pendingProps,Q=h!==null?h.memoizedProps:null,M=L.children,PN(j,L)?M=null:Q!==null&&PN(j,Q)&&(m.flags|=32),m.memoizedState!==null&&(j=jE(h,m,dre,null,null,_),bx._currentValue=j),tv(h,m),ea(h,m,M,_),m.child;case 6:return h===null&&Dn&&((h=_=_r)&&(_=Zre(_,m.pendingProps,$s),_!==null?(m.stateNode=_,Qi=m,_r=null,h=!0):h=!1),h||uu(m)),null;case 13:return t5(h,m,_);case 4:return ce(m,m.stateNode.containerInfo),M=m.pendingProps,h===null?m.child=ah(m,null,M,_):ea(h,m,M,_),m.child;case 11:return WI(h,m,m.type,m.pendingProps,_);case 7:return ea(h,m,m.pendingProps,_),m.child;case 8:return ea(h,m,m.pendingProps.children,_),m.child;case 12:return ea(h,m,m.pendingProps.children,_),m.child;case 10:return M=m.pendingProps,du(m,m.type,M.value),ea(h,m,M.children,_),m.child;case 9:return j=m.type._context,M=m.pendingProps.children,th(m),j=Ji(j),M=M(j),m.flags|=1,ea(h,m,M,_),m.child;case 14:return qI(h,m,m.type,m.pendingProps,_);case 15:return KI(h,m,m.type,m.pendingProps,_);case 19:return r5(h,m,_);case 31:return yre(h,m,_);case 22:return XI(h,m,_,m.pendingProps);case 24:return th(m),M=Ji(ri),h===null?(j=_E(),j===null&&(j=fr,L=yE(),j.pooledCache=L,L.refCount++,L!==null&&(j.pooledCacheLanes|=_),j=L),m.memoizedState={parent:M,cache:j},SE(m),du(m,ri,j)):((h.lanes&_)!==0&&(ME(h,m),Qg(m,null,null,_),Zg()),j=h.memoizedState,L=m.memoizedState,j.parent!==M?(j={parent:M,cache:M},m.memoizedState=j,m.lanes===0&&(m.memoizedState=m.updateQueue.baseState=j),du(m,ri,M)):(M=L.cache,du(m,ri,M),M!==j.cache&&bE(m,[ri],_,!0))),ea(h,m,m.pendingProps.children,_),m.child;case 29:throw m.pendingProps}throw Error(r(156,m.tag))}function Yl(h){h.flags|=4}function aN(h,m,_,M,j){if((m=(h.mode&32)!==0)&&(m=!1),m){if(h.flags|=16777216,(j&335544128)===j)if(h.stateNode.complete)h.flags|=8192;else if(j5())h.flags|=8192;else throw ih=zy,wE}else h.flags&=-16777217}function a5(h,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!vF(m))if(j5())h.flags|=8192;else throw ih=zy,wE}function rv(h,m){m!==null&&(h.flags|=4),h.flags&16384&&(m=h.tag!==22?At():536870912,h.lanes|=m,am|=m)}function ix(h,m){if(!Dn)switch(h.tailMode){case"hidden":m=h.tail;for(var _=null;m!==null;)m.alternate!==null&&(_=m),m=m.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var M=null;_!==null;)_.alternate!==null&&(M=_),_=_.sibling;M===null?m||h.tail===null?h.tail=null:h.tail.sibling=null:M.sibling=null}}function wr(h){var m=h.alternate!==null&&h.alternate.child===h.child,_=0,M=0;if(m)for(var j=h.child;j!==null;)_|=j.lanes|j.childLanes,M|=j.subtreeFlags&65011712,M|=j.flags&65011712,j.return=h,j=j.sibling;else for(j=h.child;j!==null;)_|=j.lanes|j.childLanes,M|=j.subtreeFlags,M|=j.flags,j.return=h,j=j.sibling;return h.subtreeFlags|=M,h.childLanes=_,m}function _re(h,m,_){var M=m.pendingProps;switch(fE(m),m.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wr(m),null;case 1:return wr(m),null;case 3:return _=m.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),m.memoizedState.cache!==M&&(m.flags|=2048),Wl(ri),fe(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Wf(m)?Yl(m):h===null||h.memoizedState.isDehydrated&&(m.flags&256)===0||(m.flags|=1024,pE())),wr(m),null;case 26:var j=m.type,L=m.memoizedState;return h===null?(Yl(m),L!==null?(wr(m),a5(m,L)):(wr(m),aN(m,j,null,M,_))):L?L!==h.memoizedState?(Yl(m),wr(m),a5(m,L)):(wr(m),m.flags&=-16777217):(h=h.memoizedProps,h!==M&&Yl(m),wr(m),aN(m,j,h,M,_)),null;case 27:if(_e(m),_=he.current,j=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&Yl(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return wr(m),null}h=re.current,Wf(m)?FL(m):(h=hF(j,M,_),m.stateNode=h,Yl(m))}return wr(m),null;case 5:if(_e(m),j=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&Yl(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return wr(m),null}if(L=re.current,Wf(m))FL(m);else{var Q=bv(he.current);switch(L){case 1:L=Q.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:L=Q.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":L=Q.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":L=Q.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":L=Q.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof M.is=="string"?Q.createElement("select",{is:M.is}):Q.createElement("select"),M.multiple?L.multiple=!0:M.size&&(L.size=M.size);break;default:L=typeof M.is=="string"?Q.createElement(j,{is:M.is}):Q.createElement(j)}}L[$t]=m,L[cn]=M;e:for(Q=m.child;Q!==null;){if(Q.tag===5||Q.tag===6)L.appendChild(Q.stateNode);else if(Q.tag!==4&&Q.tag!==27&&Q.child!==null){Q.child.return=Q,Q=Q.child;continue}if(Q===m)break e;for(;Q.sibling===null;){if(Q.return===null||Q.return===m)break e;Q=Q.return}Q.sibling.return=Q.return,Q=Q.sibling}m.stateNode=L;e:switch(ta(L,j,M),j){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}M&&Yl(m)}}return wr(m),aN(m,m.type,h===null?null:h.memoizedProps,m.pendingProps,_),null;case 6:if(h&&m.stateNode!=null)h.memoizedProps!==M&&Yl(m);else{if(typeof M!="string"&&m.stateNode===null)throw Error(r(166));if(h=he.current,Wf(m)){if(h=m.stateNode,_=m.memoizedProps,M=null,j=Qi,j!==null)switch(j.tag){case 27:case 5:M=j.memoizedProps}h[$t]=m,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||tF(h.nodeValue,_)),h||uu(m,!0)}else h=bv(h).createTextNode(M),h[$t]=m,m.stateNode=h}return wr(m),null;case 31:if(_=m.memoizedState,h===null||h.memoizedState!==null){if(M=Wf(m),_!==null){if(h===null){if(!M)throw Error(r(318));if(h=m.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[$t]=m}else Jd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),h=!1}else _=pE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return m.flags&256?(ys(m),m):(ys(m),null);if((m.flags&128)!==0)throw Error(r(558))}return wr(m),null;case 13:if(M=m.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(j=Wf(m),M!==null&&M.dehydrated!==null){if(h===null){if(!j)throw Error(r(318));if(j=m.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[$t]=m}else Jd(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),j=!1}else j=pE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=j),j=!0;if(!j)return m.flags&256?(ys(m),m):(ys(m),null)}return ys(m),(m.flags&128)!==0?(m.lanes=_,m):(_=M!==null,h=h!==null&&h.memoizedState!==null,_&&(M=m.child,j=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(j=M.alternate.memoizedState.cachePool.pool),L=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(L=M.memoizedState.cachePool.pool),L!==j&&(M.flags|=2048)),_!==h&&_&&(m.child.flags|=8192),rv(m,m.updateQueue),wr(m),null);case 4:return fe(),h===null&&AN(m.stateNode.containerInfo),wr(m),null;case 10:return Wl(m.type),wr(m),null;case 19:if(V(Zr),M=m.memoizedState,M===null)return wr(m),null;if(j=(m.flags&128)!==0,L=M.rendering,L===null)if(j)ix(M,!1);else{if(Hr!==0||h!==null&&(h.flags&128)!==0)for(h=m.child;h!==null;){if(L=Vy(h),L!==null){for(m.flags|=128,ix(M,!1),h=L.updateQueue,m.updateQueue=h,rv(m,h),m.subtreeFlags=0,h=_,_=m.child;_!==null;)RL(_,h),_=_.sibling;return te(Zr,Zr.current&1|2),Dn&&Vl(m,M.treeForkCount),m.child}h=h.sibling}M.tail!==null&&I()>lv&&(m.flags|=128,j=!0,ix(M,!1),m.lanes=4194304)}else{if(!j)if(h=Vy(L),h!==null){if(m.flags|=128,j=!0,h=h.updateQueue,m.updateQueue=h,rv(m,h),ix(M,!0),M.tail===null&&M.tailMode==="hidden"&&!L.alternate&&!Dn)return wr(m),null}else 2*I()-M.renderingStartTime>lv&&_!==536870912&&(m.flags|=128,j=!0,ix(M,!1),m.lanes=4194304);M.isBackwards?(L.sibling=m.child,m.child=L):(h=M.last,h!==null?h.sibling=L:m.child=L,M.last=L)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=I(),h.sibling=null,_=Zr.current,te(Zr,j?_&1|2:_&1),Dn&&Vl(m,M.treeForkCount),h):(wr(m),null);case 22:case 23:return ys(m),TE(),M=m.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(m.flags|=8192):M&&(m.flags|=8192),M?(_&536870912)!==0&&(m.flags&128)===0&&(wr(m),m.subtreeFlags&6&&(m.flags|=8192)):wr(m),_=m.updateQueue,_!==null&&rv(m,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),M=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(M=m.memoizedState.cachePool.pool),M!==_&&(m.flags|=2048),h!==null&&V(nh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),Wl(ri),wr(m),null;case 25:return null;case 30:return null}throw Error(r(156,m.tag))}function wre(h,m){switch(fE(m),m.tag){case 1:return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 3:return Wl(ri),fe(),h=m.flags,(h&65536)!==0&&(h&128)===0?(m.flags=h&-65537|128,m):null;case 26:case 27:case 5:return _e(m),null;case 31:if(m.memoizedState!==null){if(ys(m),m.alternate===null)throw Error(r(340));Jd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 13:if(ys(m),h=m.memoizedState,h!==null&&h.dehydrated!==null){if(m.alternate===null)throw Error(r(340));Jd()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 19:return V(Zr),null;case 4:return fe(),null;case 10:return Wl(m.type),null;case 22:case 23:return ys(m),TE(),h!==null&&V(nh),h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 24:return Wl(ri),null;case 25:return null;default:return null}}function s5(h,m){switch(fE(m),m.tag){case 3:Wl(ri),fe();break;case 26:case 27:case 5:_e(m);break;case 4:fe();break;case 31:m.memoizedState!==null&&ys(m);break;case 13:ys(m);break;case 19:V(Zr);break;case 10:Wl(m.type);break;case 22:case 23:ys(m),TE(),h!==null&&V(nh);break;case 24:Wl(ri)}}function ax(h,m){try{var _=m.updateQueue,M=_!==null?_.lastEffect:null;if(M!==null){var j=M.next;_=j;do{if((_.tag&h)===h){M=void 0;var L=_.create,Q=_.inst;M=L(),Q.destroy=M}_=_.next}while(_!==j)}}catch(me){Xn(m,m.return,me)}}function xu(h,m,_){try{var M=m.updateQueue,j=M!==null?M.lastEffect:null;if(j!==null){var L=j.next;M=L;do{if((M.tag&h)===h){var Q=M.inst,me=Q.destroy;if(me!==void 0){Q.destroy=void 0,j=m;var Ce=_,tt=me;try{tt()}catch(ot){Xn(j,Ce,ot)}}}M=M.next}while(M!==L)}}catch(ot){Xn(m,m.return,ot)}}function o5(h){var m=h.updateQueue;if(m!==null){var _=h.stateNode;try{ZL(m,_)}catch(M){Xn(h,h.return,M)}}}function l5(h,m,_){_.props=oh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){Xn(h,m,M)}}function sx(h,m){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var M=h.stateNode;break;case 30:M=h.stateNode;break;default:M=h.stateNode}typeof _=="function"?h.refCleanup=_(M):_.current=M}}catch(j){Xn(h,m,j)}}function rl(h,m){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(j){Xn(h,m,j)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(j){Xn(h,m,j)}else _.current=null}function c5(h){var m=h.type,_=h.memoizedProps,M=h.stateNode;try{e:switch(m){case"button":case"input":case"select":case"textarea":_.autoFocus&&M.focus();break e;case"img":_.src?M.src=_.src:_.srcSet&&(M.srcset=_.srcSet)}}catch(j){Xn(h,h.return,j)}}function sN(h,m,_){try{var M=h.stateNode;Vre(M,h.type,_,m),M[cn]=m}catch(j){Xn(h,h.return,j)}}function u5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&Mu(h.type)||h.tag===4}function oN(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||u5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&Mu(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 lN(h,m,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,m?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,m):(m=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,m.appendChild(h),_=_._reactRootContainer,_!=null||m.onclick!==null||(m.onclick=Bl));else if(M!==4&&(M===27&&Mu(h.type)&&(_=h.stateNode,m=null),h=h.child,h!==null))for(lN(h,m,_),h=h.sibling;h!==null;)lN(h,m,_),h=h.sibling}function iv(h,m,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,m?_.insertBefore(h,m):_.appendChild(h);else if(M!==4&&(M===27&&Mu(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(iv(h,m,_),h=h.sibling;h!==null;)iv(h,m,_),h=h.sibling}function d5(h){var m=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,j=m.attributes;j.length;)m.removeAttributeNode(j[0]);ta(m,M,_),m[$t]=h,m[cn]=_}catch(L){Xn(h,h.return,L)}}var Zl=!1,si=!1,cN=!1,h5=typeof WeakSet=="function"?WeakSet:Set,Fi=null;function Sre(h,m){if(h=h.containerInfo,kN=Ev,h=ML(h),nE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var M=_.getSelection&&_.getSelection();if(M&&M.rangeCount!==0){_=M.anchorNode;var j=M.anchorOffset,L=M.focusNode;M=M.focusOffset;try{_.nodeType,L.nodeType}catch{_=null;break e}var Q=0,me=-1,Ce=-1,tt=0,ot=0,pt=h,rt=null;t:for(;;){for(var st;pt!==_||j!==0&&pt.nodeType!==3||(me=Q+j),pt!==L||M!==0&&pt.nodeType!==3||(Ce=Q+M),pt.nodeType===3&&(Q+=pt.nodeValue.length),(st=pt.firstChild)!==null;)rt=pt,pt=st;for(;;){if(pt===h)break t;if(rt===_&&++tt===j&&(me=Q),rt===L&&++ot===M&&(Ce=Q),(st=pt.nextSibling)!==null)break;pt=rt,rt=pt.parentNode}pt=st}_=me===-1||Ce===-1?null:{start:me,end:Ce}}else _=null}_=_||{start:0,end:0}}else _=null;for(jN={focusedElem:h,selectionRange:_},Ev=!1,Fi=m;Fi!==null;)if(m=Fi,h=m.child,(m.subtreeFlags&1028)!==0&&h!==null)h.return=m,Fi=h;else for(;Fi!==null;){switch(m=Fi,L=m.alternate,h=m.flags,m.tag){case 0:if((h&4)!==0&&(h=m.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)j=h[_],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&L!==null){h=void 0,_=m,j=L.memoizedProps,L=L.memoizedState,M=_.stateNode;try{var It=oh(_.type,j);h=M.getSnapshotBeforeUpdate(It,L),M.__reactInternalSnapshotBeforeUpdate=h}catch(Zt){Xn(_,_.return,Zt)}}break;case 3:if((h&1024)!==0){if(h=m.stateNode.containerInfo,_=h.nodeType,_===9)DN(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":DN(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=m.sibling,h!==null){h.return=m.return,Fi=h;break}Fi=m.return}}function f5(h,m,_){var M=_.flags;switch(_.tag){case 0:case 11:case 15:Jl(h,_),M&4&&ax(5,_);break;case 1:if(Jl(h,_),M&4)if(h=_.stateNode,m===null)try{h.componentDidMount()}catch(Q){Xn(_,_.return,Q)}else{var j=oh(_.type,m.memoizedProps);m=m.memoizedState;try{h.componentDidUpdate(j,m,h.__reactInternalSnapshotBeforeUpdate)}catch(Q){Xn(_,_.return,Q)}}M&64&&o5(_),M&512&&sx(_,_.return);break;case 3:if(Jl(h,_),M&64&&(h=_.updateQueue,h!==null)){if(m=null,_.child!==null)switch(_.child.tag){case 27:case 5:m=_.child.stateNode;break;case 1:m=_.child.stateNode}try{ZL(h,m)}catch(Q){Xn(_,_.return,Q)}}break;case 27:m===null&&M&4&&d5(_);case 26:case 5:Jl(h,_),m===null&&M&4&&c5(_),M&512&&sx(_,_.return);break;case 12:Jl(h,_);break;case 31:Jl(h,_),M&4&&g5(h,_);break;case 13:Jl(h,_),M&4&&x5(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Pre.bind(null,_),Qre(h,_))));break;case 22:if(M=_.memoizedState!==null||Zl,!M){m=m!==null&&m.memoizedState!==null||si,j=Zl;var L=si;Zl=M,(si=m)&&!L?ec(h,_,(_.subtreeFlags&8772)!==0):Jl(h,_),Zl=j,si=L}break;case 30:break;default:Jl(h,_)}}function m5(h){var m=h.alternate;m!==null&&(h.alternate=null,m5(m)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(m=h.stateNode,m!==null&&nt(m)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Ar=null,qa=!1;function Ql(h,m,_){for(_=_.child;_!==null;)p5(h,m,_),_=_.sibling}function p5(h,m,_){if(ge&&typeof ge.onCommitFiberUnmount=="function")try{ge.onCommitFiberUnmount($e,_)}catch{}switch(_.tag){case 26:si||rl(_,m),Ql(h,m,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:si||rl(_,m);var M=Ar,j=qa;Mu(_.type)&&(Ar=_.stateNode,qa=!1),Ql(h,m,_),px(_.stateNode),Ar=M,qa=j;break;case 5:si||rl(_,m);case 6:if(M=Ar,j=qa,Ar=null,Ql(h,m,_),Ar=M,qa=j,Ar!==null)if(qa)try{(Ar.nodeType===9?Ar.body:Ar.nodeName==="HTML"?Ar.ownerDocument.body:Ar).removeChild(_.stateNode)}catch(L){Xn(_,m,L)}else try{Ar.removeChild(_.stateNode)}catch(L){Xn(_,m,L)}break;case 18:Ar!==null&&(qa?(h=Ar,oF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),fm(h)):oF(Ar,_.stateNode));break;case 4:M=Ar,j=qa,Ar=_.stateNode.containerInfo,qa=!0,Ql(h,m,_),Ar=M,qa=j;break;case 0:case 11:case 14:case 15:xu(2,_,m),si||xu(4,_,m),Ql(h,m,_);break;case 1:si||(rl(_,m),M=_.stateNode,typeof M.componentWillUnmount=="function"&&l5(_,m,M)),Ql(h,m,_);break;case 21:Ql(h,m,_);break;case 22:si=(M=si)||_.memoizedState!==null,Ql(h,m,_),si=M;break;default:Ql(h,m,_)}}function g5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{fm(h)}catch(_){Xn(m,m.return,_)}}}function x5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{fm(h)}catch(_){Xn(m,m.return,_)}}function Mre(h){switch(h.tag){case 31:case 13:case 19:var m=h.stateNode;return m===null&&(m=h.stateNode=new h5),m;case 22:return h=h.stateNode,m=h._retryCache,m===null&&(m=h._retryCache=new h5),m;default:throw Error(r(435,h.tag))}}function av(h,m){var _=Mre(h);m.forEach(function(M){if(!_.has(M)){_.add(M);var j=Rre.bind(null,h,M);M.then(j,j)}})}function Ka(h,m){var _=m.deletions;if(_!==null)for(var M=0;M<_.length;M++){var j=_[M],L=h,Q=m,me=Q;e:for(;me!==null;){switch(me.tag){case 27:if(Mu(me.type)){Ar=me.stateNode,qa=!1;break e}break;case 5:Ar=me.stateNode,qa=!1;break e;case 3:case 4:Ar=me.stateNode.containerInfo,qa=!0;break e}me=me.return}if(Ar===null)throw Error(r(160));p5(L,Q,j),Ar=null,qa=!1,L=j.alternate,L!==null&&(L.return=null),j.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)b5(m,h),m=m.sibling}var Eo=null;function b5(h,m){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Ka(m,h),Xa(h),M&4&&(xu(3,h,h.return),ax(3,h),xu(5,h,h.return));break;case 1:Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),M&64&&Zl&&(h=h.updateQueue,h!==null&&(M=h.callbacks,M!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?M:_.concat(M))));break;case 26:var j=Eo;if(Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),M&4){var L=_!==null?_.memoizedState:null;if(M=h.memoizedState,_===null)if(M===null)if(h.stateNode===null){e:{M=h.type,_=h.memoizedProps,j=j.ownerDocument||j;t:switch(M){case"title":L=j.getElementsByTagName("title")[0],(!L||L[Ye]||L[$t]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=j.createElement(M),j.head.insertBefore(L,j.querySelector("head > title"))),ta(L,M,_),L[$t]=h,De(L),M=L;break e;case"link":var Q=bF("link","href",j).get(M+(_.href||""));if(Q){for(var me=0;me<Q.length;me++)if(L=Q[me],L.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&L.getAttribute("rel")===(_.rel==null?null:_.rel)&&L.getAttribute("title")===(_.title==null?null:_.title)&&L.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){Q.splice(me,1);break t}}L=j.createElement(M),ta(L,M,_),j.head.appendChild(L);break;case"meta":if(Q=bF("meta","content",j).get(M+(_.content||""))){for(me=0;me<Q.length;me++)if(L=Q[me],L.getAttribute("content")===(_.content==null?null:""+_.content)&&L.getAttribute("name")===(_.name==null?null:_.name)&&L.getAttribute("property")===(_.property==null?null:_.property)&&L.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&L.getAttribute("charset")===(_.charSet==null?null:_.charSet)){Q.splice(me,1);break t}}L=j.createElement(M),ta(L,M,_),j.head.appendChild(L);break;default:throw Error(r(468,M))}L[$t]=h,De(L),M=L}h.stateNode=M}else yF(j,h.type,h.stateNode);else h.stateNode=xF(j,M,h.memoizedProps);else L!==M?(L===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):L.count--,M===null?yF(j,h.type,h.stateNode):xF(j,M,h.memoizedProps)):M===null&&h.stateNode!==null&&sN(h,h.memoizedProps,_.memoizedProps)}break;case 27:Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),_!==null&&M&4&&sN(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Ka(m,h),Xa(h),M&512&&(si||_===null||rl(_,_.return)),h.flags&32){j=h.stateNode;try{el(j,"")}catch(It){Xn(h,h.return,It)}}M&4&&h.stateNode!=null&&(j=h.memoizedProps,sN(h,j,_!==null?_.memoizedProps:j)),M&1024&&(cN=!0);break;case 6:if(Ka(m,h),Xa(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(It){Xn(h,h.return,It)}}break;case 3:if(_v=null,j=Eo,Eo=yv(m.containerInfo),Ka(m,h),Eo=j,Xa(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{fm(m.containerInfo)}catch(It){Xn(h,h.return,It)}cN&&(cN=!1,y5(h));break;case 4:M=Eo,Eo=yv(h.stateNode.containerInfo),Ka(m,h),Xa(h),Eo=M;break;case 12:Ka(m,h),Xa(h);break;case 31:Ka(m,h),Xa(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,av(h,M)));break;case 13:Ka(m,h),Xa(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(ov=I()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,av(h,M)));break;case 22:j=h.memoizedState!==null;var Ce=_!==null&&_.memoizedState!==null,tt=Zl,ot=si;if(Zl=tt||j,si=ot||Ce,Ka(m,h),si=ot,Zl=tt,Xa(h),M&8192)e:for(m=h.stateNode,m._visibility=j?m._visibility&-2:m._visibility|1,j&&(_===null||Ce||Zl||si||lh(h)),_=null,m=h;;){if(m.tag===5||m.tag===26){if(_===null){Ce=_=m;try{if(L=Ce.stateNode,j)Q=L.style,typeof Q.setProperty=="function"?Q.setProperty("display","none","important"):Q.display="none";else{me=Ce.stateNode;var pt=Ce.memoizedProps.style,rt=pt!=null&&pt.hasOwnProperty("display")?pt.display:null;me.style.display=rt==null||typeof rt=="boolean"?"":(""+rt).trim()}}catch(It){Xn(Ce,Ce.return,It)}}}else if(m.tag===6){if(_===null){Ce=m;try{Ce.stateNode.nodeValue=j?"":Ce.memoizedProps}catch(It){Xn(Ce,Ce.return,It)}}}else if(m.tag===18){if(_===null){Ce=m;try{var st=Ce.stateNode;j?lF(st,!0):lF(Ce.stateNode,!1)}catch(It){Xn(Ce,Ce.return,It)}}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===h)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break e;for(;m.sibling===null;){if(m.return===null||m.return===h)break e;_===m&&(_=null),m=m.return}_===m&&(_=null),m.sibling.return=m.return,m=m.sibling}M&4&&(M=h.updateQueue,M!==null&&(_=M.retryQueue,_!==null&&(M.retryQueue=null,av(h,_))));break;case 19:Ka(m,h),Xa(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,av(h,M)));break;case 30:break;case 21:break;default:Ka(m,h),Xa(h)}}function Xa(h){var m=h.flags;if(m&2){try{for(var _,M=h.return;M!==null;){if(u5(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var j=_.stateNode,L=oN(h);iv(h,L,j);break;case 5:var Q=_.stateNode;_.flags&32&&(el(Q,""),_.flags&=-33);var me=oN(h);iv(h,me,Q);break;case 3:case 4:var Ce=_.stateNode.containerInfo,tt=oN(h);lN(h,tt,Ce);break;default:throw Error(r(161))}}catch(ot){Xn(h,h.return,ot)}h.flags&=-3}m&4096&&(h.flags&=-4097)}function y5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var m=h;y5(m),m.tag===5&&m.flags&1024&&m.stateNode.reset(),h=h.sibling}}function Jl(h,m){if(m.subtreeFlags&8772)for(m=m.child;m!==null;)f5(h,m.alternate,m),m=m.sibling}function lh(h){for(h=h.child;h!==null;){var m=h;switch(m.tag){case 0:case 11:case 14:case 15:xu(4,m,m.return),lh(m);break;case 1:rl(m,m.return);var _=m.stateNode;typeof _.componentWillUnmount=="function"&&l5(m,m.return,_),lh(m);break;case 27:px(m.stateNode);case 26:case 5:rl(m,m.return),lh(m);break;case 22:m.memoizedState===null&&lh(m);break;case 30:lh(m);break;default:lh(m)}h=h.sibling}}function ec(h,m,_){for(_=_&&(m.subtreeFlags&8772)!==0,m=m.child;m!==null;){var M=m.alternate,j=h,L=m,Q=L.flags;switch(L.tag){case 0:case 11:case 15:ec(j,L,_),ax(4,L);break;case 1:if(ec(j,L,_),M=L,j=M.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(tt){Xn(M,M.return,tt)}if(M=L,j=M.updateQueue,j!==null){var me=M.stateNode;try{var Ce=j.shared.hiddenCallbacks;if(Ce!==null)for(j.shared.hiddenCallbacks=null,j=0;j<Ce.length;j++)YL(Ce[j],me)}catch(tt){Xn(M,M.return,tt)}}_&&Q&64&&o5(L),sx(L,L.return);break;case 27:d5(L);case 26:case 5:ec(j,L,_),_&&M===null&&Q&4&&c5(L),sx(L,L.return);break;case 12:ec(j,L,_);break;case 31:ec(j,L,_),_&&Q&4&&g5(j,L);break;case 13:ec(j,L,_),_&&Q&4&&x5(j,L);break;case 22:L.memoizedState===null&&ec(j,L,_),sx(L,L.return);break;case 30:break;default:ec(j,L,_)}m=m.sibling}}function uN(h,m){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(h=m.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&Wg(_))}function dN(h,m){h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&Wg(h))}function No(h,m,_,M){if(m.subtreeFlags&10256)for(m=m.child;m!==null;)v5(h,m,_,M),m=m.sibling}function v5(h,m,_,M){var j=m.flags;switch(m.tag){case 0:case 11:case 15:No(h,m,_,M),j&2048&&ax(9,m);break;case 1:No(h,m,_,M);break;case 3:No(h,m,_,M),j&2048&&(h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&Wg(h)));break;case 12:if(j&2048){No(h,m,_,M),h=m.stateNode;try{var L=m.memoizedProps,Q=L.id,me=L.onPostCommit;typeof me=="function"&&me(Q,m.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ce){Xn(m,m.return,Ce)}}else No(h,m,_,M);break;case 31:No(h,m,_,M);break;case 13:No(h,m,_,M);break;case 23:break;case 22:L=m.stateNode,Q=m.alternate,m.memoizedState!==null?L._visibility&2?No(h,m,_,M):ox(h,m):L._visibility&2?No(h,m,_,M):(L._visibility|=2,nm(h,m,_,M,(m.subtreeFlags&10256)!==0||!1)),j&2048&&uN(Q,m);break;case 24:No(h,m,_,M),j&2048&&dN(m.alternate,m);break;default:No(h,m,_,M)}}function nm(h,m,_,M,j){for(j=j&&((m.subtreeFlags&10256)!==0||!1),m=m.child;m!==null;){var L=h,Q=m,me=_,Ce=M,tt=Q.flags;switch(Q.tag){case 0:case 11:case 15:nm(L,Q,me,Ce,j),ax(8,Q);break;case 23:break;case 22:var ot=Q.stateNode;Q.memoizedState!==null?ot._visibility&2?nm(L,Q,me,Ce,j):ox(L,Q):(ot._visibility|=2,nm(L,Q,me,Ce,j)),j&&tt&2048&&uN(Q.alternate,Q);break;case 24:nm(L,Q,me,Ce,j),j&&tt&2048&&dN(Q.alternate,Q);break;default:nm(L,Q,me,Ce,j)}m=m.sibling}}function ox(h,m){if(m.subtreeFlags&10256)for(m=m.child;m!==null;){var _=h,M=m,j=M.flags;switch(M.tag){case 22:ox(_,M),j&2048&&uN(M.alternate,M);break;case 24:ox(_,M),j&2048&&dN(M.alternate,M);break;default:ox(_,M)}m=m.sibling}}var lx=8192;function rm(h,m,_){if(h.subtreeFlags&lx)for(h=h.child;h!==null;)_5(h,m,_),h=h.sibling}function _5(h,m,_){switch(h.tag){case 26:rm(h,m,_),h.flags&lx&&h.memoizedState!==null&&uie(_,Eo,h.memoizedState,h.memoizedProps);break;case 5:rm(h,m,_);break;case 3:case 4:var M=Eo;Eo=yv(h.stateNode.containerInfo),rm(h,m,_),Eo=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=lx,lx=16777216,rm(h,m,_),lx=M):rm(h,m,_));break;default:rm(h,m,_)}}function w5(h){var m=h.alternate;if(m!==null&&(h=m.child,h!==null)){m.child=null;do m=h.sibling,h.sibling=null,h=m;while(h!==null)}}function cx(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Fi=M,M5(M,h)}w5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)S5(h),h=h.sibling}function S5(h){switch(h.tag){case 0:case 11:case 15:cx(h),h.flags&2048&&xu(9,h,h.return);break;case 3:cx(h);break;case 12:cx(h);break;case 22:var m=h.stateNode;h.memoizedState!==null&&m._visibility&2&&(h.return===null||h.return.tag!==13)?(m._visibility&=-3,sv(h)):cx(h);break;default:cx(h)}}function sv(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Fi=M,M5(M,h)}w5(h)}for(h=h.child;h!==null;){switch(m=h,m.tag){case 0:case 11:case 15:xu(8,m,m.return),sv(m);break;case 22:_=m.stateNode,_._visibility&2&&(_._visibility&=-3,sv(m));break;default:sv(m)}h=h.sibling}}function M5(h,m){for(;Fi!==null;){var _=Fi;switch(_.tag){case 0:case 11:case 15:xu(8,_,m);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var M=_.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:Wg(_.memoizedState.cache)}if(M=_.child,M!==null)M.return=_,Fi=M;else e:for(_=h;Fi!==null;){M=Fi;var j=M.sibling,L=M.return;if(m5(M),M===_){Fi=null;break e}if(j!==null){j.return=L,Fi=j;break e}Fi=L}}}var Ere={getCacheForType:function(h){var m=Ji(ri),_=m.data.get(h);return _===void 0&&(_=h(),m.data.set(h,_)),_},cacheSignal:function(){return Ji(ri).controller.signal}},Nre=typeof WeakMap=="function"?WeakMap:Map,$n=0,fr=null,En=null,Pn=0,Kn=0,vs=null,bu=!1,im=!1,hN=!1,tc=0,Hr=0,yu=0,ch=0,fN=0,_s=0,am=0,ux=null,Ya=null,mN=!1,ov=0,E5=0,lv=1/0,cv=null,vu=null,yi=0,_u=null,sm=null,nc=0,pN=0,gN=null,N5=null,dx=0,xN=null;function ws(){return($n&2)!==0&&Pn!==0?Pn&-Pn:Z.T!==null?SN():Ht()}function A5(){if(_s===0)if((Pn&536870912)===0||Dn){var h=xe;xe<<=1,(xe&3932160)===0&&(xe=262144),_s=h}else _s=536870912;return h=bs.current,h!==null&&(h.flags|=32),_s}function Za(h,m,_){(h===fr&&(Kn===2||Kn===9)||h.cancelPendingCommit!==null)&&(om(h,0),wu(h,Pn,_s,!1)),Yt(h,_),(($n&2)===0||h!==fr)&&(h===fr&&(($n&2)===0&&(ch|=_),Hr===4&&wu(h,Pn,_s,!1)),il(h))}function T5(h,m,_){if(($n&6)!==0)throw Error(r(327));var M=!_&&(m&127)===0&&(m&h.expiredLanes)===0||Xe(h,m),j=M?Cre(h,m):yN(h,m,!0),L=M;do{if(j===0){im&&!M&&wu(h,m,0,!1);break}else{if(_=h.current.alternate,L&&!Are(_)){j=yN(h,m,!1),L=!1;continue}if(j===2){if(L=m,h.errorRecoveryDisabledLanes&L)var Q=0;else Q=h.pendingLanes&-536870913,Q=Q!==0?Q:Q&536870912?536870912:0;if(Q!==0){m=Q;e:{var me=h;j=ux;var Ce=me.current.memoizedState.isDehydrated;if(Ce&&(om(me,Q).flags|=256),Q=yN(me,Q,!1),Q!==2){if(hN&&!Ce){me.errorRecoveryDisabledLanes|=L,ch|=L,j=4;break e}L=Ya,Ya=j,L!==null&&(Ya===null?Ya=L:Ya.push.apply(Ya,L))}j=Q}if(L=!1,j!==2)continue}}if(j===1){om(h,0),wu(h,m,0,!0);break}e:{switch(M=h,L=j,L){case 0:case 1:throw Error(r(345));case 4:if((m&4194048)!==m)break;case 6:wu(M,m,_s,!bu);break e;case 2:Ya=null;break;case 3:case 5:break;default:throw Error(r(329))}if((m&62914560)===m&&(j=ov+300-I(),10<j)){if(wu(M,m,_s,!bu),Me(M,0,!0)!==0)break e;nc=m,M.timeoutHandle=aF(C5.bind(null,M,_,Ya,cv,mN,m,_s,ch,am,bu,L,"Throttled",-0,0),j);break e}C5(M,_,Ya,cv,mN,m,_s,ch,am,bu,L,null,-0,0)}}break}while(!0);il(h)}function C5(h,m,_,M,j,L,Q,me,Ce,tt,ot,pt,rt,st){if(h.timeoutHandle=-1,pt=m.subtreeFlags,pt&8192||(pt&16785408)===16785408){pt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Bl},_5(m,L,pt);var It=(L&62914560)===L?ov-I():(L&4194048)===L?E5-I():0;if(It=die(pt,It),It!==null){nc=L,h.cancelPendingCommit=It(I5.bind(null,h,m,L,_,M,j,Q,me,Ce,ot,pt,null,rt,st)),wu(h,L,Q,!tt);return}}I5(h,m,L,_,M,j,Q,me,Ce)}function Are(h){for(var m=h;;){var _=m.tag;if((_===0||_===11||_===15)&&m.flags&16384&&(_=m.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var M=0;M<_.length;M++){var j=_[M],L=j.getSnapshot;j=j.value;try{if(!gs(L(),j))return!1}catch{return!1}}if(_=m.child,m.subtreeFlags&16384&&_!==null)_.return=m,m=_;else{if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return!0;m=m.return}m.sibling.return=m.return,m=m.sibling}}return!0}function wu(h,m,_,M){m&=~fN,m&=~ch,h.suspendedLanes|=m,h.pingedLanes&=~m,M&&(h.warmLanes|=m),M=h.expirationTimes;for(var j=m;0<j;){var L=31-qe(j),Q=1<<L;M[L]=-1,j&=~Q}_!==0&&Jt(h,_,m)}function uv(){return($n&6)===0?(hx(0),!1):!0}function bN(){if(En!==null){if(Kn===0)var h=En.return;else h=En,Gl=eh=null,DE(h),Zf=null,Kg=0,h=En;for(;h!==null;)s5(h.alternate,h),h=h.return;En=null}}function om(h,m){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,qre(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),nc=0,bN(),fr=h,En=_=$l(h.current,null),Pn=m,Kn=0,vs=null,bu=!1,im=Xe(h,m),hN=!1,am=_s=fN=ch=yu=Hr=0,Ya=ux=null,mN=!1,(m&8)!==0&&(m|=m&32);var M=h.entangledLanes;if(M!==0)for(h=h.entanglements,M&=m;0<M;){var j=31-qe(M),L=1<<j;m|=h[j],M&=~L}return tc=m,jy(),_}function k5(h,m){dn=null,Z.H=nx,m===Yf||m===Uy?(m=WL(),Kn=3):m===wE?(m=WL(),Kn=4):Kn=m===YE?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,vs=m,En===null&&(Hr=1,Jy(h,zs(m,h.current)))}function j5(){var h=bs.current;return h===null?!0:(Pn&4194048)===Pn?Vs===null:(Pn&62914560)===Pn||(Pn&536870912)!==0?h===Vs:!1}function P5(){var h=Z.H;return Z.H=nx,h===null?nx:h}function R5(){var h=Z.A;return Z.A=Ere,h}function dv(){Hr=4,bu||(Pn&4194048)!==Pn&&bs.current!==null||(im=!0),(yu&134217727)===0&&(ch&134217727)===0||fr===null||wu(fr,Pn,_s,!1)}function yN(h,m,_){var M=$n;$n|=2;var j=P5(),L=R5();(fr!==h||Pn!==m)&&(cv=null,om(h,m)),m=!1;var Q=Hr;e:do try{if(Kn!==0&&En!==null){var me=En,Ce=vs;switch(Kn){case 8:bN(),Q=6;break e;case 3:case 2:case 9:case 6:bs.current===null&&(m=!0);var tt=Kn;if(Kn=0,vs=null,lm(h,me,Ce,tt),_&&im){Q=0;break e}break;default:tt=Kn,Kn=0,vs=null,lm(h,me,Ce,tt)}}Tre(),Q=Hr;break}catch(ot){k5(h,ot)}while(!0);return m&&h.shellSuspendCounter++,Gl=eh=null,$n=M,Z.H=j,Z.A=L,En===null&&(fr=null,Pn=0,jy()),Q}function Tre(){for(;En!==null;)D5(En)}function Cre(h,m){var _=$n;$n|=2;var M=P5(),j=R5();fr!==h||Pn!==m?(cv=null,lv=I()+500,om(h,m)):im=Xe(h,m);e:do try{if(Kn!==0&&En!==null){m=En;var L=vs;t:switch(Kn){case 1:Kn=0,vs=null,lm(h,m,L,1);break;case 2:case 9:if(VL(L)){Kn=0,vs=null,O5(m);break}m=function(){Kn!==2&&Kn!==9||fr!==h||(Kn=7),il(h)},L.then(m,m);break e;case 3:Kn=7;break e;case 4:Kn=5;break e;case 7:VL(L)?(Kn=0,vs=null,O5(m)):(Kn=0,vs=null,lm(h,m,L,7));break;case 5:var Q=null;switch(En.tag){case 26:Q=En.memoizedState;case 5:case 27:var me=En;if(Q?vF(Q):me.stateNode.complete){Kn=0,vs=null;var Ce=me.sibling;if(Ce!==null)En=Ce;else{var tt=me.return;tt!==null?(En=tt,hv(tt)):En=null}break t}}Kn=0,vs=null,lm(h,m,L,5);break;case 6:Kn=0,vs=null,lm(h,m,L,6);break;case 8:bN(),Hr=6;break e;default:throw Error(r(462))}}kre();break}catch(ot){k5(h,ot)}while(!0);return Gl=eh=null,Z.H=M,Z.A=j,$n=_,En!==null?0:(fr=null,Pn=0,jy(),Hr)}function kre(){for(;En!==null&&!Ee();)D5(En)}function D5(h){var m=i5(h.alternate,h,tc);h.memoizedProps=h.pendingProps,m===null?hv(h):En=m}function O5(h){var m=h,_=m.alternate;switch(m.tag){case 15:case 0:m=QI(_,m,m.pendingProps,m.type,void 0,Pn);break;case 11:m=QI(_,m,m.pendingProps,m.type.render,m.ref,Pn);break;case 5:DE(m);default:s5(_,m),m=En=RL(m,tc),m=i5(_,m,tc)}h.memoizedProps=h.pendingProps,m===null?hv(h):En=m}function lm(h,m,_,M){Gl=eh=null,DE(m),Zf=null,Kg=0;var j=m.return;try{if(bre(h,j,m,_,Pn)){Hr=1,Jy(h,zs(_,h.current)),En=null;return}}catch(L){if(j!==null)throw En=j,L;Hr=1,Jy(h,zs(_,h.current)),En=null;return}m.flags&32768?(Dn||M===1?h=!0:im||(Pn&536870912)!==0?h=!1:(bu=h=!0,(M===2||M===9||M===3||M===6)&&(M=bs.current,M!==null&&M.tag===13&&(M.flags|=16384))),L5(m,h)):hv(m)}function hv(h){var m=h;do{if((m.flags&32768)!==0){L5(m,bu);return}h=m.return;var _=_re(m.alternate,m,tc);if(_!==null){En=_;return}if(m=m.sibling,m!==null){En=m;return}En=m=h}while(m!==null);Hr===0&&(Hr=5)}function L5(h,m){do{var _=wre(h.alternate,h);if(_!==null){_.flags&=32767,En=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!m&&(h=h.sibling,h!==null)){En=h;return}En=h=_}while(h!==null);Hr=6,En=null}function I5(h,m,_,M,j,L,Q,me,Ce){h.cancelPendingCommit=null;do fv();while(yi!==0);if(($n&6)!==0)throw Error(r(327));if(m!==null){if(m===h.current)throw Error(r(177));if(L=m.lanes|m.childLanes,L|=oE,Pt(h,_,L,Q,me,Ce),h===fr&&(En=fr=null,Pn=0),sm=m,_u=h,nc=_,pN=L,gN=j,N5=M,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Dre(ve,function(){return H5(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||M){M=Z.T,Z.T=null,j=G.p,G.p=2,Q=$n,$n|=4;try{Sre(h,m,_)}finally{$n=Q,G.p=j,Z.T=M}}yi=1,F5(),U5(),z5()}}function F5(){if(yi===1){yi=0;var h=_u,m=sm,_=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||_){_=Z.T,Z.T=null;var M=G.p;G.p=2;var j=$n;$n|=4;try{b5(m,h);var L=jN,Q=ML(h.containerInfo),me=L.focusedElem,Ce=L.selectionRange;if(Q!==me&&me&&me.ownerDocument&&SL(me.ownerDocument.documentElement,me)){if(Ce!==null&&nE(me)){var tt=Ce.start,ot=Ce.end;if(ot===void 0&&(ot=tt),"selectionStart"in me)me.selectionStart=tt,me.selectionEnd=Math.min(ot,me.value.length);else{var pt=me.ownerDocument||document,rt=pt&&pt.defaultView||window;if(rt.getSelection){var st=rt.getSelection(),It=me.textContent.length,Zt=Math.min(Ce.start,It),rr=Ce.end===void 0?Zt:Math.min(Ce.end,It);!st.extend&&Zt>rr&&(Q=rr,rr=Zt,Zt=Q);var Ve=wL(me,Zt),Oe=wL(me,rr);if(Ve&&Oe&&(st.rangeCount!==1||st.anchorNode!==Ve.node||st.anchorOffset!==Ve.offset||st.focusNode!==Oe.node||st.focusOffset!==Oe.offset)){var et=pt.createRange();et.setStart(Ve.node,Ve.offset),st.removeAllRanges(),Zt>rr?(st.addRange(et),st.extend(Oe.node,Oe.offset)):(et.setEnd(Oe.node,Oe.offset),st.addRange(et))}}}}for(pt=[],st=me;st=st.parentNode;)st.nodeType===1&&pt.push({element:st,left:st.scrollLeft,top:st.scrollTop});for(typeof me.focus=="function"&&me.focus(),me=0;me<pt.length;me++){var dt=pt[me];dt.element.scrollLeft=dt.left,dt.element.scrollTop=dt.top}}Ev=!!kN,jN=kN=null}finally{$n=j,G.p=M,Z.T=_}}h.current=m,yi=2}}function U5(){if(yi===2){yi=0;var h=_u,m=sm,_=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||_){_=Z.T,Z.T=null;var M=G.p;G.p=2;var j=$n;$n|=4;try{f5(h,m.alternate,m)}finally{$n=j,G.p=M,Z.T=_}}yi=3}}function z5(){if(yi===4||yi===3){yi=0,U();var h=_u,m=sm,_=nc,M=N5;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?yi=5:(yi=0,sm=_u=null,B5(h,h.pendingLanes));var j=h.pendingLanes;if(j===0&&(vu=null),ft(_),m=m.stateNode,ge&&typeof ge.onCommitFiberRoot=="function")try{ge.onCommitFiberRoot($e,m,void 0,(m.current.flags&128)===128)}catch{}if(M!==null){m=Z.T,j=G.p,G.p=2,Z.T=null;try{for(var L=h.onRecoverableError,Q=0;Q<M.length;Q++){var me=M[Q];L(me.value,{componentStack:me.stack})}}finally{Z.T=m,G.p=j}}(nc&3)!==0&&fv(),il(h),j=h.pendingLanes,(_&261930)!==0&&(j&42)!==0?h===xN?dx++:(dx=0,xN=h):dx=0,hx(0)}}function B5(h,m){(h.pooledCacheLanes&=m)===0&&(m=h.pooledCache,m!=null&&(h.pooledCache=null,Wg(m)))}function fv(){return F5(),U5(),z5(),H5()}function H5(){if(yi!==5)return!1;var h=_u,m=pN;pN=0;var _=ft(nc),M=Z.T,j=G.p;try{G.p=32>_?32:_,Z.T=null,_=gN,gN=null;var L=_u,Q=nc;if(yi=0,sm=_u=null,nc=0,($n&6)!==0)throw Error(r(331));var me=$n;if($n|=4,S5(L.current),v5(L,L.current,Q,_),$n=me,hx(0,!1),ge&&typeof ge.onPostCommitFiberRoot=="function")try{ge.onPostCommitFiberRoot($e,L)}catch{}return!0}finally{G.p=j,Z.T=M,B5(h,m)}}function $5(h,m,_){m=zs(_,m),m=XE(h.stateNode,m,2),h=mu(h,m,2),h!==null&&(Yt(h,2),il(h))}function Xn(h,m,_){if(h.tag===3)$5(h,h,_);else for(;m!==null;){if(m.tag===3){$5(m,h,_);break}else if(m.tag===1){var M=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(vu===null||!vu.has(M))){h=zs(_,h),_=VI(2),M=mu(m,_,2),M!==null&&(GI(_,M,m,h),Yt(M,2),il(M));break}}m=m.return}}function vN(h,m,_){var M=h.pingCache;if(M===null){M=h.pingCache=new Nre;var j=new Set;M.set(m,j)}else j=M.get(m),j===void 0&&(j=new Set,M.set(m,j));j.has(_)||(hN=!0,j.add(_),h=jre.bind(null,h,m,_),m.then(h,h))}function jre(h,m,_){var M=h.pingCache;M!==null&&M.delete(m),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,fr===h&&(Pn&_)===_&&(Hr===4||Hr===3&&(Pn&62914560)===Pn&&300>I()-ov?($n&2)===0&&om(h,0):fN|=_,am===Pn&&(am=0)),il(h)}function V5(h,m){m===0&&(m=At()),h=Zd(h,m),h!==null&&(Yt(h,m),il(h))}function Pre(h){var m=h.memoizedState,_=0;m!==null&&(_=m.retryLane),V5(h,_)}function Rre(h,m){var _=0;switch(h.tag){case 31:case 13:var M=h.stateNode,j=h.memoizedState;j!==null&&(_=j.retryLane);break;case 19:M=h.stateNode;break;case 22:M=h.stateNode._retryCache;break;default:throw Error(r(314))}M!==null&&M.delete(m),V5(h,_)}function Dre(h,m){return ke(h,m)}var mv=null,cm=null,_N=!1,pv=!1,wN=!1,Su=0;function il(h){h!==cm&&h.next===null&&(cm===null?mv=cm=h:cm=cm.next=h),pv=!0,_N||(_N=!0,Lre())}function hx(h,m){if(!wN&&pv){wN=!0;do for(var _=!1,M=mv;M!==null;){if(h!==0){var j=M.pendingLanes;if(j===0)var L=0;else{var Q=M.suspendedLanes,me=M.pingedLanes;L=(1<<31-qe(42|h)+1)-1,L&=j&~(Q&~me),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(_=!0,K5(M,L))}else L=Pn,L=Me(M,M===fr?L:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(L&3)===0||Xe(M,L)||(_=!0,K5(M,L));M=M.next}while(_);wN=!1}}function Ore(){G5()}function G5(){pv=_N=!1;var h=0;Su!==0&&Wre()&&(h=Su);for(var m=I(),_=null,M=mv;M!==null;){var j=M.next,L=W5(M,m);L===0?(M.next=null,_===null?mv=j:_.next=j,j===null&&(cm=_)):(_=M,(h!==0||(L&3)!==0)&&(pv=!0)),M=j}yi!==0&&yi!==5||hx(h),Su!==0&&(Su=0)}function W5(h,m){for(var _=h.suspendedLanes,M=h.pingedLanes,j=h.expirationTimes,L=h.pendingLanes&-62914561;0<L;){var Q=31-qe(L),me=1<<Q,Ce=j[Q];Ce===-1?((me&_)===0||(me&M)!==0)&&(j[Q]=ut(me,m)):Ce<=m&&(h.expiredLanes|=me),L&=~me}if(m=fr,_=Pn,_=Me(h,h===m?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===m&&(Kn===2||Kn===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&we(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Xe(h,_)){if(m=_&-_,m===h.callbackPriority)return m;switch(M!==null&&we(M),ft(_)){case 2:case 8:_=Se;break;case 32:_=ve;break;case 268435456:_=Ge;break;default:_=ve}return M=q5.bind(null,h),_=ke(_,M),h.callbackPriority=m,h.callbackNode=_,m}return M!==null&&M!==null&&we(M),h.callbackPriority=2,h.callbackNode=null,2}function q5(h,m){if(yi!==0&&yi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(fv()&&h.callbackNode!==_)return null;var M=Pn;return M=Me(h,h===fr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(T5(h,M,m),W5(h,I()),h.callbackNode!=null&&h.callbackNode===_?q5.bind(null,h):null)}function K5(h,m){if(fv())return null;T5(h,m,!0)}function Lre(){Kre(function(){($n&6)!==0?ke(ye,Ore):G5()})}function SN(){if(Su===0){var h=Kf;h===0&&(h=Ie,Ie<<=1,(Ie&261888)===0&&(Ie=256)),Su=h}return Su}function X5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Sy(""+h)}function Y5(h,m){var _=m.ownerDocument.createElement("input");return _.name=m.name,_.value=m.value,h.id&&_.setAttribute("form",h.id),m.parentNode.insertBefore(_,m),h=new FormData(h),_.parentNode.removeChild(_),h}function Ire(h,m,_,M,j){if(m==="submit"&&_&&_.stateNode===j){var L=X5((j[cn]||null).action),Q=M.submitter;Q&&(m=(m=Q[cn]||null)?X5(m.formAction):Q.getAttribute("formAction"),m!==null&&(L=m,Q=null));var me=new Ay("action","action",null,M,j);h.push({event:me,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(Su!==0){var Ce=Q?Y5(j,Q):new FormData(j);$E(_,{pending:!0,data:Ce,method:j.method,action:L},null,Ce)}}else typeof L=="function"&&(me.preventDefault(),Ce=Q?Y5(j,Q):new FormData(j),$E(_,{pending:!0,data:Ce,method:j.method,action:L},L,Ce))},currentTarget:j}]})}}for(var MN=0;MN<sE.length;MN++){var EN=sE[MN],Fre=EN.toLowerCase(),Ure=EN[0].toUpperCase()+EN.slice(1);Mo(Fre,"on"+Ure)}Mo(AL,"onAnimationEnd"),Mo(TL,"onAnimationIteration"),Mo(CL,"onAnimationStart"),Mo("dblclick","onDoubleClick"),Mo("focusin","onFocus"),Mo("focusout","onBlur"),Mo(tre,"onTransitionRun"),Mo(nre,"onTransitionStart"),Mo(rre,"onTransitionCancel"),Mo(kL,"onTransitionEnd"),Tt("onMouseEnter",["mouseout","mouseover"]),Tt("onMouseLeave",["mouseout","mouseover"]),Tt("onPointerEnter",["pointerout","pointerover"]),Tt("onPointerLeave",["pointerout","pointerover"]),bt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),bt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),bt("onBeforeInput",["compositionend","keypress","textInput","paste"]),bt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),bt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),bt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var fx="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(" "),zre=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(fx));function Z5(h,m){m=(m&4)!==0;for(var _=0;_<h.length;_++){var M=h[_],j=M.event;M=M.listeners;e:{var L=void 0;if(m)for(var Q=M.length-1;0<=Q;Q--){var me=M[Q],Ce=me.instance,tt=me.currentTarget;if(me=me.listener,Ce!==L&&j.isPropagationStopped())break e;L=me,j.currentTarget=tt;try{L(j)}catch(ot){ky(ot)}j.currentTarget=null,L=Ce}else for(Q=0;Q<M.length;Q++){if(me=M[Q],Ce=me.instance,tt=me.currentTarget,me=me.listener,Ce!==L&&j.isPropagationStopped())break e;L=me,j.currentTarget=tt;try{L(j)}catch(ot){ky(ot)}j.currentTarget=null,L=Ce}}}}function Nn(h,m){var _=m[qt];_===void 0&&(_=m[qt]=new Set);var M=h+"__bubble";_.has(M)||(Q5(m,h,2,!1),_.add(M))}function NN(h,m,_){var M=0;m&&(M|=4),Q5(_,h,M,m)}var gv="_reactListening"+Math.random().toString(36).slice(2);function AN(h){if(!h[gv]){h[gv]=!0,je.forEach(function(_){_!=="selectionchange"&&(zre.has(_)||NN(_,!1,h),NN(_,!0,h))});var m=h.nodeType===9?h:h.ownerDocument;m===null||m[gv]||(m[gv]=!0,NN("selectionchange",!1,m))}}function Q5(h,m,_,M){switch(AF(m)){case 2:var j=mie;break;case 8:j=pie;break;default:j=HN}_=j.bind(null,m,_,h),j=void 0,!q2||m!=="touchstart"&&m!=="touchmove"&&m!=="wheel"||(j=!0),M?j!==void 0?h.addEventListener(m,_,{capture:!0,passive:j}):h.addEventListener(m,_,!0):j!==void 0?h.addEventListener(m,_,{passive:j}):h.addEventListener(m,_,!1)}function TN(h,m,_,M,j){var L=M;if((m&1)===0&&(m&2)===0&&M!==null)e:for(;;){if(M===null)return;var Q=M.tag;if(Q===3||Q===4){var me=M.stateNode.containerInfo;if(me===j)break;if(Q===4)for(Q=M.return;Q!==null;){var Ce=Q.tag;if((Ce===3||Ce===4)&&Q.stateNode.containerInfo===j)return;Q=Q.return}for(;me!==null;){if(Q=Et(me),Q===null)return;if(Ce=Q.tag,Ce===5||Ce===6||Ce===26||Ce===27){M=L=Q;continue e}me=me.parentNode}}M=M.return}rL(function(){var tt=L,ot=G2(_),pt=[];e:{var rt=jL.get(h);if(rt!==void 0){var st=Ay,It=h;switch(h){case"keypress":if(Ey(_)===0)break e;case"keydown":case"keyup":st=Rne;break;case"focusin":It="focus",st=Z2;break;case"focusout":It="blur",st=Z2;break;case"beforeblur":case"afterblur":st=Z2;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":st=sL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":st=_ne;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":st=Lne;break;case AL:case TL:case CL:st=Mne;break;case kL:st=Fne;break;case"scroll":case"scrollend":st=yne;break;case"wheel":st=zne;break;case"copy":case"cut":case"paste":st=Nne;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":st=lL;break;case"toggle":case"beforetoggle":st=Hne}var Zt=(m&4)!==0,rr=!Zt&&(h==="scroll"||h==="scrollend"),Ve=Zt?rt!==null?rt+"Capture":null:rt;Zt=[];for(var Oe=tt,et;Oe!==null;){var dt=Oe;if(et=dt.stateNode,dt=dt.tag,dt!==5&&dt!==26&&dt!==27||et===null||Ve===null||(dt=Og(Oe,Ve),dt!=null&&Zt.push(mx(Oe,dt,et))),rr)break;Oe=Oe.return}0<Zt.length&&(rt=new st(rt,It,null,_,ot),pt.push({event:rt,listeners:Zt}))}}if((m&7)===0){e:{if(rt=h==="mouseover"||h==="pointerover",st=h==="mouseout"||h==="pointerout",rt&&_!==V2&&(It=_.relatedTarget||_.fromElement)&&(Et(It)||It[Mn]))break e;if((st||rt)&&(rt=ot.window===ot?ot:(rt=ot.ownerDocument)?rt.defaultView||rt.parentWindow:window,st?(It=_.relatedTarget||_.toElement,st=tt,It=It?Et(It):null,It!==null&&(rr=a(It),Zt=It.tag,It!==rr||Zt!==5&&Zt!==27&&Zt!==6)&&(It=null)):(st=null,It=tt),st!==It)){if(Zt=sL,dt="onMouseLeave",Ve="onMouseEnter",Oe="mouse",(h==="pointerout"||h==="pointerover")&&(Zt=lL,dt="onPointerLeave",Ve="onPointerEnter",Oe="pointer"),rr=st==null?rt:Ae(st),et=It==null?rt:Ae(It),rt=new Zt(dt,Oe+"leave",st,_,ot),rt.target=rr,rt.relatedTarget=et,dt=null,Et(ot)===tt&&(Zt=new Zt(Ve,Oe+"enter",It,_,ot),Zt.target=et,Zt.relatedTarget=rr,dt=Zt),rr=dt,st&&It)t:{for(Zt=Bre,Ve=st,Oe=It,et=0,dt=Ve;dt;dt=Zt(dt))et++;dt=0;for(var Gt=Oe;Gt;Gt=Zt(Gt))dt++;for(;0<et-dt;)Ve=Zt(Ve),et--;for(;0<dt-et;)Oe=Zt(Oe),dt--;for(;et--;){if(Ve===Oe||Oe!==null&&Ve===Oe.alternate){Zt=Ve;break t}Ve=Zt(Ve),Oe=Zt(Oe)}Zt=null}else Zt=null;st!==null&&J5(pt,rt,st,Zt,!1),It!==null&&rr!==null&&J5(pt,rr,It,Zt,!0)}}e:{if(rt=tt?Ae(tt):window,st=rt.nodeName&&rt.nodeName.toLowerCase(),st==="select"||st==="input"&&rt.type==="file")var Un=gL;else if(mL(rt))if(xL)Un=Qne;else{Un=Yne;var Ut=Xne}else st=rt.nodeName,!st||st.toLowerCase()!=="input"||rt.type!=="checkbox"&&rt.type!=="radio"?tt&&$2(tt.elementType)&&(Un=gL):Un=Zne;if(Un&&(Un=Un(h,tt))){pL(pt,Un,_,ot);break e}Ut&&Ut(h,rt,tt),h==="focusout"&&tt&&rt.type==="number"&&tt.memoizedProps.value!=null&&Li(rt,"number",rt.value)}switch(Ut=tt?Ae(tt):window,h){case"focusin":(mL(Ut)||Ut.contentEditable==="true")&&(zf=Ut,rE=tt,$g=null);break;case"focusout":$g=rE=zf=null;break;case"mousedown":iE=!0;break;case"contextmenu":case"mouseup":case"dragend":iE=!1,EL(pt,_,ot);break;case"selectionchange":if(ere)break;case"keydown":case"keyup":EL(pt,_,ot)}var hn;if(J2)e:{switch(h){case"compositionstart":var Rn="onCompositionStart";break e;case"compositionend":Rn="onCompositionEnd";break e;case"compositionupdate":Rn="onCompositionUpdate";break e}Rn=void 0}else Uf?hL(h,_)&&(Rn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Rn="onCompositionStart");Rn&&(cL&&_.locale!=="ko"&&(Uf||Rn!=="onCompositionStart"?Rn==="onCompositionEnd"&&Uf&&(hn=iL()):(ou=ot,K2="value"in ou?ou.value:ou.textContent,Uf=!0)),Ut=xv(tt,Rn),0<Ut.length&&(Rn=new oL(Rn,h,null,_,ot),pt.push({event:Rn,listeners:Ut}),hn?Rn.data=hn:(hn=fL(_),hn!==null&&(Rn.data=hn)))),(hn=Vne?Gne(h,_):Wne(h,_))&&(Rn=xv(tt,"onBeforeInput"),0<Rn.length&&(Ut=new oL("onBeforeInput","beforeinput",null,_,ot),pt.push({event:Ut,listeners:Rn}),Ut.data=hn)),Ire(pt,h,tt,_,ot)}Z5(pt,m)})}function mx(h,m,_){return{instance:h,listener:m,currentTarget:_}}function xv(h,m){for(var _=m+"Capture",M=[];h!==null;){var j=h,L=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||L===null||(j=Og(h,_),j!=null&&M.unshift(mx(h,j,L)),j=Og(h,m),j!=null&&M.push(mx(h,j,L))),h.tag===3)return M;h=h.return}return[]}function Bre(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function J5(h,m,_,M,j){for(var L=m._reactName,Q=[];_!==null&&_!==M;){var me=_,Ce=me.alternate,tt=me.stateNode;if(me=me.tag,Ce!==null&&Ce===M)break;me!==5&&me!==26&&me!==27||tt===null||(Ce=tt,j?(tt=Og(_,L),tt!=null&&Q.unshift(mx(_,tt,Ce))):j||(tt=Og(_,L),tt!=null&&Q.push(mx(_,tt,Ce)))),_=_.return}Q.length!==0&&h.push({event:m,listeners:Q})}var Hre=/\r\n?/g,$re=/\u0000|\uFFFD/g;function eF(h){return(typeof h=="string"?h:""+h).replace(Hre,`
- `).replace($re,"")}function tF(h,m){return m=eF(m),eF(h)===m}function nr(h,m,_,M,j,L){switch(_){case"children":typeof M=="string"?m==="body"||m==="textarea"&&M===""||el(h,M):(typeof M=="number"||typeof M=="bigint")&&m!=="body"&&el(h,""+M);break;case"className":Vt(h,"class",M);break;case"tabIndex":Vt(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Vt(h,_,M);break;case"style":tL(h,M,L);break;case"data":if(m!=="object"){Vt(h,"data",M);break}case"src":case"href":if(M===""&&(m!=="a"||_!=="href")){h.removeAttribute(_);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=Sy(""+M),h.setAttribute(_,M);break;case"action":case"formAction":if(typeof M=="function"){h.setAttribute(_,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof L=="function"&&(_==="formAction"?(m!=="input"&&nr(h,m,"name",j.name,j,null),nr(h,m,"formEncType",j.formEncType,j,null),nr(h,m,"formMethod",j.formMethod,j,null),nr(h,m,"formTarget",j.formTarget,j,null)):(nr(h,m,"encType",j.encType,j,null),nr(h,m,"method",j.method,j,null),nr(h,m,"target",j.target,j,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=Sy(""+M),h.setAttribute(_,M);break;case"onClick":M!=null&&(h.onclick=Bl);break;case"onScroll":M!=null&&Nn("scroll",h);break;case"onScrollEnd":M!=null&&Nn("scrollend",h);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=M&&typeof M!="function"&&typeof M!="symbol";break;case"muted":h.muted=M&&typeof M!="function"&&typeof M!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(M==null||typeof M=="function"||typeof M=="boolean"||typeof M=="symbol"){h.removeAttribute("xlink:href");break}_=Sy(""+M),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""+M):h.removeAttribute(_);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":M&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":M===!0?h.setAttribute(_,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,M):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?h.setAttribute(_,M):h.removeAttribute(_);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?h.removeAttribute(_):h.setAttribute(_,M);break;case"popover":Nn("beforetoggle",h),Nn("toggle",h),nn(h,"popover",M);break;case"xlinkActuate":fn(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":fn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":fn(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":fn(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":fn(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":fn(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":fn(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":fn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":fn(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":nn(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=xne.get(_)||_,nn(h,_,M))}}function CN(h,m,_,M,j,L){switch(_){case"style":tL(h,M,L);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof M=="string"?el(h,M):(typeof M=="number"||typeof M=="bigint")&&el(h,""+M);break;case"onScroll":M!=null&&Nn("scroll",h);break;case"onScrollEnd":M!=null&&Nn("scrollend",h);break;case"onClick":M!=null&&(h.onclick=Bl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!at.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(j=_.endsWith("Capture"),m=_.slice(2,j?_.length-7:void 0),L=h[cn]||null,L=L!=null?L[_]:null,typeof L=="function"&&h.removeEventListener(m,L,j),typeof M=="function")){typeof L!="function"&&L!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(m,M,j);break e}_ in h?h[_]=M:M===!0?h.setAttribute(_,""):nn(h,_,M)}}}function ta(h,m,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Nn("error",h),Nn("load",h);var M=!1,j=!1,L;for(L in _)if(_.hasOwnProperty(L)){var Q=_[L];if(Q!=null)switch(L){case"src":M=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:nr(h,m,L,Q,_,null)}}j&&nr(h,m,"srcSet",_.srcSet,_,null),M&&nr(h,m,"src",_.src,_,null);return;case"input":Nn("invalid",h);var me=L=Q=j=null,Ce=null,tt=null;for(M in _)if(_.hasOwnProperty(M)){var ot=_[M];if(ot!=null)switch(M){case"name":j=ot;break;case"type":Q=ot;break;case"checked":Ce=ot;break;case"defaultChecked":tt=ot;break;case"value":L=ot;break;case"defaultValue":me=ot;break;case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,m));break;default:nr(h,m,M,ot,_,null)}}qn(h,L,me,Ce,tt,Q,j,!1);return;case"select":Nn("invalid",h),M=Q=L=null;for(j in _)if(_.hasOwnProperty(j)&&(me=_[j],me!=null))switch(j){case"value":L=me;break;case"defaultValue":Q=me;break;case"multiple":M=me;default:nr(h,m,j,me,_,null)}m=L,_=Q,h.multiple=!!M,m!=null?bi(h,!!M,m,!1):_!=null&&bi(h,!!M,_,!0);return;case"textarea":Nn("invalid",h),L=j=M=null;for(Q in _)if(_.hasOwnProperty(Q)&&(me=_[Q],me!=null))switch(Q){case"value":M=me;break;case"defaultValue":j=me;break;case"children":L=me;break;case"dangerouslySetInnerHTML":if(me!=null)throw Error(r(91));break;default:nr(h,m,Q,me,_,null)}Zi(h,M,j,L);return;case"option":for(Ce in _)if(_.hasOwnProperty(Ce)&&(M=_[Ce],M!=null))switch(Ce){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:nr(h,m,Ce,M,_,null)}return;case"dialog":Nn("beforetoggle",h),Nn("toggle",h),Nn("cancel",h),Nn("close",h);break;case"iframe":case"object":Nn("load",h);break;case"video":case"audio":for(M=0;M<fx.length;M++)Nn(fx[M],h);break;case"image":Nn("error",h),Nn("load",h);break;case"details":Nn("toggle",h);break;case"embed":case"source":case"link":Nn("error",h),Nn("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(tt in _)if(_.hasOwnProperty(tt)&&(M=_[tt],M!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:nr(h,m,tt,M,_,null)}return;default:if($2(m)){for(ot in _)_.hasOwnProperty(ot)&&(M=_[ot],M!==void 0&&CN(h,m,ot,M,_,void 0));return}}for(me in _)_.hasOwnProperty(me)&&(M=_[me],M!=null&&nr(h,m,me,M,_,null))}function Vre(h,m,_,M){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,L=null,Q=null,me=null,Ce=null,tt=null,ot=null;for(st in _){var pt=_[st];if(_.hasOwnProperty(st)&&pt!=null)switch(st){case"checked":break;case"value":break;case"defaultValue":Ce=pt;default:M.hasOwnProperty(st)||nr(h,m,st,null,M,pt)}}for(var rt in M){var st=M[rt];if(pt=_[rt],M.hasOwnProperty(rt)&&(st!=null||pt!=null))switch(rt){case"type":L=st;break;case"name":j=st;break;case"checked":tt=st;break;case"defaultChecked":ot=st;break;case"value":Q=st;break;case"defaultValue":me=st;break;case"children":case"dangerouslySetInnerHTML":if(st!=null)throw Error(r(137,m));break;default:st!==pt&&nr(h,m,rt,st,M,pt)}}So(h,Q,me,Ce,tt,ot,L,j);return;case"select":st=Q=me=rt=null;for(L in _)if(Ce=_[L],_.hasOwnProperty(L)&&Ce!=null)switch(L){case"value":break;case"multiple":st=Ce;default:M.hasOwnProperty(L)||nr(h,m,L,null,M,Ce)}for(j in M)if(L=M[j],Ce=_[j],M.hasOwnProperty(j)&&(L!=null||Ce!=null))switch(j){case"value":rt=L;break;case"defaultValue":me=L;break;case"multiple":Q=L;default:L!==Ce&&nr(h,m,j,L,M,Ce)}m=me,_=Q,M=st,rt!=null?bi(h,!!_,rt,!1):!!M!=!!_&&(m!=null?bi(h,!!_,m,!0):bi(h,!!_,_?[]:"",!1));return;case"textarea":st=rt=null;for(me in _)if(j=_[me],_.hasOwnProperty(me)&&j!=null&&!M.hasOwnProperty(me))switch(me){case"value":break;case"children":break;default:nr(h,m,me,null,M,j)}for(Q in M)if(j=M[Q],L=_[Q],M.hasOwnProperty(Q)&&(j!=null||L!=null))switch(Q){case"value":rt=j;break;case"defaultValue":st=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==L&&nr(h,m,Q,j,M,L)}Ii(h,rt,st);return;case"option":for(var It in _)if(rt=_[It],_.hasOwnProperty(It)&&rt!=null&&!M.hasOwnProperty(It))switch(It){case"selected":h.selected=!1;break;default:nr(h,m,It,null,M,rt)}for(Ce in M)if(rt=M[Ce],st=_[Ce],M.hasOwnProperty(Ce)&&rt!==st&&(rt!=null||st!=null))switch(Ce){case"selected":h.selected=rt&&typeof rt!="function"&&typeof rt!="symbol";break;default:nr(h,m,Ce,rt,M,st)}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 Zt in _)rt=_[Zt],_.hasOwnProperty(Zt)&&rt!=null&&!M.hasOwnProperty(Zt)&&nr(h,m,Zt,null,M,rt);for(tt in M)if(rt=M[tt],st=_[tt],M.hasOwnProperty(tt)&&rt!==st&&(rt!=null||st!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":if(rt!=null)throw Error(r(137,m));break;default:nr(h,m,tt,rt,M,st)}return;default:if($2(m)){for(var rr in _)rt=_[rr],_.hasOwnProperty(rr)&&rt!==void 0&&!M.hasOwnProperty(rr)&&CN(h,m,rr,void 0,M,rt);for(ot in M)rt=M[ot],st=_[ot],!M.hasOwnProperty(ot)||rt===st||rt===void 0&&st===void 0||CN(h,m,ot,rt,M,st);return}}for(var Ve in _)rt=_[Ve],_.hasOwnProperty(Ve)&&rt!=null&&!M.hasOwnProperty(Ve)&&nr(h,m,Ve,null,M,rt);for(pt in M)rt=M[pt],st=_[pt],!M.hasOwnProperty(pt)||rt===st||rt==null&&st==null||nr(h,m,pt,rt,M,st)}function nF(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Gre(){if(typeof performance.getEntriesByType=="function"){for(var h=0,m=0,_=performance.getEntriesByType("resource"),M=0;M<_.length;M++){var j=_[M],L=j.transferSize,Q=j.initiatorType,me=j.duration;if(L&&me&&nF(Q)){for(Q=0,me=j.responseEnd,M+=1;M<_.length;M++){var Ce=_[M],tt=Ce.startTime;if(tt>me)break;var ot=Ce.transferSize,pt=Ce.initiatorType;ot&&nF(pt)&&(Ce=Ce.responseEnd,Q+=ot*(Ce<me?1:(me-tt)/(Ce-tt)))}if(--M,m+=8*(L+Q)/(j.duration/1e3),h++,10<h)break}}if(0<h)return m/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var kN=null,jN=null;function bv(h){return h.nodeType===9?h:h.ownerDocument}function rF(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function iF(h,m){if(h===0)switch(m){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&m==="foreignObject"?0:h}function PN(h,m){return h==="textarea"||h==="noscript"||typeof m.children=="string"||typeof m.children=="number"||typeof m.children=="bigint"||typeof m.dangerouslySetInnerHTML=="object"&&m.dangerouslySetInnerHTML!==null&&m.dangerouslySetInnerHTML.__html!=null}var RN=null;function Wre(){var h=window.event;return h&&h.type==="popstate"?h===RN?!1:(RN=h,!0):(RN=null,!1)}var aF=typeof setTimeout=="function"?setTimeout:void 0,qre=typeof clearTimeout=="function"?clearTimeout:void 0,sF=typeof Promise=="function"?Promise:void 0,Kre=typeof queueMicrotask=="function"?queueMicrotask:typeof sF<"u"?function(h){return sF.resolve(null).then(h).catch(Xre)}:aF;function Xre(h){setTimeout(function(){throw h})}function Mu(h){return h==="head"}function oF(h,m){var _=m,M=0;do{var j=_.nextSibling;if(h.removeChild(_),j&&j.nodeType===8)if(_=j.data,_==="/$"||_==="/&"){if(M===0){h.removeChild(j),fm(m);return}M--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")M++;else if(_==="html")px(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,px(_);for(var L=_.firstChild;L;){var Q=L.nextSibling,me=L.nodeName;L[Ye]||me==="SCRIPT"||me==="STYLE"||me==="LINK"&&L.rel.toLowerCase()==="stylesheet"||_.removeChild(L),L=Q}}else _==="body"&&px(h.ownerDocument.body);_=j}while(_);fm(m)}function lF(h,m){var _=h;h=0;do{var M=_.nextSibling;if(_.nodeType===1?m?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(m?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),M&&M.nodeType===8)if(_=M.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=M}while(_)}function DN(h){var m=h.firstChild;for(m&&m.nodeType===10&&(m=m.nextSibling);m;){var _=m;switch(m=m.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":DN(_),nt(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function Yre(h,m,_,M){for(;h.nodeType===1;){var j=_;if(h.nodeName.toLowerCase()!==m.toLowerCase()){if(!M&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(M){if(!h[Ye])switch(m){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(L=h.getAttribute("rel"),L==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(L!==j.rel||h.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||h.getAttribute("title")!==(j.title==null?null:j.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(L=h.getAttribute("src"),(L!==(j.src==null?null:j.src)||h.getAttribute("type")!==(j.type==null?null:j.type)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&L&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(m==="input"&&h.type==="hidden"){var L=j.name==null?null:""+j.name;if(j.type==="hidden"&&h.getAttribute("name")===L)return h}else return h;if(h=Gs(h.nextSibling),h===null)break}return null}function Zre(h,m,_){if(m==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Gs(h.nextSibling),h===null))return null;return h}function cF(h,m){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!m||(h=Gs(h.nextSibling),h===null))return null;return h}function ON(h){return h.data==="$?"||h.data==="$~"}function LN(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function Qre(h,m){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=m;else if(h.data!=="$?"||_.readyState!=="loading")m();else{var M=function(){m(),_.removeEventListener("DOMContentLoaded",M)};_.addEventListener("DOMContentLoaded",M),h._reactRetry=M}}function Gs(h){for(;h!=null;h=h.nextSibling){var m=h.nodeType;if(m===1||m===3)break;if(m===8){if(m=h.data,m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"||m==="F!"||m==="F")break;if(m==="/$"||m==="/&")return null}}return h}var IN=null;function uF(h){h=h.nextSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(m===0)return Gs(h.nextSibling);m--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||m++}h=h.nextSibling}return null}function dF(h){h=h.previousSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(m===0)return h;m--}else _!=="/$"&&_!=="/&"||m++}h=h.previousSibling}return null}function hF(h,m,_){switch(m=bv(_),h){case"html":if(h=m.documentElement,!h)throw Error(r(452));return h;case"head":if(h=m.head,!h)throw Error(r(453));return h;case"body":if(h=m.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function px(h){for(var m=h.attributes;m.length;)h.removeAttributeNode(m[0]);nt(h)}var Ws=new Map,fF=new Set;function yv(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var rc=G.d;G.d={f:Jre,r:eie,D:tie,C:nie,L:rie,m:iie,X:sie,S:aie,M:oie};function Jre(){var h=rc.f(),m=uv();return h||m}function eie(h){var m=oe(h);m!==null&&m.tag===5&&m.type==="form"?kI(m):rc.r(h)}var um=typeof document>"u"?null:document;function mF(h,m,_){var M=um;if(M&&typeof m=="string"&&m){var j=Gn(m);j='link[rel="'+h+'"][href="'+j+'"]',typeof _=="string"&&(j+='[crossorigin="'+_+'"]'),fF.has(j)||(fF.add(j),h={rel:h,crossOrigin:_,href:m},M.querySelector(j)===null&&(m=M.createElement("link"),ta(m,"link",h),De(m),M.head.appendChild(m)))}}function tie(h){rc.D(h),mF("dns-prefetch",h,null)}function nie(h,m){rc.C(h,m),mF("preconnect",h,m)}function rie(h,m,_){rc.L(h,m,_);var M=um;if(M&&h&&m){var j='link[rel="preload"][as="'+Gn(m)+'"]';m==="image"&&_&&_.imageSrcSet?(j+='[imagesrcset="'+Gn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(j+='[imagesizes="'+Gn(_.imageSizes)+'"]')):j+='[href="'+Gn(h)+'"]';var L=j;switch(m){case"style":L=dm(h);break;case"script":L=hm(h)}Ws.has(L)||(h=f({rel:"preload",href:m==="image"&&_&&_.imageSrcSet?void 0:h,as:m},_),Ws.set(L,h),M.querySelector(j)!==null||m==="style"&&M.querySelector(gx(L))||m==="script"&&M.querySelector(xx(L))||(m=M.createElement("link"),ta(m,"link",h),De(m),M.head.appendChild(m)))}}function iie(h,m){rc.m(h,m);var _=um;if(_&&h){var M=m&&typeof m.as=="string"?m.as:"script",j='link[rel="modulepreload"][as="'+Gn(M)+'"][href="'+Gn(h)+'"]',L=j;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=hm(h)}if(!Ws.has(L)&&(h=f({rel:"modulepreload",href:h},m),Ws.set(L,h),_.querySelector(j)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(xx(L)))return}M=_.createElement("link"),ta(M,"link",h),De(M),_.head.appendChild(M)}}}function aie(h,m,_){rc.S(h,m,_);var M=um;if(M&&h){var j=Re(M).hoistableStyles,L=dm(h);m=m||"default";var Q=j.get(L);if(!Q){var me={loading:0,preload:null};if(Q=M.querySelector(gx(L)))me.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":m},_),(_=Ws.get(L))&&FN(h,_);var Ce=Q=M.createElement("link");De(Ce),ta(Ce,"link",h),Ce._p=new Promise(function(tt,ot){Ce.onload=tt,Ce.onerror=ot}),Ce.addEventListener("load",function(){me.loading|=1}),Ce.addEventListener("error",function(){me.loading|=2}),me.loading|=4,vv(Q,m,M)}Q={type:"stylesheet",instance:Q,count:1,state:me},j.set(L,Q)}}}function sie(h,m){rc.X(h,m);var _=um;if(_&&h){var M=Re(_).hoistableScripts,j=hm(h),L=M.get(j);L||(L=_.querySelector(xx(j)),L||(h=f({src:h,async:!0},m),(m=Ws.get(j))&&UN(h,m),L=_.createElement("script"),De(L),ta(L,"link",h),_.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},M.set(j,L))}}function oie(h,m){rc.M(h,m);var _=um;if(_&&h){var M=Re(_).hoistableScripts,j=hm(h),L=M.get(j);L||(L=_.querySelector(xx(j)),L||(h=f({src:h,async:!0,type:"module"},m),(m=Ws.get(j))&&UN(h,m),L=_.createElement("script"),De(L),ta(L,"link",h),_.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},M.set(j,L))}}function pF(h,m,_,M){var j=(j=he.current)?yv(j):null;if(!j)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(m=dm(_.href),_=Re(j).hoistableStyles,M=_.get(m),M||(M={type:"style",instance:null,count:0,state:null},_.set(m,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=dm(_.href);var L=Re(j).hoistableStyles,Q=L.get(h);if(Q||(j=j.ownerDocument||j,Q={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(h,Q),(L=j.querySelector(gx(h)))&&!L._p&&(Q.instance=L,Q.state.loading=5),Ws.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Ws.set(h,_),L||lie(j,h,_,Q.state))),m&&M===null)throw Error(r(528,""));return Q}if(m&&M!==null)throw Error(r(529,""));return null;case"script":return m=_.async,_=_.src,typeof _=="string"&&m&&typeof m!="function"&&typeof m!="symbol"?(m=hm(_),_=Re(j).hoistableScripts,M=_.get(m),M||(M={type:"script",instance:null,count:0,state:null},_.set(m,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function dm(h){return'href="'+Gn(h)+'"'}function gx(h){return'link[rel="stylesheet"]['+h+"]"}function gF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function lie(h,m,_,M){h.querySelector('link[rel="preload"][as="style"]['+m+"]")?M.loading=1:(m=h.createElement("link"),M.preload=m,m.addEventListener("load",function(){return M.loading|=1}),m.addEventListener("error",function(){return M.loading|=2}),ta(m,"link",_),De(m),h.head.appendChild(m))}function hm(h){return'[src="'+Gn(h)+'"]'}function xx(h){return"script[async]"+h}function xF(h,m,_){if(m.count++,m.instance===null)switch(m.type){case"style":var M=h.querySelector('style[data-href~="'+Gn(_.href)+'"]');if(M)return m.instance=M,De(M),M;var j=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),De(M),ta(M,"style",j),vv(M,_.precedence,h),m.instance=M;case"stylesheet":j=dm(_.href);var L=h.querySelector(gx(j));if(L)return m.state.loading|=4,m.instance=L,De(L),L;M=gF(_),(j=Ws.get(j))&&FN(M,j),L=(h.ownerDocument||h).createElement("link"),De(L);var Q=L;return Q._p=new Promise(function(me,Ce){Q.onload=me,Q.onerror=Ce}),ta(L,"link",M),m.state.loading|=4,vv(L,_.precedence,h),m.instance=L;case"script":return L=hm(_.src),(j=h.querySelector(xx(L)))?(m.instance=j,De(j),j):(M=_,(j=Ws.get(L))&&(M=f({},_),UN(M,j)),h=h.ownerDocument||h,j=h.createElement("script"),De(j),ta(j,"link",M),h.head.appendChild(j),m.instance=j);case"void":return null;default:throw Error(r(443,m.type))}else m.type==="stylesheet"&&(m.state.loading&4)===0&&(M=m.instance,m.state.loading|=4,vv(M,_.precedence,h));return m.instance}function vv(h,m,_){for(var M=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=M.length?M[M.length-1]:null,L=j,Q=0;Q<M.length;Q++){var me=M[Q];if(me.dataset.precedence===m)L=me;else if(L!==j)break}L?L.parentNode.insertBefore(h,L.nextSibling):(m=_.nodeType===9?_.head:_,m.insertBefore(h,m.firstChild))}function FN(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.title==null&&(h.title=m.title)}function UN(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.integrity==null&&(h.integrity=m.integrity)}var _v=null;function bF(h,m,_){if(_v===null){var M=new Map,j=_v=new Map;j.set(_,M)}else j=_v,M=j.get(_),M||(M=new Map,j.set(_,M));if(M.has(h))return M;for(M.set(h,null),_=_.getElementsByTagName(h),j=0;j<_.length;j++){var L=_[j];if(!(L[Ye]||L[$t]||h==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var Q=L.getAttribute(m)||"";Q=h+Q;var me=M.get(Q);me?me.push(L):M.set(Q,[L])}}return M}function yF(h,m,_){h=h.ownerDocument||h,h.head.insertBefore(_,m==="title"?h.querySelector("head > title"):null)}function cie(h,m,_){if(_===1||m.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof m.precedence!="string"||typeof m.href!="string"||m.href==="")break;return!0;case"link":if(typeof m.rel!="string"||typeof m.href!="string"||m.href===""||m.onLoad||m.onError)break;switch(m.rel){case"stylesheet":return h=m.disabled,typeof m.precedence=="string"&&h==null;default:return!0}case"script":if(m.async&&typeof m.async!="function"&&typeof m.async!="symbol"&&!m.onLoad&&!m.onError&&m.src&&typeof m.src=="string")return!0}return!1}function vF(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function uie(h,m,_,M){if(_.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var j=dm(M.href),L=m.querySelector(gx(j));if(L){m=L._p,m!==null&&typeof m=="object"&&typeof m.then=="function"&&(h.count++,h=wv.bind(h),m.then(h,h)),_.state.loading|=4,_.instance=L,De(L);return}L=m.ownerDocument||m,M=gF(M),(j=Ws.get(j))&&FN(M,j),L=L.createElement("link"),De(L);var Q=L;Q._p=new Promise(function(me,Ce){Q.onload=me,Q.onerror=Ce}),ta(L,"link",M),_.instance=L}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,m),(m=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=wv.bind(h),m.addEventListener("load",_),m.addEventListener("error",_))}}var zN=0;function die(h,m){return h.stylesheets&&h.count===0&&Mv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var M=setTimeout(function(){if(h.stylesheets&&Mv(h,h.stylesheets),h.unsuspend){var L=h.unsuspend;h.unsuspend=null,L()}},6e4+m);0<h.imgBytes&&zN===0&&(zN=62500*Gre());var j=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&Mv(h,h.stylesheets),h.unsuspend)){var L=h.unsuspend;h.unsuspend=null,L()}},(h.imgBytes>zN?50:800)+m);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(j)}}:null}function wv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Mv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Sv=null;function Mv(h,m){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Sv=new Map,m.forEach(hie,h),Sv=null,wv.call(h))}function hie(h,m){if(!(m.state.loading&4)){var _=Sv.get(h);if(_)var M=_.get(null);else{_=new Map,Sv.set(h,_);for(var j=h.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<j.length;L++){var Q=j[L];(Q.nodeName==="LINK"||Q.getAttribute("media")!=="not all")&&(_.set(Q.dataset.precedence,Q),M=Q)}M&&_.set(null,M)}j=m.instance,Q=j.getAttribute("data-precedence"),L=_.get(Q)||M,L===M&&_.set(null,j),_.set(Q,j),this.count++,M=wv.bind(this),j.addEventListener("load",M),j.addEventListener("error",M),L?L.parentNode.insertBefore(j,L.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(j,h.firstChild)),m.state.loading|=4}}var bx={$$typeof:w,Provider:null,Consumer:null,_currentValue:Y,_currentValue2:Y,_threadCount:0};function fie(h,m,_,M,j,L,Q,me,Ce){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=St(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=St(0),this.hiddenUpdates=St(null),this.identifierPrefix=M,this.onUncaughtError=j,this.onCaughtError=L,this.onRecoverableError=Q,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ce,this.incompleteTransitions=new Map}function _F(h,m,_,M,j,L,Q,me,Ce,tt,ot,pt){return h=new fie(h,m,_,Q,Ce,tt,ot,pt,me),m=1,L===!0&&(m|=24),L=xs(3,null,null,m),h.current=L,L.stateNode=h,m=yE(),m.refCount++,h.pooledCache=m,m.refCount++,L.memoizedState={element:M,isDehydrated:_,cache:m},SE(L),h}function wF(h){return h?(h=$f,h):$f}function SF(h,m,_,M,j,L){j=wF(j),M.context===null?M.context=j:M.pendingContext=j,M=fu(m),M.payload={element:_},L=L===void 0?null:L,L!==null&&(M.callback=L),_=mu(h,M,m),_!==null&&(Za(_,h,m),Yg(_,h,m))}function MF(h,m){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<m?_:m}}function BN(h,m){MF(h,m),(h=h.alternate)&&MF(h,m)}function EF(h){if(h.tag===13||h.tag===31){var m=Zd(h,67108864);m!==null&&Za(m,h,67108864),BN(h,67108864)}}function NF(h){if(h.tag===13||h.tag===31){var m=ws();m=vr(m);var _=Zd(h,m);_!==null&&Za(_,h,m),BN(h,m)}}var Ev=!0;function mie(h,m,_,M){var j=Z.T;Z.T=null;var L=G.p;try{G.p=2,HN(h,m,_,M)}finally{G.p=L,Z.T=j}}function pie(h,m,_,M){var j=Z.T;Z.T=null;var L=G.p;try{G.p=8,HN(h,m,_,M)}finally{G.p=L,Z.T=j}}function HN(h,m,_,M){if(Ev){var j=$N(M);if(j===null)TN(h,m,M,Nv,_),TF(h,M);else if(xie(j,h,m,_,M))M.stopPropagation();else if(TF(h,M),m&4&&-1<gie.indexOf(h)){for(;j!==null;){var L=oe(j);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var Q=Pe(L.pendingLanes);if(Q!==0){var me=L;for(me.pendingLanes|=2,me.entangledLanes|=2;Q;){var Ce=1<<31-qe(Q);me.entanglements[1]|=Ce,Q&=~Ce}il(L),($n&6)===0&&(lv=I()+500,hx(0))}}break;case 31:case 13:me=Zd(L,2),me!==null&&Za(me,L,2),uv(),BN(L,2)}if(L=$N(M),L===null&&TN(h,m,M,Nv,_),L===j)break;j=L}j!==null&&M.stopPropagation()}else TN(h,m,M,null,_)}}function $N(h){return h=G2(h),VN(h)}var Nv=null;function VN(h){if(Nv=null,h=Et(h),h!==null){var m=a(h);if(m===null)h=null;else{var _=m.tag;if(_===13){if(h=o(m),h!==null)return h;h=null}else if(_===31){if(h=l(m),h!==null)return h;h=null}else if(_===3){if(m.stateNode.current.memoizedState.isDehydrated)return m.tag===3?m.stateNode.containerInfo:null;h=null}else m!==h&&(h=null)}}return Nv=h,null}function AF(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(se()){case ye:return 2;case Se:return 8;case ve:case Be:return 32;case Ge:return 268435456;default:return 32}default:return 32}}var GN=!1,Eu=null,Nu=null,Au=null,yx=new Map,vx=new Map,Tu=[],gie="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function TF(h,m){switch(h){case"focusin":case"focusout":Eu=null;break;case"dragenter":case"dragleave":Nu=null;break;case"mouseover":case"mouseout":Au=null;break;case"pointerover":case"pointerout":yx.delete(m.pointerId);break;case"gotpointercapture":case"lostpointercapture":vx.delete(m.pointerId)}}function _x(h,m,_,M,j,L){return h===null||h.nativeEvent!==L?(h={blockedOn:m,domEventName:_,eventSystemFlags:M,nativeEvent:L,targetContainers:[j]},m!==null&&(m=oe(m),m!==null&&EF(m)),h):(h.eventSystemFlags|=M,m=h.targetContainers,j!==null&&m.indexOf(j)===-1&&m.push(j),h)}function xie(h,m,_,M,j){switch(m){case"focusin":return Eu=_x(Eu,h,m,_,M,j),!0;case"dragenter":return Nu=_x(Nu,h,m,_,M,j),!0;case"mouseover":return Au=_x(Au,h,m,_,M,j),!0;case"pointerover":var L=j.pointerId;return yx.set(L,_x(yx.get(L)||null,h,m,_,M,j)),!0;case"gotpointercapture":return L=j.pointerId,vx.set(L,_x(vx.get(L)||null,h,m,_,M,j)),!0}return!1}function CF(h){var m=Et(h.target);if(m!==null){var _=a(m);if(_!==null){if(m=_.tag,m===13){if(m=o(_),m!==null){h.blockedOn=m,Qt(h.priority,function(){NF(_)});return}}else if(m===31){if(m=l(_),m!==null){h.blockedOn=m,Qt(h.priority,function(){NF(_)});return}}else if(m===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Av(h){if(h.blockedOn!==null)return!1;for(var m=h.targetContainers;0<m.length;){var _=$N(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);V2=M,_.target.dispatchEvent(M),V2=null}else return m=oe(_),m!==null&&EF(m),h.blockedOn=_,!1;m.shift()}return!0}function kF(h,m,_){Av(h)&&_.delete(m)}function bie(){GN=!1,Eu!==null&&Av(Eu)&&(Eu=null),Nu!==null&&Av(Nu)&&(Nu=null),Au!==null&&Av(Au)&&(Au=null),yx.forEach(kF),vx.forEach(kF)}function Tv(h,m){h.blockedOn===m&&(h.blockedOn=null,GN||(GN=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,bie)))}var Cv=null;function jF(h){Cv!==h&&(Cv=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Cv===h&&(Cv=null);for(var m=0;m<h.length;m+=3){var _=h[m],M=h[m+1],j=h[m+2];if(typeof M!="function"){if(VN(M||_)===null)continue;break}var L=oe(_);L!==null&&(h.splice(m,3),m-=3,$E(L,{pending:!0,data:j,method:_.method,action:M},M,j))}}))}function fm(h){function m(Ce){return Tv(Ce,h)}Eu!==null&&Tv(Eu,h),Nu!==null&&Tv(Nu,h),Au!==null&&Tv(Au,h),yx.forEach(m),vx.forEach(m);for(var _=0;_<Tu.length;_++){var M=Tu[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<Tu.length&&(_=Tu[0],_.blockedOn===null);)CF(_),_.blockedOn===null&&Tu.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var j=_[M],L=_[M+1],Q=j[cn]||null;if(typeof L=="function")Q||jF(_);else if(Q){var me=null;if(L&&L.hasAttribute("formAction")){if(j=L,Q=L[cn]||null)me=Q.formAction;else if(VN(j)!==null)continue}else me=Q.action;typeof me=="function"?_[M+1]=me:(_.splice(M,3),M-=3),jF(_)}}}function PF(){function h(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(Q){return j=Q})},focusReset:"manual",scroll:"manual"})}function m(){j!==null&&(j(),j=null),M||setTimeout(_,20)}function _(){if(!M&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var M=!1,j=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",m),navigation.addEventListener("navigateerror",m),setTimeout(_,100),function(){M=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",m),navigation.removeEventListener("navigateerror",m),j!==null&&(j(),j=null)}}}function WN(h){this._internalRoot=h}kv.prototype.render=WN.prototype.render=function(h){var m=this._internalRoot;if(m===null)throw Error(r(409));var _=m.current,M=ws();SF(_,M,h,m,null,null)},kv.prototype.unmount=WN.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var m=h.containerInfo;SF(h.current,2,null,h,null,null),uv(),m[Mn]=null}};function kv(h){this._internalRoot=h}kv.prototype.unstable_scheduleHydration=function(h){if(h){var m=Ht();h={blockedOn:null,target:h,priority:m};for(var _=0;_<Tu.length&&m!==0&&m<Tu[_].priority;_++);Tu.splice(_,0,h),_===0&&CF(h)}};var RF=e.version;if(RF!=="19.2.0")throw Error(r(527,RF,"19.2.0"));G.findDOMNode=function(h){var m=h._reactInternals;if(m===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(m),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var yie={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:Z,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var jv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!jv.isDisabled&&jv.supportsFiber)try{$e=jv.inject(yie),ge=jv}catch{}}return Sx.createRoot=function(h,m){if(!i(h))throw Error(r(299));var _=!1,M="",j=zI,L=BI,Q=HI;return m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(M=m.identifierPrefix),m.onUncaughtError!==void 0&&(j=m.onUncaughtError),m.onCaughtError!==void 0&&(L=m.onCaughtError),m.onRecoverableError!==void 0&&(Q=m.onRecoverableError)),m=_F(h,1,!1,null,null,_,M,null,j,L,Q,PF),h[Mn]=m.current,AN(h),new WN(m)},Sx.hydrateRoot=function(h,m,_){if(!i(h))throw Error(r(299));var M=!1,j="",L=zI,Q=BI,me=HI,Ce=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(j=_.identifierPrefix),_.onUncaughtError!==void 0&&(L=_.onUncaughtError),_.onCaughtError!==void 0&&(Q=_.onCaughtError),_.onRecoverableError!==void 0&&(me=_.onRecoverableError),_.formState!==void 0&&(Ce=_.formState)),m=_F(h,1,!0,m,_??null,M,j,Ce,L,Q,me,PF),m.context=wF(null),_=m.current,M=ws(),M=vr(M),j=fu(M),j.callback=null,mu(_,j,M),_=M,m.current.lanes=_,Yt(m,_),il(m),h[Mn]=m.current,AN(h),new kv(m)},Sx.version="19.2.0",Sx}var $F;function kie(){if($F)return XN.exports;$F=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),XN.exports=Cie(),XN.exports}var jie=kie();const en=t=>typeof t=="string",Mx=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},VF=t=>t==null?"":""+t,Pie=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Rie=/###/g,GF=t=>t&&t.indexOf("###")>-1?t.replace(Rie,"."):t,WF=t=>!t||en(t),h0=(t,e,n)=>{const r=en(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(WF(t))return{};const a=GF(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return WF(t)?{}:{obj:t,k:GF(r[i])}},qF=(t,e,n)=>{const{obj:r,k:i}=h0(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=h0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=h0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},Die=(t,e,n,r)=>{const{obj:i,k:a}=h0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},V1=(t,e)=>{const{obj:n,k:r}=h0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Oie=(t,e,n)=>{const r=V1(t,n);return r!==void 0?r:V1(e,n)},cG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?en(t[r])||t[r]instanceof String||en(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):cG(t[r],e[r],n):t[r]=e[r]);return t},mm=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Lie={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Iie=t=>en(t)?t.replace(/[&<>"'\/]/g,e=>Lie[e]):t;class Fie{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 Uie=[" ",",","?","!",";"],zie=new Fie(20),Bie=(t,e,n)=>{e=e||"",n=n||"";const r=Uie.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=zie.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},Xk=(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},L0=t=>t?.replace("_","-"),Hie={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 G1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Hie,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:(en(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new G1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new G1(this.logger,e)}}var gl=new G1;let oM=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i.apply(i,[e,...n])})}};class KF extends oM{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):en(r)&&a?l.push(...r.split(a)):l.push(r)));const c=V1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!en(r)?c:Xk(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),qF(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(en(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=V1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?cG(c,r,a):c={...c,...r},qF(this.data,l,c),o.silent||this.emit("added",e,n,r)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var uG={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 dG=Symbol("i18next/PATH_KEY");function $ie(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===dG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Yk(t,e){const{[dG]:n}=t($ie());return n.join(e?.keySeparator??".")}const XF={},JN=t=>!en(t)&&typeof t!="boolean"&&typeof t!="number";class W1 extends oM{constructor(e,n={}){super(),Pie(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=gl.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=JN(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&&!Bie(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:en(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:en(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=Yk(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,g=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return g?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const p=this.resolve(e,i);let x=p?.res;const y=p?.usedKey||l,b=p?.exactUsedKey||l,v=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!en(i.count),N=W1.hasDefaultValue(i),C=A?this.pluralResolver.getSuffix(f,i.count,i):"",T=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",O=A&&!i.ordinal&&i.count===0,k=O&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${T}`]||i.defaultValue;let R=x;w&&!x&&N&&(R=k);const z=JN(R),D=Object.prototype.toString.apply(R);if(w&&R&&z&&v.indexOf(D)<0&&!(en(E)&&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 K=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=K,p.usedParams=this.getUsedParamsDetails(i),p):K}if(o){const K=Array.isArray(R),P=K?[]:{},W=K?b:y;for(const Z in R)if(Object.prototype.hasOwnProperty.call(R,Z)){const G=`${W}${o}${Z}`;N&&!x?P[Z]=this.translate(G,{...i,defaultValue:JN(k)?k[Z]:void 0,joinArrays:!1,ns:c}):P[Z]=this.translate(G,{...i,joinArrays:!1,ns:c}),P[Z]===G&&(P[Z]=R[Z])}x=P}}else if(w&&en(E)&&Array.isArray(x))x=x.join(E),x&&(x=this.extendTranslation(x,e,i,r));else{let K=!1,P=!1;!this.isValidLookup(x)&&N&&(K=!0,x=k),this.isValidLookup(x)||(P=!0,x=l);const Z=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:x,G=N&&k!==x&&this.options.updateMissing;if(P||K||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,l,G?k:x),o){const F=this.resolve(l,{...i,keySeparator:!1});F&&F.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Y=[];const X=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&X&&X[0])for(let F=0;F<X.length;F++)Y.push(X[F]);else this.options.saveMissingTo==="all"?Y=this.languageUtils.toResolveHierarchy(i.lng||this.language):Y.push(i.lng||this.language);const q=(F,V,te)=>{const re=N&&te!==x?te:Z;this.options.missingKeyHandler?this.options.missingKeyHandler(F,u,V,re,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(F,u,V,re,G,i),this.emit("missingKey",F,u,V,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?Y.forEach(F=>{const V=this.pluralResolver.getSuffixes(F,i);O&&i[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(te=>{q([F],l+te,i[`defaultValue${te}`]||k)})}):q(Y,l,k))}x=this.extendTranslation(x,e,i,p,r),P&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(P||K)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,K?x:void 0,i))}return a?(p.res=x,p.usedParams=this.getUsedParamsDetails(i),p):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=en(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&&!en(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),g=f&&f.length;u<g&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=en(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=uG.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 en(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const g=n.count!==void 0&&!en(n.count),p=g&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(en(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!XF[`${y[0]}-${b}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(XF[`${y[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${y.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(v=>{if(this.isValidLookup(r))return;o=v;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,v,b,n);else{let A;g&&(A=this.pluralResolver.getSuffix(v,n.count,n));const N=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(g&&(n.ordinal&&A.indexOf(C)===0&&E.push(d+A.replace(C,this.options.pluralSeparator)),E.push(d+A),p&&E.push(d+N)),x){const T=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(T),g&&(n.ordinal&&A.indexOf(C)===0&&E.push(T+A.replace(C,this.options.pluralSeparator)),E.push(T+A),p&&E.push(T+N))}}let w;for(;w=E.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(v,b,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!en(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class YF{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=gl.create("languageUtils")}getScriptPartFromCode(e){if(e=L0(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=L0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(en(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)),en(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 en(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))):en(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const ZF={zero:0,one:1,two:2,few:3,many:4,other:5},QF={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Vie{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=gl.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=L0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),QF;if(!e.match(/-|_/))return QF;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[a]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,a)=>ZF[i]-ZF[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const JF=(t,e,n,r=".",i=!0)=>{let a=Oie(t,e,n);return!a&&i&&en(n)&&(a=Xk(t,n,r),a===void 0&&(a=Xk(e,n,r))),a},eA=t=>t.replace(/\$/g,"$$$$");class Gie{constructor(e={}){this.logger=gl.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:g,nestingPrefixEscaped:p,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:b,maxReplaces:v,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:Iie,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?mm(a):o||"{{",this.suffix=l?mm(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=g?mm(g):p||mm("$t("),this.nestingSuffix=x?mm(x):y||mm(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=v||1e3,this.alwaysFormat=E!==void 0?E:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,r,i){let a,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=p=>{if(p.indexOf(this.formatSeparator)<0){const v=JF(n,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,r,{...i,...n,interpolationkey:p}):v}const x=p.split(this.formatSeparator),y=x.shift().trim(),b=x.join(this.formatSeparator).trim();return this.format(JF(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>eA(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?eA(this.escape(p)):eA(p)}].forEach(p=>{for(l=0;a=p.regex.exec(e);){const x=a[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const b=d(e,a,i);o=en(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!en(o)&&!this.useRawValueToEscape&&(o=VF(o));const y=p.safeValue(o);if(e=e.replace(a[0],y),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=a[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let g=`{${f[1]}`;c=f[0],g=this.interpolate(g,o);const p=g.match(/'/g),x=g.match(/"/g);((p?.length??0)%2===0&&!x||x.length%2!==0)&&(g=g.replace(/'/g,'"'));try{o=JSON.parse(g),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${g}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!en(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&&!en(a))return a;en(a)||(a=VF(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const Wie=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[l,...c]=o.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},eU=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const o=r+JSON.stringify(a);let l=e[o];return l||(l=t(L0(r),i),e[o]=l),l(n)}},qie=t=>(e,n,r)=>t(L0(n),r)(e);class Kie{constructor(e={}){this.logger=gl.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?eU:qie;this.formats={number:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a});return l=>o.format(l)}),currency:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>o.format(l)}),datetime:r((i,a)=>{const o=new Intl.DateTimeFormat(i,{...a});return l=>o.format(l)}),relativetime:r((i,a)=>{const o=new Intl.RelativeTimeFormat(i,{...a});return l=>o.format(l,a.range||"day")}),list:r((i,a)=>{const o=new Intl.ListFormat(i,{...a});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=eU(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=Wie(c);if(this.formats[u]){let f=l;try{const g=i?.formatParams?.[i.interpolationkey]||{},p=g.locale||g.lng||i.locale||i.lng||r;f=this.formats[u](l,p,{...d,...i,...g})}catch(g){this.logger.warn(g)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const Xie=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Yie extends oM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=gl.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const g=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[g]=2:this.state[g]<0||(this.state[g]===1?o[g]===void 0&&(o[g]=!0):(this.state[g]=1,d=!1,o[g]===void 0&&(o[g]=!0),a[g]===void 0&&(a[g]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Die(c.loaded,[a],o),Xie(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();en(e)&&(e=this.languageUtils.toResolveHierarchy(e)),en(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const tU=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),en(t[1])&&(e.defaultValue=t[1]),en(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),nU=t=>(en(t.ns)&&(t.ns=[t.ns]),en(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),en(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),Rv=()=>{},Zie=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class f0 extends oM{constructor(e={},n){if(super(),this.options=nU(e),this.services={},this.logger=gl,this.modules={external:[]},Zie(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&&(en(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=tU();this.options={...r,...this.options,...nU(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?gl.init(i(this.modules.logger),this.options):gl.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Kie;const d=new YF(this.options);this.store=new KF(this.options.resources,this.options);const f=this.services;f.logger=gl,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new Vie(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 Gie(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Yie(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new W1(this.services,this.options),this.translator.on("*",(p,...x)=>{this.emit(p,...x)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Rv),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=Mx(),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=Rv){let r=n;const i=en(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=Mx();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=Rv),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"&&uG.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=Mx();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=en(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(en(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=Yk(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=Yk(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return en(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=Mx();return this.options.ns?(en(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=Mx();en(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new YF(tU());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new f0(e,n);return r.createInstance=f0.createInstance,r}cloneInstance(e={},n=Rv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new f0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new KF(l,i),a.services.resourceStore=a.store}return a.translator=new W1(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 Ga=f0.createInstance();Ga.createInstance;Ga.dir;Ga.init;Ga.loadResources;Ga.reloadResources;Ga.use;Ga.changeLanguage;Ga.getFixedT;Ga.t;Ga.exists;Ga.setDefaultNamespace;Ga.hasLoadedNamespace;Ga.loadNamespaces;Ga.loadLanguages;const Qie=(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);rf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},rU={},hG=(t,e,n,r)=>{rf(n)&&rU[n]||(rf(n)&&(rU[n]=new Date),Qie(t,e,n,r))},fG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},Zk=(t,e,n)=>{t.loadNamespaces(e,fG(t,n))},iU=(t,e,n,r)=>{if(rf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return Zk(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,fG(t,r))},Jie=(t,e,n={})=>!e.languages||!e.languages.length?(hG(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}}),rf=t=>typeof t=="string",eae=t=>typeof t=="object"&&t!==null,tae=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,nae={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},rae=t=>nae[t],iae=t=>t.replace(tae,rae);let Qk={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:iae};const aae=(t={})=>{Qk={...Qk,...t}},sae=()=>Qk;let mG;const oae=t=>{mG=t},lae=()=>mG,cae={type:"3rdParty",init(t){aae(t.options.react),oae(t)}},uae=S.createContext();class dae{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var tA={exports:{}},nA={};var aU;function hae(){if(aU)return nA;aU=1;var t=lg();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,g){var p=g(),x=r({inst:{value:p,getSnapshot:g}}),y=x[0].inst,b=x[1];return a(function(){y.value=p,y.getSnapshot=g,c(y)&&b({inst:y})},[f,p,g]),i(function(){return c(y)&&b({inst:y}),f(function(){c(y)&&b({inst:y})})},[f]),o(p),p}function c(f){var g=f.getSnapshot;f=f.value;try{var p=g();return!n(f,p)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return nA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,nA}var sU;function pG(){return sU||(sU=1,tA.exports=hae()),tA.exports}var sR=pG();const fae=(t,e)=>rf(e)?e:eae(e)&&rf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,mae={t:fae,ready:!1},pae=()=>()=>{},cg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=S.useContext(uae)||{},a=n||r||lae();a&&!a.reportNamespaces&&(a.reportNamespaces=new dae),a||hG(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=S.useMemo(()=>({...sae(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=rf(u)?[u]:u||["translation"],f=S.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const g=S.useRef(0),p=S.useCallback(k=>{if(!a)return pae;const{bindI18n:R,bindI18nStore:z}=o,D=()=>{g.current+=1,k()};return R&&a.on(R,D),z&&a.store.on(z,D),()=>{R&&R.split(" ").forEach(K=>a.off(K,D)),z&&z.split(" ").forEach(K=>a.store.off(K,D))}},[a,o]),x=S.useRef(),y=S.useCallback(()=>{if(!a)return mae;const k=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(W=>Jie(W,a,o)),R=e.lng||a.language,z=g.current,D=x.current;if(D&&D.ready===k&&D.lng===R&&D.keyPrefix===c&&D.revision===z)return D;const P={t:a.getFixedT(R,o.nsMode==="fallback"?f:f[0],c),ready:k,lng:R,keyPrefix:c,revision:z};return x.current=P,P},[a,f,c,o,e.lng]),[b,v]=S.useState(0),{t:E,ready:w}=sR.useSyncExternalStore(p,y,y);S.useEffect(()=>{if(a&&!w&&!l){const k=()=>v(R=>R+1);e.lng?iU(a,e.lng,f,k):Zk(a,f,k)}},[a,e.lng,f,w,l,b]);const A=a||{},N=S.useRef(null),C=S.useRef(),T=k=>{const R=Object.getOwnPropertyDescriptors(k);R.__original&&delete R.__original;const z=Object.create(Object.getPrototypeOf(k),R);if(!Object.prototype.hasOwnProperty.call(z,"__original"))try{Object.defineProperty(z,"__original",{value:k,writable:!1,enumerable:!1,configurable:!1})}catch{}return z},O=S.useMemo(()=>{const k=A,R=k?.language;let z=k;k&&(N.current&&N.current.__original===k?C.current!==R?(z=T(k),N.current=z,C.current=R):z=N.current:(z=T(k),N.current=z,C.current=R));const D=[E,z,w];return D.t=E,D.i18n=z,D.ready=w,D},[E,A,w,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!w)throw new Promise(k=>{const R=()=>k();e.lng?iU(a,e.lng,f,R):Zk(a,f,R)});return O},{slice:gae,forEach:xae}=[];function bae(t){return xae.call(gae.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function yae(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(n=>n.test(t))}const oU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,vae=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!oU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!oU.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},lU={create(t,e,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=vae(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 _ae={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return lU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&lU.create(n,t,r,i,a)}},wae={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}},Sae={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 pm=null;const cU=()=>{if(pm!==null)return pm;try{if(pm=typeof window<"u"&&window.localStorage!==null,!pm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{pm=!1}return pm};var Mae={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&cU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&cU()&&window.localStorage.setItem(n,t)}};let gm=null;const uU=()=>{if(gm!==null)return gm;try{if(gm=typeof window<"u"&&window.sessionStorage!==null,!gm)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{gm=!1}return gm};var Eae={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&uU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&uU()&&window.sessionStorage.setItem(n,t)}},Nae={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}},Aae={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}},Tae={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}},Cae={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 gG=!1;try{document.cookie,gG=!0}catch{}const xG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];gG||xG.splice(1,1);const kae=()=>({order:xG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class bG{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=bae(n,this.options||{},kae()),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(_ae),this.addDetector(wae),this.addDetector(Mae),this.addDetector(Eae),this.addDetector(Nae),this.addDetector(Aae),this.addDetector(Tae),this.addDetector(Cae),this.addDetector(Sae)}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&&!yae(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)}))}}bG.type="languageDetector";const jae={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app, which versions and printer models are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"Printer model types (e.g., X1C, P1S) - not names or serial numbers",telemetryInfoItem4:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"Your IP address is hashed and cannot be reversed",telemetryInfoNotItem2:"Printer names, serial numbers, or access codes",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},Pae={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",settings:"Einstellungen",system:"System",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},Rae={en:{translation:jae},de:{translation:Pae}};Ga.use(bG).use(cae).init({resources:Rae,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const dU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var hU="popstate";function Dae(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return Jk("",{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:I0(i)}return Lae(e,n,null,t)}function Or(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Go(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Oae(){return Math.random().toString(36).substring(2,10)}function fU(t,e){return{usr:t.state,key:t.key,idx:e}}function Jk(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?ug(e):e,state:n,key:e&&e.key||r||Oae()}}function I0({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 ug(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 Lae(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let b=d(),v=b==null?null:b-u;u=b,c&&c({action:l,location:y.location,delta:v})}function g(b,v){l="PUSH";let E=Jk(y.location,b,v);u=d()+1;let w=fU(E,u),A=y.createHref(E);try{o.pushState(w,"",A)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;i.location.assign(A)}a&&c&&c({action:l,location:y.location,delta:1})}function p(b,v){l="REPLACE";let E=Jk(y.location,b,v);u=d();let w=fU(E,u),A=y.createHref(E);o.replaceState(w,"",A),a&&c&&c({action:l,location:y.location,delta:0})}function x(b){return Iae(b)}let y={get action(){return l},get location(){return t(i,o)},listen(b){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(hU,f),c=b,()=>{i.removeEventListener(hU,f),c=null}},createHref(b){return e(i,b)},createURL:x,encodeLocation(b){let v=x(b);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:g,replace:p,go(b){return o.go(b)}};return y}function Iae(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Or(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:I0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function yG(t,e,n="/"){return Fae(t,e,n,!1)}function Fae(t,e,n,r){let i=typeof e=="string"?ug(e):e,a=Vc(i.pathname||"/",n);if(a==null)return null;let o=vG(t);Uae(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=Yae(a);l=Kae(o[c],u,r)}return l}function vG(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;Or(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=Oc([r,d.relativePath]),g=n.concat(d);o.children&&o.children.length>0&&(Or(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),vG(o.children,e,g,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:Wae(f,o.index),routesMeta:g})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of _G(o.path))a(o,l,!0,c)}),e}function _G(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=_G(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 Uae(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:qae(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var zae=/^:[\w-]+$/,Bae=3,Hae=2,$ae=1,Vae=10,Gae=-2,mU=t=>t==="*";function Wae(t,e){let n=t.split("/"),r=n.length;return n.some(mU)&&(r+=Gae),e&&(r+=Hae),n.filter(i=>!mU(i)).reduce((i,a)=>i+(zae.test(a)?Bae:a===""?$ae:Vae),r)}function qae(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 Kae(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=q1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),g=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=q1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Oc([a,f.pathname]),pathnameBase:tse(Oc([a,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(a=Oc([a,f.pathnameBase]))}return o}function q1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=Xae(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},g)=>{if(d==="*"){let x=l[g]||"";o=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const p=l[g];return f&&!p?u[d]=void 0:u[d]=(p||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function Xae(t,e=!1,n=!0){Go(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function Yae(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Go(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function Vc(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 Zae=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Qae=t=>Zae.test(t);function Jae(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?ug(t):t,a;if(n)if(Qae(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Go(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=pU(n.substring(1),"/"):a=pU(n,e)}else a=e;return{pathname:a,search:nse(r),hash:rse(i)}}function pU(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function rA(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 ese(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function wG(t){let e=ese(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function SG(t,e,n,r=!1){let i;typeof t=="string"?i=ug(t):(i={...t},Or(!i.pathname||!i.pathname.includes("?"),rA("?","pathname","search",i)),Or(!i.pathname||!i.pathname.includes("#"),rA("#","pathname","hash",i)),Or(!i.search||!i.search.includes("#"),rA("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let g=o.split("/");for(;g[0]==="..";)g.shift(),f-=1;i.pathname=g.join("/")}l=f>=0?e[f]:"/"}let c=Jae(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Oc=t=>t.join("/").replace(/\/\/+/g,"/"),tse=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),nse=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,rse=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function ise(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var MG=["POST","PUT","PATCH","DELETE"];new Set(MG);var ase=["GET",...MG];new Set(ase);var dg=S.createContext(null);dg.displayName="DataRouter";var lM=S.createContext(null);lM.displayName="DataRouterState";S.createContext(!1);var EG=S.createContext({isTransitioning:!1});EG.displayName="ViewTransition";var sse=S.createContext(new Map);sse.displayName="Fetchers";var ose=S.createContext(null);ose.displayName="Await";var Dl=S.createContext(null);Dl.displayName="Navigation";var jb=S.createContext(null);jb.displayName="Location";var Yo=S.createContext({outlet:null,matches:[],isDataRoute:!1});Yo.displayName="Route";var oR=S.createContext(null);oR.displayName="RouteError";function lse(t,{relative:e}={}){Or(Pb(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=S.useContext(Dl),{hash:i,pathname:a,search:o}=Db(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Oc([n,a])),r.createHref({pathname:l,search:o,hash:i})}function Pb(){return S.useContext(jb)!=null}function Ud(){return Or(Pb(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(jb).location}var NG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function AG(t){S.useContext(Dl).static||S.useLayoutEffect(t)}function Rb(){let{isDataRoute:t}=S.useContext(Yo);return t?Sse():cse()}function cse(){Or(Pb(),"useNavigate() may be used only in the context of a <Router> component.");let t=S.useContext(dg),{basename:e,navigator:n}=S.useContext(Dl),{matches:r}=S.useContext(Yo),{pathname:i}=Ud(),a=JSON.stringify(wG(r)),o=S.useRef(!1);return AG(()=>{o.current=!0}),S.useCallback((c,u={})=>{if(Go(o.current,NG),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=SG(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Oc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var use=S.createContext(null);function dse(t){let e=S.useContext(Yo).outlet;return S.useMemo(()=>e&&S.createElement(use.Provider,{value:t},e),[e,t])}function lR(){let{matches:t}=S.useContext(Yo),e=t[t.length-1];return e?e.params:{}}function Db(t,{relative:e}={}){let{matches:n}=S.useContext(Yo),{pathname:r}=Ud(),i=JSON.stringify(wG(n));return S.useMemo(()=>SG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function hse(t,e){return TG(t,e)}function TG(t,e,n,r,i){Or(Pb(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=S.useContext(Dl),{matches:o}=S.useContext(Yo),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let E=f&&f.path||"";CG(u,!f||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${E}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let g=Ud(),p;if(e){let E=typeof e=="string"?ug(e):e;Or(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),p=E}else p=g;let x=p.pathname||"/",y=x;if(d!=="/"){let E=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let b=yG(t,{pathname:y});Go(f||b!=null,`No routes matched location "${p.pathname}${p.search}${p.hash}" `),Go(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.length-1].route.lazy!==void 0,`Matched leaf route at location "${p.pathname}${p.search}${p.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let v=xse(b&&b.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:Oc([d,a.encodeLocation?a.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:Oc([d,a.encodeLocation?a.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),o,n,r,i);return e&&v?S.createElement(jb.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...p},navigationType:"POP"}},v):v}function fse(){let t=wse(),e=ise(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=S.createElement(S.Fragment,null,S.createElement("p",null,"💿 Hey developer 👋"),S.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",S.createElement("code",{style:a},"ErrorBoundary")," or"," ",S.createElement("code",{style:a},"errorElement")," prop on your route.")),S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},e),n?S.createElement("pre",{style:i},n):null,o)}var mse=S.createElement(fse,null),pse=class extends S.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?S.createElement(Yo.Provider,{value:this.props.routeContext},S.createElement(oR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function gse({routeContext:t,match:e,children:n}){let r=S.useContext(dg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),S.createElement(Yo.Provider,{value:t},n)}function xse(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);Or(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:g,errors:p}=n,x=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!p||p[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,g)=>{let p,x=!1,y=null,b=null;n&&(p=o&&f.route.id?o[f.route.id]:void 0,y=f.route.errorElement||mse,l&&(c<0&&g===0?(CG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,b=null):c===g&&(x=!0,b=f.route.hydrateFallbackElement||null)));let v=e.concat(a.slice(0,g+1)),E=()=>{let w;return p?w=y:x?w=b:f.route.Component?w=S.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,S.createElement(gse,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?S.createElement(pse,{location:n.location,revalidation:n.revalidation,component:y,error:p,children:E(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:u}):E()},null)}function cR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bse(t){let e=S.useContext(dg);return Or(e,cR(t)),e}function yse(t){let e=S.useContext(lM);return Or(e,cR(t)),e}function vse(t){let e=S.useContext(Yo);return Or(e,cR(t)),e}function uR(t){let e=vse(t),n=e.matches[e.matches.length-1];return Or(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function _se(){return uR("useRouteId")}function wse(){let t=S.useContext(oR),e=yse("useRouteError"),n=uR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Sse(){let{router:t}=bse("useNavigate"),e=uR("useNavigate"),n=S.useRef(!1);return AG(()=>{n.current=!0}),S.useCallback(async(i,a={})=>{Go(n.current,NG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var gU={};function CG(t,e,n){!e&&!gU[t]&&(gU[t]=!0,Go(!1,n))}S.memo(Mse);function Mse({routes:t,future:e,state:n,unstable_onError:r}){return TG(t,void 0,n,r,e)}function Ese(t){return dse(t.context)}function es(t){Or(!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 Nse({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Or(!Pb(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let o=t.replace(/^\/*/,"/"),l=S.useMemo(()=>({basename:o,navigator:i,static:a,future:{}}),[o,i,a]);typeof n=="string"&&(n=ug(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:g="default"}=n,p=S.useMemo(()=>{let x=Vc(c,o);return x==null?null:{location:{pathname:x,search:u,hash:d,state:f,key:g},navigationType:r}},[o,c,u,d,f,g,r]);return Go(p!=null,`<Router basename="${o}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:S.createElement(Dl.Provider,{value:l},S.createElement(jb.Provider,{children:e,value:p}))}function Ase({children:t,location:e}){return hse(e3(t),e)}function e3(t,e=[]){let n=[];return S.Children.forEach(t,(r,i)=>{if(!S.isValidElement(r))return;let a=[...e,i];if(r.type===S.Fragment){n.push.apply(n,e3(r.props.children,a));return}Or(r.type===es,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Or(!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=e3(r.props.children,a)),n.push(o)}),n}var x1="get",b1="application/x-www-form-urlencoded";function cM(t){return t!=null&&typeof t.tagName=="string"}function Tse(t){return cM(t)&&t.tagName.toLowerCase()==="button"}function Cse(t){return cM(t)&&t.tagName.toLowerCase()==="form"}function kse(t){return cM(t)&&t.tagName.toLowerCase()==="input"}function jse(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Pse(t,e){return t.button===0&&(!e||e==="_self")&&!jse(t)}var Dv=null;function Rse(){if(Dv===null)try{new FormData(document.createElement("form"),0),Dv=!1}catch{Dv=!0}return Dv}var Dse=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function iA(t){return t!=null&&!Dse.has(t)?(Go(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${b1}"`),null):t}function Ose(t,e){let n,r,i,a,o;if(Cse(t)){let l=t.getAttribute("action");r=l?Vc(l,e):null,n=t.getAttribute("method")||x1,i=iA(t.getAttribute("enctype"))||b1,a=new FormData(t)}else if(Tse(t)||kse(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?Vc(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||x1,i=iA(t.getAttribute("formenctype"))||iA(l.getAttribute("enctype"))||b1,a=new FormData(l,t),!Rse()){let{name:u,type:d,value:f}=t;if(d==="image"){let g=u?`${u}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else u&&a.append(u,f)}}else{if(cM(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=x1,r=null,i=b1,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 dR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Lse(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&Vc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Ise(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 Fse(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 Use(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await Ise(a,n);return o.links?o.links():[]}return[]}));return $se(r.flat(1).filter(Fse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function xU(t,e,n,r,i,a){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function zse(t,e,{includeHydrateFallback:n}={}){return Bse(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 Bse(t){return[...new Set(t)]}function Hse(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function $se(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(Hse(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function kG(){let t=S.useContext(dg);return dR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Vse(){let t=S.useContext(lM);return dR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var hR=S.createContext(void 0);hR.displayName="FrameworkContext";function jG(){let t=S.useContext(hR);return dR(t,"You must render this element inside a <HydratedRouter> element"),t}function Gse(t,e){let n=S.useContext(hR),[r,i]=S.useState(!1),[a,o]=S.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,g=S.useRef(null);S.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=v=>{v.forEach(E=>{o(E.isIntersecting)})},b=new IntersectionObserver(y,{threshold:.5});return g.current&&b.observe(g.current),()=>{b.disconnect()}}},[t]),S.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let p=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,g,{}]:[a,g,{onFocus:Ex(l,p),onBlur:Ex(c,x),onMouseEnter:Ex(u,p),onMouseLeave:Ex(d,x),onTouchStart:Ex(f,p)}]:[!1,g,{}]}function Ex(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Wse({page:t,...e}){let{router:n}=kG(),r=S.useMemo(()=>yG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?S.createElement(Kse,{page:t,matches:r,...e}):null}function qse(t){let{manifest:e,routeModules:n}=jG(),[r,i]=S.useState([]);return S.useEffect(()=>{let a=!1;return Use(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function Kse({page:t,matches:e,...n}){let r=Ud(),{manifest:i,routeModules:a}=jG(),{basename:o}=kG(),{loaderData:l,matches:c}=Vse(),u=S.useMemo(()=>xU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=S.useMemo(()=>xU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=S.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let x=new Set,y=!1;if(e.forEach(v=>{let E=i.routes[v.route.id];!E||!E.hasLoader||(!u.some(w=>w.route.id===v.route.id)&&v.route.id in l&&a[v.route.id]?.shouldRevalidate||E.hasClientLoader?y=!0:x.add(v.route.id))}),x.size===0)return[];let b=Lse(t,o,"data");return y&&x.size>0&&b.searchParams.set("_routes",e.filter(v=>x.has(v.route.id)).map(v=>v.route.id).join(",")),[b.pathname+b.search]},[o,l,r,i,u,e,t,a]),g=S.useMemo(()=>zse(d,i),[d,i]),p=qse(d);return S.createElement(S.Fragment,null,f.map(x=>S.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),g.map(x=>S.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),p.map(({key:x,link:y})=>S.createElement("link",{key:x,nonce:n.nonce,...y})))}function Xse(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var PG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{PG&&(window.__reactRouterVersion="7.9.6")}catch{}function Yse({basename:t,children:e,window:n}){let r=S.useRef();r.current==null&&(r.current=Dae({window:n,v5Compat:!0}));let i=r.current,[a,o]=S.useState({action:i.action,location:i.location}),l=S.useCallback(c=>{S.startTransition(()=>o(c))},[o]);return S.useLayoutEffect(()=>i.listen(l),[i,l]),S.createElement(Nse,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var RG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ac=S.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,...g},p){let{basename:x}=S.useContext(Dl),y=typeof u=="string"&&RG.test(u),b,v=!1;if(typeof u=="string"&&y&&(b=u,PG))try{let k=new URL(window.location.href),R=u.startsWith("//")?new URL(k.protocol+u):new URL(u),z=Vc(R.pathname,x);R.origin===k.origin&&z!=null?u=z+R.search+R.hash:v=!0}catch{Go(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=lse(u,{relative:i}),[w,A,N]=Gse(r,g),C=Jse(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f});function T(k){e&&e(k),k.defaultPrevented||C(k)}let O=S.createElement("a",{...g,...N,href:b||E,onClick:v||a?e:T,ref:Xse(p,A),target:c,"data-discover":!y&&n==="render"?"true":void 0});return w&&!y?S.createElement(S.Fragment,null,O,S.createElement(Wse,{page:E})):O});Ac.displayName="Link";var Qx=S.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=Db(o,{relative:u.relative}),g=Ud(),p=S.useContext(lM),{navigator:x,basename:y}=S.useContext(Dl),b=p!=null&&ioe(f)&&l===!0,v=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,E=g.pathname,w=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;n||(E=E.toLowerCase(),w=w?w.toLowerCase():null,v=v.toLowerCase()),w&&y&&(w=Vc(w,y)||w);const A=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let N=E===v||!i&&E.startsWith(v)&&E.charAt(A)==="/",C=w!=null&&(w===v||!i&&w.startsWith(v)&&w.charAt(v.length)==="/"),T={isActive:N,isPending:C,isTransitioning:b},O=N?e:void 0,k;typeof r=="function"?k=r(T):k=[r,N?"active":null,C?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let R=typeof a=="function"?a(T):a;return S.createElement(Ac,{...u,"aria-current":O,className:k,ref:d,style:R,to:o,viewTransition:l},typeof c=="function"?c(T):c)});Qx.displayName="NavLink";var Zse=S.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=x1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...g},p)=>{let x=noe(),y=roe(l,{relative:u}),b=o.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&RG.test(l),E=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,N=A?.getAttribute("formmethod")||o;x(A||w.currentTarget,{fetcherKey:e,method:N,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return S.createElement("form",{ref:p,method:b,action:y,onSubmit:r?c:E,...g,"data-discover":!v&&t==="render"?"true":void 0})});Zse.displayName="Form";function Qse(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function DG(t){let e=S.useContext(dg);return Or(e,Qse(t)),e}function Jse(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o}={}){let l=Rb(),c=Ud(),u=Db(t,{relative:a});return S.useCallback(d=>{if(Pse(d,e)){d.preventDefault();let f=n!==void 0?n:I0(c)===I0(u);l(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:o})}},[c,l,u,n,r,e,t,i,a,o])}var eoe=0,toe=()=>`__${String(++eoe)}__`;function noe(){let{router:t}=DG("useSubmit"),{basename:e}=S.useContext(Dl),n=_se();return S.useCallback(async(r,i={})=>{let{action:a,method:o,encType:l,formData:c,body:u}=Ose(r,e);if(i.navigate===!1){let d=i.fetcherKey||toe();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function roe(t,{relative:e}={}){let{basename:n}=S.useContext(Dl),r=S.useContext(Yo);Or(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Db(t||".",{relative:e})},o=Ud();if(t==null){a.search=o.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Oc([n,a.pathname])),I0(a)}function ioe(t,{relative:e}={}){let n=S.useContext(EG);Or(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=DG("useViewTransitionState"),i=Db(t,{relative:e});if(!n.isTransitioning)return!1;let a=Vc(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Vc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return q1(i.pathname,o)!=null||q1(i.pathname,a)!=null}var Tc=lG();const aoe=_o(Tc);var hg=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(){}},soe={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},ooe=class{#e=soe;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Rh=new ooe;function loe(t){setTimeout(t,0)}var af=typeof window>"u"||"Deno"in globalThis;function Oa(){}function coe(t,e){return typeof t=="function"?t(e):t}function t3(t){return typeof t=="number"&&t>=0&&t!==1/0}function OG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function hd(t,e){return typeof t=="function"?t(e):t}function to(t,e){return typeof t=="function"?t(e):t}function bU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==fR(o,e.options))return!1}else if(!F0(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||a&&!a(e))}function yU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(sf(e.options.mutationKey)!==sf(a))return!1}else if(!F0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function fR(t,e){return(e?.queryKeyHashFn||sf)(t)}function sf(t){return JSON.stringify(t,(e,n)=>n3(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function F0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>F0(t[n],e[n])):!1}var uoe=Object.prototype.hasOwnProperty;function LG(t,e){if(t===e)return t;const n=vU(t)&&vU(e);if(!n&&!(n3(t)&&n3(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:a[u],f=t[d],g=e[d];if(f===g){l[d]=f,(n?u<i:uoe.call(t,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){l[d]=g;continue}const p=LG(f,g);l[d]=p,p===f&&c++}return i===o&&c===i?t:l}function K1(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function vU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function n3(t){if(!_U(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!_U(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function _U(t){return Object.prototype.toString.call(t)==="[object Object]"}function doe(t){return new Promise(e=>{Rh.setTimeout(e,t)})}function r3(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?LG(t,e):e}function hoe(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function foe(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var mR=Symbol();function IG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===mR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function FG(t,e){return typeof t=="function"?t(...e):!!t}var moe=class extends hg{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!af&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},pR=new moe;function i3(){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 poe=loe;function goe(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=poe;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=goe(),xoe=class extends hg{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!af&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},X1=new xoe;function boe(t){return Math.min(1e3*2**t,3e4)}function UG(t){return(t??"online")==="online"?X1.isOnline():!0}var a3=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function zG(t){let e=!1,n=0,r;const i=i3(),a=()=>i.status!=="pending",o=y=>{if(!a()){const b=new a3(y);g(b),t.onCancel?.(b)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>pR.isFocused()&&(t.networkMode==="always"||X1.isOnline())&&t.canRun(),d=()=>UG(t.networkMode)&&t.canRun(),f=y=>{a()||(r?.(),i.resolve(y))},g=y=>{a()||(r?.(),i.reject(y))},p=()=>new Promise(y=>{r=b=>{(a()||u())&&y(b)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let y;const b=n===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(v){y=Promise.reject(v)}Promise.resolve(y).then(f).catch(v=>{if(a())return;const E=t.retry??(af?0:3),w=t.retryDelay??boe,A=typeof w=="function"?w(n,v):w,N=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,v);if(e||!N){g(v);return}n++,t.onFail?.(n,v),doe(A).then(()=>u()?void 0:p()).then(()=>{e?g(v):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():p().then(x),i)}}var BG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),t3(this.gcTime)&&(this.#e=Rh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(af?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Rh.clearTimeout(this.#e),this.#e=void 0)}},yoe=class extends BG{#e;#t;#n;#i;#r;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=SU(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=SU(this.options);e.data!==void 0&&(this.setState(wU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=r3(this.state.data,t,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#a({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(Oa).catch(Oa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>to(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===mR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>hd(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:!OG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=IG(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},o=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#a({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=zG({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof a3&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#a({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof a3){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#a({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...HG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...wU(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),Si.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function HG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:UG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function wU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function SU(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var voe=class extends hg{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=i3(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),MU(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return s3(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return s3(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof to(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),e._defaulted&&!K1(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&EU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||to(this.options.enabled,this.#t)!==to(e.enabled,this.#t)||hd(this.options.staleTime,this.#t)!==hd(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||to(this.options.enabled,this.#t)!==to(e.enabled,this.#t)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return woe(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#d(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Oa)),e}#g(){this.#v();const t=hd(this.options.staleTime,this.#t);if(af||this.#i.isStale||!t3(t))return;const n=OG(this.#i.dataUpdatedAt,t)+1;this.#c=Rh.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(af||to(this.options.enabled,this.#t)===!1||!t3(this.#l)||this.#l===0)&&(this.#u=Rh.setInterval(()=>{(this.options.refetchIntervalInBackground||pR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Rh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Rh.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,a=this.#r,o=this.#s,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,g;if(e._optimisticResults){const O=this.hasListeners(),k=!O&&MU(t,e),R=O&&EU(t,n,e,r);(k||R)&&(d={...d,...HG(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:x,status:y}=d;g=d.data;let b=!1;if(e.placeholderData!==void 0&&g===void 0&&y==="pending"){let O;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(O=i.data,b=!0):O=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,O!==void 0&&(y="success",g=r3(i?.data,O,e),f=!0)}if(e.select&&g!==void 0&&!b)if(i&&g===a?.data&&e.select===this.#p)g=this.#h;else try{this.#p=e.select,g=e.select(g),g=r3(i?.data,g,e),this.#h=g,this.#a=null}catch(O){this.#a=O}this.#a&&(p=this.#a,g=this.#h,x=Date.now(),y="error");const v=d.fetchStatus==="fetching",E=y==="pending",w=y==="error",A=E&&v,N=g!==void 0,T={status:y,fetchStatus:d.fetchStatus,isPending:E,isSuccess:y==="success",isError:w,isInitialLoading:A,isLoading:A,data:g,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:v,isRefetching:v&&!E,isLoadingError:w&&!N,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&N,isStale:gR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:to(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=z=>{T.status==="error"?z.reject(T.error):T.data!==void 0&&z.resolve(T.data)},k=()=>{const z=this.#o=T.promise=i3();O(z)},R=this.#o;switch(R.status){case"pending":t.queryHash===n.queryHash&&O(R);break;case"fulfilled":(T.status==="error"||T.data!==R.value)&&k();break;case"rejected":(T.status!=="error"||T.error!==R.reason)&&k();break}}return T}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#s=this.options,this.#r.data!==void 0&&(this.#f=this.#t),K1(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const a=new Set(i??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#w(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(t){Si.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function _oe(t,e){return to(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function MU(t,e){return _oe(t,e)||t.state.data!==void 0&&s3(t,e,e.refetchOnMount)}function s3(t,e,n){if(to(e.enabled,t)!==!1&&hd(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&gR(t,e)}return!1}function EU(t,e,n,r){return(t!==e||to(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&gR(t,n)}function gR(t,e){return to(e.enabled,t)!==!1&&t.isStaleByTime(hd(e.staleTime,t))}function woe(t,e){return!K1(t.getCurrentResult(),e)}function NU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=IG(e.options,e.fetchOptions),p=async(x,y,b)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const E=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return f(C),C})(),w=await g(E),{maxPages:A}=e.options,N=b?foe:hoe;return{pages:N(x.pages,w,A),pageParams:N(x.pageParams,y,A)}};if(i&&a.length){const x=i==="backward",y=x?Soe:AU,b={pages:a,pageParams:o},v=y(r,b);l=await p(b,v,x)}else{const x=t??a.length;do{const y=c===0?o[0]??r.initialPageParam:AU(r,l);if(c>0&&y==null)break;l=await p(l,y),c++}while(c<x)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function AU(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 Soe(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Moe=class extends BG{#e;#t;#n;#i;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||$G(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=zG({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,variables:t,isPaused:i})}const a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),Si.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function $G(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Eoe=class extends hg{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const r=new Moe({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=Ov(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=Ov(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Ov(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=Ov(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Si.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>yU(e,n))}findAll(t={}){return this.getAll().filter(e=>yU(t,e))}notify(t){Si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Si.batch(()=>Promise.all(t.map(e=>e.continue().catch(Oa))))}};function Ov(t){return t.options.scope?.id}var Noe=class extends hg{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),K1(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&sf(n.mutationKey)!==sf(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#s()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??$G();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){Si.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},Aoe=class extends hg{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??fR(r,e);let a=this.get(i);return a||(a=new yoe({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Si.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>bU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>bU(t,n)):e}notify(t){Si.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Si.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Si.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Toe=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new Aoe,this.#t=t.mutationCache||new Eoe,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=pR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=X1.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(hd(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#e.get(r.queryHash)?.state.data,o=coe(e,a);if(o!==void 0)return this.#e.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Si.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;Si.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return Si.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Si.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Oa).catch(Oa)}invalidateQueries(t,e={}){return Si.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},r=Si.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Oa)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Oa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(hd(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Oa).catch(Oa)}fetchInfiniteQuery(t){return t.behavior=NU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Oa).catch(Oa)}ensureInfiniteQueryData(t){return t.behavior=NU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return X1.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(sf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{F0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(sf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{F0(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=fR(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===mR&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},VG=S.createContext(void 0),ln=t=>{const e=S.useContext(VG);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Coe=({client:t,children:e})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(VG.Provider,{value:t,children:e})),GG=S.createContext(!1),koe=()=>S.useContext(GG);GG.Provider;function joe(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Poe=S.createContext(joe()),Roe=()=>S.useContext(Poe),Doe=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Ooe=t=>{S.useEffect(()=>{t.clearReset()},[t])},Loe=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||FG(n,[t.error,r])),Ioe=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))}},Foe=(t,e)=>t.isLoading&&t.isFetching&&!e,Uoe=(t,e)=>t?.suspense&&e.isPending,TU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function zoe(t,e,n){const r=koe(),i=Roe(),a=ln(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",Ioe(o),Doe(o,i),Ooe(i);const l=!a.getQueryCache().get(o.queryHash),[c]=S.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(f=>{const g=d?c.subscribe(Si.batchCalls(f)):Oa;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),S.useEffect(()=>{c.setOptions(o)},[o,c]),Uoe(o,u))throw TU(o,c,i);if(Loe({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!af&&Foe(u,r)&&(l?TU(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Oa).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function ht(t,e){return zoe(t,voe)}function xt(t,e){const n=ln(),[r]=S.useState(()=>new Noe(n,t));S.useEffect(()=>{r.setOptions(t)},[r,t]);const i=S.useSyncExternalStore(S.useCallback(o=>r.subscribe(Si.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=S.useCallback((o,l)=>{r.mutate(o,l).catch(Oa)},[r]);if(i.error&&FG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const Boe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Hoe=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),CU=t=>{const e=Hoe(t);return e.charAt(0).toUpperCase()+e.slice(1)},WG=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),$oe=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Voe={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 Goe=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>S.createElement("svg",{ref:c,...Voe,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:WG("lucide",i),...!a&&!$oe(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>S.createElement(u,d)),...Array.isArray(a)?a:[a]]));const We=(t,e)=>{const n=S.forwardRef(({className:r,...i},a)=>S.createElement(Goe,{ref:a,iconNode:e,className:WG(`lucide-${Boe(CU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=CU(t),n};const Woe=[["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"}]],qoe=We("air-vent",Woe);const Koe=[["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"}]],Ho=We("archive",Koe);const Xoe=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],U0=We("arrow-down",Xoe);const Yoe=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Zoe=We("arrow-left",Yoe);const Qoe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],o3=We("arrow-right",Qoe);const Joe=[["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"}]],ele=We("arrow-up-down",Joe);const tle=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],kp=We("arrow-up",tle);const nle=[["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"}]],$h=We("bell",nle);const rle=[["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"}]],ile=We("bold",rle);const ale=[["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"}]],sle=We("book",ale);const ole=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],lle=We("bookmark",ole);const cle=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],vl=We("box",cle);const ule=[["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"}]],qG=We("bug",ule);const dle=[["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"}]],hle=We("cable",dle);const fle=[["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"}]],mle=We("calendar-days",fle);const ple=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Wr=We("calendar",ple);const gle=[["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"}]],jp=We("camera",gle);const xle=[["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"}]],ble=We("chart-column",xle);const yle=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ds=We("check",yle);const vle=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Aa=We("chevron-down",vle);const _le=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Zo=We("chevron-right",_le);const wle=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],of=We("chevron-left",wle);const Sle=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],zd=We("chevron-up",Sle);const Mle=[["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"}]],Na=We("circle-alert",Mle);const Ele=[["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"}]],aA=We("circle-arrow-up",Ele);const Nle=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],kr=We("circle-check-big",Nle);const Ale=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Y1=We("circle-check",Ale);const Tle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Cle=We("circle-dot",Tle);const kle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],jle=We("circle-stop",kle);const Ple=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Sa=We("circle-x",Ple);const Rle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],z0=We("circle",Rle);const Dle=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ur=We("clock",Dle);const Ole=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],uM=We("cloud",Ole);const Lle=[["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"}]],Ile=We("code-xml",Lle);const Fle=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],KG=We("code",Fle);const Ule=[["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"}]],zle=We("coffee",Ule);const Ble=[["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"}]],Hle=We("cog",Ble);const $le=[["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"}]],Vle=We("compass",$le);const Gle=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Wo=We("copy",Gle);const Wle=[["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"}]],Lv=We("cpu",Wle);const qle=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Kle=We("cylinder",qle);const Xle=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Pp=We("database",Xle);const Yle=[["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"}]],l3=We("dollar-sign",Yle);const Zle=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Mi=We("download",Zle);const Qle=[["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"}]],xR=We("droplet",Qle);const Jle=[["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"}]],bR=We("droplets",Jle);const ece=[["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"}]],gp=We("ellipsis-vertical",ece);const tce=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],sA=We("equal",tce);const nce=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],qr=We("external-link",nce);const rce=[["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"}]],dM=We("eye-off",rce);const ice=[["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"}]],lf=We("eye",ice);const ace=[["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"}]],XG=We("fan",ace);const sce=[["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"}]],YG=We("file-box",sce);const oce=[["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"}]],Z1=We("file-code",oce);const lce=[["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"}]],cce=We("file-exclamation-point",lce);const uce=[["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"}]],Q1=We("file-spreadsheet",uce);const dce=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],is=We("file-text",dce);const hce=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],yR=We("file",hce);const fce=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],fd=We("film",fce);const mce=[["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"}]],pce=We("flame",mce);const gce=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],ha=We("folder-kanban",gce);const xce=[["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"}]],bce=We("folder-open",xce);const yce=[["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"}]],vce=We("folder-tree",yce);const _ce=[["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"}]],ZG=We("folder",_ce);const wce=[["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"}]],vR=We("funnel",wce);const Sce=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],hM=We("gauge",Sce);const Mce=[["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"}]],Ece=We("gift",Mce);const Nce=[["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"}]],xp=We("git-compare",Nce);const Ace=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],kU=We("github",Ace);const Tce=[["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"}]],cf=We("globe",Tce);const Cce=[["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"}]],B0=We("grip-vertical",Cce);const kce=[["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"}]],_R=We("hand",kce);const jce=[["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"}]],wR=We("hard-drive",jce);const Pce=[["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"}]],Rce=We("hash",Pce);const Dce=[["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"}]],Oce=We("headphones",Dce);const Lce=[["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"}]],Ice=We("heart",Lce);const Fce=[["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"}]],J1=We("history",Fce);const Uce=[["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"}]],zce=We("house",Uce);const Bce=[["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"}]],Ob=We("image",Bce);const Hce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Sd=We("info",Hce);const $ce=[["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"}]],Vce=We("italic",$ce);const Gce=[["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"}]],Dh=We("key",Gce);const Wce=[["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"}]],c3=We("keyboard",Wce);const qce=[["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"}]],Md=We("layers",qce);const Kce=[["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"}]],SR=We("layout-grid",Kce);const Xce=[["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"}]],Yce=We("link-2-off",Xce);const Zce=[["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"}]],Rp=We("link-2",Zce);const Qce=[["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"}]],Lb=We("link",Qce);const Jce=[["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"}]],QG=We("list-ordered",Jce);const eue=[["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"}]],u3=We("list-todo",eue);const tue=[["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"}]],MR=We("list",tue);const nue=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],gt=We("loader-circle",nue);const rue=[["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"}]],jU=We("log-in",rue);const iue=[["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"}]],aue=We("log-out",iue);const sue=[["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"}]],oue=We("mail",sue);const lue=[["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"}]],cue=We("map",lue);const uue=[["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"}]],due=We("maximize-2",uue);const hue=[["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"}]],fue=We("maximize",hue);const mue=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],pue=We("memory-stick",mue);const gue=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],xue=We("menu",gue);const bue=[["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"}]],yue=We("minimize-2",bue);const vue=[["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"}]],_ue=We("minimize",vue);const wue=[["path",{d:"M5 12h14",key:"1ays0h"}]],d3=We("minus",wue);const Sue=[["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"}]],Mue=We("monitor",Sue);const Eue=[["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"}]],ew=We("moon",Eue);const Nue=[["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"}]],h3=We("music",Nue);const Aue=[["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"}]],Gc=We("package",Aue);const Tue=[["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"}]],ER=We("palette",Tue);const Cue=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],kue=We("paperclip",Cue);const jue=[["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"}]],NR=We("pause",jue);const Pue=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],uf=We("pen-line",Pue);const Rue=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],AR=We("pen",Rue);const Due=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],qo=We("pencil",Due);const Oue=[["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"}]],Lue=We("phone",Oue);const Iue=[["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"}]],Wc=We("play",Iue);const Fue=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],fo=We("plug",Fue);const Uue=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],mr=We("plus",Uue);const zue=[["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"}]],fM=We("power-off",zue);const Bue=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Ol=We("power",Bue);const Hue=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],Ei=We("printer",Hue);const $ue=[["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"}]],JG=We("qr-code",$ue);const Vue=[["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"}]],Dr=We("refresh-cw",Vue);const Gue=[["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"}]],fg=We("rotate-ccw",Gue);const Wue=[["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"}]],que=We("ruler",Wue);const Kue=[["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"}]],js=We("save",Kue);const Xue=[["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"}]],eW=We("scan-search",Xue);const Yue=[["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"}]],Zue=We("scissors",Yue);const Que=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Ml=We("search",Que);const Jue=[["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"}]],TR=We("send",Jue);const ede=[["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"}]],wh=We("server",ede);const tde=[["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"}]],mM=We("settings-2",tde);const nde=[["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"}]],pM=We("settings",nde);const rde=[["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"}]],ide=We("shield",rde);const ade=[["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"}]],tW=We("shopping-cart",ade);const sde=[["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"}]],ode=We("signal",sde);const lde=[["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"}]],cde=We("skip-back",lde);const ude=[["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"}]],tw=We("skip-forward",ude);const dde=[["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"}]],PU=We("sliders-vertical",dde);const hde=[["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"}]],H0=We("sparkles",hde);const fde=[["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"}]],Ed=We("square-check-big",fde);const mde=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Nd=We("square",mde);const pde=[["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"}]],df=We("star",pde);const gde=[["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"}]],nW=We("sticky-note",gde);const xde=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],RU=We("sun",xde);const bde=[["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"}]],Dp=We("tag",bde);const yde=[["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"}]],rW=We("target",yde);const vde=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],iW=We("terminal",vde);const _de=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],wde=We("text-align-center",_de);const Sde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Mde=We("text-align-end",Sde);const Ede=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Nde=We("text-align-start",Ede);const Ade=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],gM=We("thermometer",Ade);const Tde=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],ad=We("timer",Tde);const Cde=[["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"}]],vn=We("trash-2",Cde);const kde=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],aW=We("trending-down",kde);const jde=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],sW=We("trending-up",jde);const Pde=[["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"}]],Cn=We("triangle-alert",Pde);const Rde=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Dde=We("underline",Rde);const Ode=[["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"}]],oW=We("unlink",Ode);const Lde=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],qi=We("upload",Lde);const Ide=[["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"}]],f3=We("user",Ide);const Fde=[["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"}]],Ude=We("users",Fde);const zde=[["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"}]],lW=We("video",zde);const Bde=[["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"}]],Hde=We("volume-2",Bde);const $de=[["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"}]],Vde=We("volume-x",$de);const Gde=[["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"}]],Ib=We("wifi-off",Gde);const Wde=[["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"}]],$0=We("wifi",Wde);const qde=[["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"}]],cW=We("wind",qde);const Kde=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Ad=We("wrench",Kde);const Xde=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zt=We("x",Xde);const Yde=[["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"}]],Zde=We("zoom-in",Yde);const Qde=[["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"}]],hf=We("zap",Qde);const Jde=[["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"}]],ehe=We("zoom-out",Jde),Ln="/api/v1";async function Fe(t,e={}){const n=await fetch(`${Ln}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const i=(await n.json().catch(()=>({}))).detail,a=typeof i=="string"?i:i?JSON.stringify(i):`HTTP ${n.status}`;throw new Error(a)}return await n.json()}const be={getPrinters:()=>Fe("/printers/"),getPrinter:t=>Fe(`/printers/${t}`),createPrinter:t=>Fe("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Fe(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Fe(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Fe(`/printers/${t}/status`),refreshPrinterStatus:t=>Fe(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Fe(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Fe(`/printers/${t}/disconnect`,{method:"POST"}),stopPrint:t=>Fe(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Fe(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Fe(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>Fe(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Fe(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Fe(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Fe(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Fe(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Fe(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Fe(`/printers/${t}/logging`),clearMQTTLogs:t=>Fe(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Fe(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Ln}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>Fe(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Fe(`/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)),Fe(`/archives/?${i}`)},getArchive:t=>Fe(`/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)),Fe(`/archives/search?${n}`)},rebuildSearchIndex:()=>Fe("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Fe(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Fe(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Fe(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Fe("/archives/stats"),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Fe(`/archives/analysis/failures?${e}`)},compareArchives:t=>Fe(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Fe(`/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(`${Ln}/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(`${Ln}/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=>Fe(`/archives/${t}/duplicates`),backfillContentHashes:()=>Fe("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Ln}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${Ln}/archives/${t}/download`,getArchiveGcode:t=>`${Ln}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${Ln}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${Ln}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Fe(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Fe(`/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(`${Ln}/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=>Fe(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Fe(`/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(`${Ln}/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)=>`${Ln}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${Ln}/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)=>Fe(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Ln}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Ln}/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(`${Ln}/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=>Fe(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Ln}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Fe(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Fe(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Fe(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Ln}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Ln}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchiveFilamentRequirements:t=>Fe(`/archives/${t}/filament-requirements`),reprintArchive:(t,e,n)=>Fe(`/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?`${Ln}/archives/upload?printer_id=${e}`:`${Ln}/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?`${Ln}/archives/upload-bulk?printer_id=${e}`:`${Ln}/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:()=>Fe("/settings/"),updateSettings:t=>Fe("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Fe("/settings/mqtt/status"),resetSettings:()=>Fe("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.projects!==void 0&&e.set("include_projects",String(t.projects)),t.pending_uploads!==void 0&&e.set("include_pending_uploads",String(t.pending_uploads)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)),t.api_keys!==void 0&&e.set("include_api_keys",String(t.api_keys)));const n=`${Ln}/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=`${Ln}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>Fe("/settings/check-ffmpeg"),getCloudStatus:()=>Fe("/cloud/status"),cloudLogin:(t,e,n="global")=>Fe("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>Fe("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>Fe("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Fe("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Fe(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Fe(`/cloud/settings/${t}`),createCloudSetting:t=>Fe("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Fe(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Fe(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Fe("/cloud/devices"),getCloudFields:t=>Fe(`/cloud/fields/${t}`),getAllCloudFields:()=>Fe("/cloud/fields"),getFilamentInfo:t=>Fe("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Fe("/smart-plugs/"),getSmartPlug:t=>Fe(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Fe(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>Fe("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Fe(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Fe(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Fe(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Fe(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Fe("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${Ln}/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:()=>Fe("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${Ln}/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:()=>Fe("/smart-plugs/discover/devices"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Fe(`/queue/?${n}`)},getQueueItem:t=>Fe(`/queue/${t}`),addToQueue:t=>Fe("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Fe(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Fe(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Fe("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Fe(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Fe(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Fe(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>Fe(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Fe(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Fe(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Fe(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Fe(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Fe(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Fe(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Fe(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Fe(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Fe(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Fe(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>Fe("/filaments/"),getFilament:t=>Fe(`/filaments/${t}`),getFilamentsByType:t=>Fe(`/filaments/by-type/${t}`),getNotificationProviders:()=>Fe("/notifications/"),getNotificationProvider:t=>Fe(`/notifications/${t}`),createNotificationProvider:t=>Fe("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Fe(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Fe(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Fe(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Fe("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Fe("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Fe("/notification-templates"),getNotificationTemplate:t=>Fe(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Fe(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Fe(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Fe("/notification-templates/variables"),previewTemplate:t=>Fe("/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)),Fe(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Fe(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Fe(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Fe("/spoolman/status"),connectSpoolman:()=>Fe("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Fe("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Fe(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Fe("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Fe("/spoolman/spools"),getSpoolmanFilaments:()=>Fe("/spoolman/filaments"),getUnlinkedSpools:()=>Fe("/spoolman/spools/unlinked"),linkSpool:(t,e)=>Fe(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>Fe("/updates/version"),checkForUpdates:()=>Fe("/updates/check"),applyUpdate:()=>Fe("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Fe("/updates/status"),getMaintenanceTypes:()=>Fe("/maintenance/types"),createMaintenanceType:t=>Fe("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Fe(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Fe(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Fe("/maintenance/overview"),getPrinterMaintenance:t=>Fe(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Fe(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Fe(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Fe(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Fe("/maintenance/summary"),setPrinterHours:(t,e)=>Fe(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Fe(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Fe(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${Ln}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Ln}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Fe(`/printers/${t}/camera/test`),getExternalLinks:()=>Fe("/external-links/"),getExternalLink:t=>Fe(`/external-links/${t}`),createExternalLink:t=>Fe("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Fe(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Fe(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Fe("/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(`${Ln}/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=>Fe(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${Ln}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Fe(`/projects/?${e}`)},getProject:t=>Fe(`/projects/${t}`),createProject:t=>Fe("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Fe(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Fe(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Fe(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Fe(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Fe(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Fe(`/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(`${Ln}/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)=>`${Ln}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Fe(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Fe(`/projects/${t}/bom`),createBOMItem:(t,e)=>Fe(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Fe(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Fe(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Fe("/projects/templates/"),createTemplateFromProject:t=>Fe(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Fe(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Fe(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>Fe("/api-keys/"),createAPIKey:t=>Fe("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Fe(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Fe(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Fe(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Fe("/system/info")},al={getInfo:()=>Fe("/discovery/info"),getStatus:()=>Fe("/discovery/status"),startDiscovery:(t=10)=>Fe(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Fe("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Fe("/discovery/printers"),startSubnetScan:(t,e=1)=>Fe("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Fe("/discovery/scan/status"),stopSubnetScan:()=>Fe("/discovery/scan/stop",{method:"POST"})},y1={getSettings:()=>Fe("/settings/virtual-printer"),getModels:()=>Fe("/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),Fe(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},Nx={list:()=>Fe("/pending-uploads/"),getCount:()=>Fe("/pending-uploads/count"),get:t=>Fe(`/pending-uploads/${t}`),archive:(t,e)=>Fe(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Fe(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Fe("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Fe("/pending-uploads/discard-all",{method:"DELETE"})},v1={checkUpdates:()=>Fe("/firmware/updates"),checkPrinterUpdate:t=>Fe(`/firmware/updates/${t}`),prepareUpload:t=>Fe(`/firmware/updates/${t}/prepare`),startUpload:t=>Fe(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Fe(`/firmware/updates/${t}/upload/status`)},_1={getDebugLoggingState:()=>Fe("/support/debug-logging"),setDebugLogging:t=>Fe("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${Ln}/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)}},uW=S.createContext(void 0);function the({children:t}){const[e,n]=S.useState(()=>{const T=localStorage.getItem("theme-mode"),O=localStorage.getItem("theme");return T||O||"dark"}),[r,i]=S.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=S.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=S.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=S.useState(()=>localStorage.getItem("light-style")||"classic"),[f,g]=S.useState(()=>localStorage.getItem("light-background")||"neutral"),[p,x]=S.useState(()=>localStorage.getItem("light-accent")||"green");S.useEffect(()=>{be.getSettings().then(T=>{T.dark_style&&(i(T.dark_style),localStorage.setItem("dark-style",T.dark_style)),T.dark_background&&(o(T.dark_background),localStorage.setItem("dark-background",T.dark_background)),T.dark_accent&&(c(T.dark_accent),localStorage.setItem("dark-accent",T.dark_accent)),T.light_style&&(d(T.light_style),localStorage.setItem("light-style",T.light_style)),T.light_background&&(g(T.light_background),localStorage.setItem("light-background",T.light_background)),T.light_accent&&(x(T.light_accent),localStorage.setItem("light-accent",T.light_accent))}).catch(()=>{})},[]),S.useEffect(()=>{const T=document.documentElement;T.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(T.classList.add("dark"),T.classList.add(`style-${r}`),T.classList.add(`bg-${a}`),T.classList.add(`accent-${l}`)):(T.classList.add(`style-${u}`),T.classList.add(`bg-${f}`),T.classList.add(`accent-${p}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,p]);const y=()=>n(T=>T==="dark"?"light":"dark"),b=T=>n(T),v=T=>{i(T),localStorage.setItem("dark-style",T),be.updateSettings({dark_style:T}).catch(()=>{})},E=T=>{o(T),localStorage.setItem("dark-background",T),be.updateSettings({dark_background:T}).catch(()=>{})},w=T=>{c(T),localStorage.setItem("dark-accent",T),be.updateSettings({dark_accent:T}).catch(()=>{})},A=T=>{d(T),localStorage.setItem("light-style",T),be.updateSettings({light_style:T}).catch(()=>{})},N=T=>{g(T),localStorage.setItem("light-background",T),be.updateSettings({light_background:T}).catch(()=>{})},C=T=>{x(T),localStorage.setItem("light-accent",T),be.updateSettings({light_accent:T}).catch(()=>{})};return s.jsx(uW.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:p,toggleMode:y,setMode:b,setDarkStyle:v,setDarkBackground:E,setDarkAccent:w,setLightStyle:A,setLightBackground:N,setLightAccent:C},children:t})}function mg(){const t=S.useContext(uW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function vt({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 ci({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 nhe(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function DU({children:t}){return s.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function rhe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=cg(),i=nhe(n,e,r);return S.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:s.jsx(vt,{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(c3,{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(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(qr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(DU,{children:l},l))})]},o.description))})]},a.category))}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",s.jsx(DU,{children:"Esc"})," or click outside to close"]})})]})})})}function Te({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",o={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Qn({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:o}){S.useEffect(()=>{const u=d=>{d.key==="Escape"&&o()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o]);const c={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[i];return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o,children:s.jsx(vt,{className:"w-full max-w-md",onClick:u=>u.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 ${c.icon}`,children:s.jsx(Cn,{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(Te,{variant:"secondary",onClick:o,className:"flex-1",children:r}),s.jsx(Te,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}function ihe({plug:t}){const e=ln(),[n,r]=S.useState(null),{data:i,isLoading:a}=ht({queryKey:["smart-plug-status",t.id],queryFn:()=>be.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=xt({mutationFn:f=>be.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(fo,{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(gt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx($0,{className:"w-3 h-3 text-bambu-green"}),s.jsx("span",{className:l?"text-bambu-green":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(hf,{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(Ib,{className:"w-3 h-3 text-red-400"}),s.jsx("span",{className:"text-red-400",children:"Offline"})]})})]})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>r("on"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:u?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ol,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("off"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${!l&&c?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:u?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(fM,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Qn,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:d,onCancel:()=>r(null)})]})}function OU({onClose:t}){const{data:e,isLoading:n}=ht({queryKey:["smart-plugs"],queryFn:be.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(fo,{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(gt,{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(fo,{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(ihe,{plug:i},i.id))})})]})}const dW=[{name:"globe",icon:cf},{name:"link",icon:Lb},{name:"external-link",icon:qr},{name:"book",icon:sle},{name:"file-text",icon:is},{name:"home",icon:zce},{name:"star",icon:df},{name:"heart",icon:Ice},{name:"bookmark",icon:lle},{name:"shopping-cart",icon:tW},{name:"music",icon:h3},{name:"video",icon:lW},{name:"image",icon:Ob},{name:"camera",icon:jp},{name:"map",icon:cue},{name:"compass",icon:Vle},{name:"coffee",icon:zle},{name:"gift",icon:Ece},{name:"wrench",icon:Ad},{name:"zap",icon:hf},{name:"cloud",icon:uM},{name:"database",icon:Pp},{name:"folder",icon:ZG},{name:"mail",icon:oue},{name:"phone",icon:Lue},{name:"user",icon:f3},{name:"users",icon:Ude},{name:"server",icon:wh},{name:"terminal",icon:iW},{name:"code",icon:KG}];function xM(t){return dW.find(n=>n.name===t)?.icon||Lb}function ahe({value:t,onChange:e}){const[n,r]=S.useState(!1),i=xM(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:dW.map(({name:a,icon:o})=>s.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const LU=768;function hW(){const[t,e]=S.useState(()=>typeof window<"u"?window.innerWidth<LU:!1);return S.useEffect(()=>{const n=window.matchMedia(`(max-width: ${LU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const V0=[{id:"printers",to:"/",icon:Ei,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Ho,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Wr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:ble,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:uM,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Ad,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:ha,labelKey:"nav.projects"},{id:"settings",to:"/settings",icon:pM,labelKey:"nav.settings"}];function she(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return V0.map(e=>e.id)}return V0.map(e=>e.id)}function ohe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function oA(t){return t.startsWith("ext-")}function fW(){return localStorage.getItem("defaultView")||"/"}function lhe(t){localStorage.setItem("defaultView",t)}function che(){const t=Rb(),e=Ud(),{mode:n,toggleMode:r}=mg(),{t:i}=cg(),a=hW(),[o,l]=S.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=S.useState(!1),[d,f]=S.useState(!1),[g,p]=S.useState(!1),[x,y]=S.useState(she),[b,v]=S.useState(null),[E,w]=S.useState(null),A=S.useRef(!1),[N,C]=S.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=ht({queryKey:["version"],queryFn:be.getVersion,staleTime:1/0}),{data:O}=ht({queryKey:["settings"],queryFn:be.getSettings,staleTime:300*1e3}),{data:k}=ht({queryKey:["updateCheck"],queryFn:be.checkForUpdates,enabled:O?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:R}=ht({queryKey:["external-links"],queryFn:be.getExternalLinks}),{data:z}=ht({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs,staleTime:30*1e3}),D=z?.some(ue=>ue.show_in_switchbar)??!1,{data:K}=ht({queryKey:["debugLogging"],queryFn:_1.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),[P,W]=S.useState(null);S.useEffect(()=>{if(!K?.enabled||!K.enabled_at){W(null);return}const ue=new Date(K.enabled_at).getTime(),ce=()=>{W(Math.floor((Date.now()-ue)/1e3))};ce();const fe=setInterval(ce,1e3);return()=>clearInterval(fe)},[K?.enabled,K?.enabled_at]);const Z=new Map(V0.map(ue=>[ue.id,ue])),G=new Map((R||[]).map(ue=>[`ext-${ue.id}`,ue])),Y=(()=>{const ue=[],ce=new Set;for(const fe of x)(Z.has(fe)||G.has(fe))&&(ue.push(fe),ce.add(fe));for(const fe of V0)ce.has(fe.id)||(ue.push(fe.id),ce.add(fe.id));for(const fe of R||[]){const pe=`ext-${fe.id}`;ce.has(pe)||(ue.push(pe),ce.add(pe))}return ue})(),X=(ue,ce)=>{v(ce),ue.dataTransfer.effectAllowed="move",ue.dataTransfer.setData("text/plain",ce)},q=(ue,ce)=>{ue.preventDefault(),ue.dataTransfer.dropEffect="move",w(ce)},F=()=>{w(null)},V=(ue,ce)=>{if(ue.preventDefault(),b===null||b===ce){v(null),w(null);return}const fe=[...Y],pe=fe.indexOf(b),_e=fe.indexOf(ce);if(pe===-1||_e===-1){v(null),w(null);return}fe.splice(pe,1),fe.splice(_e,0,b),y(fe),ohe(fe),v(null),w(null)},te=()=>{v(null),w(null)},re=k?.update_available&&k.latest_version&&k.latest_version!==N,ae=()=>{k?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",k.latest_version),C(k.latest_version))};S.useEffect(()=>{if(!A.current&&e.pathname==="/"){const ue=fW();ue!=="/"&&(A.current=!0,t(ue,{replace:!0}))}},[e.pathname,t]),S.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(o))},[o]),S.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const he=S.useCallback(ue=>{const ce=ue.target;if(!(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.isContentEditable)&&!ue.metaKey&&!ue.ctrlKey&&!ue.altKey){const fe=parseInt(ue.key);if(fe>=1&&fe<=Y.length&&fe<=9){const pe=Y[fe-1];if(ue.preventDefault(),oA(pe)){const _e=pe.replace("ext-","");t(`/external/${_e}`)}else{const _e=Z.get(pe);_e&&t(_e.to)}return}switch(ue.key){case"?":ue.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,Y,Z]);return S.useEffect(()=>(document.addEventListener("keydown",he),()=>document.removeEventListener("keydown",he)),[he]),s.jsxs("div",{className:"flex min-h-screen",children:[a&&s.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[s.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(xue,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&c&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),s.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${c?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${o?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||o?"p-4":"p-2"}`,children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||o?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),s.jsx("nav",{className:"flex-1 p-2",children:s.jsx("ul",{className:"space-y-2",children:Y.map(ue=>{if(oA(ue)){const fe=G.get(ue);if(!fe)return null;const pe=fe.custom_icon?null:xM(fe.icon);return s.jsx("li",{draggable:!0,onDragStart:_e=>X(_e,ue),onDragOver:_e=>q(_e,ue),onDragLeave:F,onDrop:_e=>V(_e,ue),onDragEnd:te,className:`relative ${b===ue?"opacity-50":""} ${E===ue&&b!==ue?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Qx,{to:`/external/${fe.id}`,className:({isActive:_e})=>`flex items-center ${a||o?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${_e?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!o?fe.name:void 0,children:[o&&!a&&s.jsx(B0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),fe.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${fe.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):pe&&s.jsx(pe,{className:"w-5 h-5 flex-shrink-0"}),(a||o)&&s.jsx("span",{children:fe.name})]})},ue)}else{const fe=Z.get(ue);if(!fe)return null;const{to:pe,icon:_e,labelKey:ne}=fe;return s.jsx("li",{draggable:!0,onDragStart:He=>X(He,ue),onDragOver:He=>q(He,ue),onDragLeave:F,onDrop:He=>V(He,ue),onDragEnd:te,className:`relative ${b===ue?"opacity-50":""} ${E===ue&&b!==ue?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(Qx,{to:pe,className:({isActive:He})=>`flex items-center ${a||o?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${He?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!o?i(ne):void 0,children:[o&&!a&&s.jsx(B0,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsx(_e,{className:"w-5 h-5 flex-shrink-0"}),(a||o)&&s.jsx("span",{children:i(ne)})]})},ue)}})})}),!a&&s.jsx("button",{onClick:()=>l(!o),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:i(o?"nav.collapseSidebar":"nav.expandSidebar"),children:o?s.jsx(of,{className:"w-5 h-5"}):s.jsx(Zo,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||o?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[D&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>p(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${g?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(fo,{className:"w-5 h-5"})}),g&&s.jsx(OU,{onClose:()=>p(!1)})]}),s.jsx(Qx,{to:"/system",className:({isActive:ue})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ue?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Sd,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(kU,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(c3,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(RU,{className:"w-5 h-5"}):s.jsx(ew,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),k?.update_available&&s.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:k.latest_version}),children:[s.jsx(aA,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[k?.update_available&&s.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:k.latest_version}),children:s.jsx(aA,{className:"w-5 h-5"})}),D&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>p(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${g?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(fo,{className:"w-5 h-5"})}),g&&s.jsx(OU,{onClose:()=>p(!1)})]}),s.jsx(Qx,{to:"/system",className:({isActive:ue})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ue?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(Sd,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.viewOnGithub"),children:s.jsx(kU,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(c3,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx(RU,{className:"w-5 h-5"}):s.jsx(ew,{className:"w-5 h-5"})})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":o?"ml-64":"ml-16"}`,children:[K?.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(qG,{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"}),P!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(P/60),"m ",P%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"})})]})}),re&&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(aA,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:k?.latest_version,defaultValue:`Version ${k?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:ae,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(zt,{className:"w-4 h-4"})})]}),s.jsx(Ese,{})]}),d&&s.jsx(rhe,{onClose:()=>f(!1),sidebarItems:Y.map(ue=>{if(oA(ue)){const ce=G.get(ue);return ce?{type:"external",label:ce.name}:null}else{const ce=Z.get(ue);return ce?{type:"nav",label:ce.labelKey,labelKey:ce.labelKey}:null}}).filter(Boolean)})]})}function m0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function di(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Op(t,e){const n=di(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Lp(t,e="system",n){const r=di(t);if(!r)return"";const a=m0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function uhe(t,e="system",n){const i=m0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const mW=S.createContext(void 0);function dr(){const t=S.useContext(mW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const dhe={success:s.jsx(kr,{className:"w-5 h-5 text-green-400"}),error:s.jsx(Sa,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(Na,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Sd,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(gt,{className:"w-5 h-5 text-bambu-green animate-spin"})},hhe={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 fhe({children:t}){const[e,n]=S.useState([]),r=S.useCallback((o,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:o,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=S.useCallback((o,l,c="info")=>{n(u=>u.find(f=>f.id===o)?u.map(f=>f.id===o?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:o,message:l,type:c,persistent:!0}])},[]),a=S.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(mW.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 ${hhe[o.type]}`,children:[dhe[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(zt,{className:"w-4 h-4"})})]},o.id))})]})}function mhe(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`}function IU(t){if(t===0)return"0 GB";const e=t/(1024*1024*1024);return e>=1?`${e.toFixed(1)} GB`:`${(t/(1024*1024)).toFixed(0)} MB`}function phe(t,e){if(e)return ZG;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return YG;case"gcode":return is;case"mp4":case"avi":return fd;case"png":case"jpg":case"jpeg":return Ob;default:return yR}}function ghe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=dr(),i=ln(),[a,o]=S.useState("/"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,g]=S.useState(null);S.useEffect(()=>{const T=O=>{O.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);const{data:p,isLoading:x,refetch:y}=ht({queryKey:["printerFiles",t,a],queryFn:()=>be.getPrinterFiles(t,a)}),{data:b}=ht({queryKey:["printerStorage",t],queryFn:()=>be.getPrinterStorage(t),staleTime:3e4}),v=xt({mutationFn:T=>be.deletePrinterFile(t,T),onSuccess:(T,O)=>{r(`Deleted: ${O.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:T=>{r(`Delete failed: ${T.message}`,"error")}}),E=T=>{o(T),c(null)},w=()=>{if(a==="/")return;const T=a.split("/").filter(Boolean);T.pop(),o(T.length?"/"+T.join("/"):"/"),c(null)},A=T=>{window.open(be.getPrinterFileDownloadUrl(t,T),"_blank")},N=T=>{g(T)},C=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(wR,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[b&&(b.used_bytes!=null||b.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[b.used_bytes!=null&&s.jsxs("span",{children:["Used: ",IU(b.used_bytes)]}),b.used_bytes!=null&&b.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),b.free_bytes!=null&&s.jsxs("span",{children:["Free: ",IU(b.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[C.map(T=>s.jsx("button",{onClick:()=>{E(T.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===T.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:T.label},T.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Ml,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:T=>d(T.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>y(),disabled:x,children:s.jsx(Dr,{className:`w-4 h-4 ${x?"animate-spin":""}`})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[s.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(of,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:x?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):p?.files?.length?s.jsx("div",{className:"space-y-1",children:[...p.files].filter(T=>!u||T.name.toLowerCase().includes(u.toLowerCase())).sort((T,O)=>T.is_directory&&!O.is_directory?-1:!T.is_directory&&O.is_directory?1:T.name.localeCompare(O.name)).map(T=>{const O=phe(T.name,T.is_directory),k=l===T.path;return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${k?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{T.is_directory?E(T.path):c(k?null:T.path)},children:[s.jsx(O,{className:`w-5 h-5 flex-shrink-0 ${T.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:T.name}),!T.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:mhe(T.size)}),T.is_directory&&s.jsx(of,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},T.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${p?.files?.filter(T=>T.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${p?.files?.length||0} items`:`${p?.files?.length||0} items`}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",disabled:!l,onClick:()=>l&&A(l),children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download"]}),s.jsxs(Te,{variant:"secondary",disabled:!l||v.isPending,onClick:()=>l&&N(l),className:"text-red-400 hover:text-red-300",children:[v.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(vn,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&s.jsx(Qn,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{v.mutate(f),g(null)},onCancel:()=>g(null)})]})}function xhe({printerId:t,printerName:e,onClose:n}){const r=ln(),[i,a]=S.useState(!0),[o,l]=S.useState(new Set),[c,u]=S.useState(""),[d,f]=S.useState("all"),g=S.useRef(null),{data:p,isLoading:x,refetch:y}=ht({queryKey:["mqtt-logs",t],queryFn:()=>be.getMQTTLogs(t),refetchInterval:1e3}),b=xt({mutationFn:()=>be.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),v=xt({mutationFn:()=>be.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=xt({mutationFn:()=>be.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});S.useEffect(()=>{const k=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]),S.useEffect(()=>{i&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[p?.logs,i]);const w=k=>{l(R=>{const z=new Set(R);return z.has(k)?z.delete(k):z.add(k),z})},A=k=>new Date(k).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),N=(k,R)=>{if(k==null)return"<empty>";const z=typeof k=="string"?JSON.parse(k):k,D=JSON.stringify(z,null,R?2:0);return!R&&D.length>100?D.substring(0,100)+"...":D},C=p?.logging_enabled??!1,T=p?.logs??[],O=S.useMemo(()=>T.filter(k=>{if(d!=="all"&&k.direction!==d)return!1;if(c.trim()){const R=c.toLowerCase(),z=k.topic.toLowerCase().includes(R),K=JSON.stringify(k.payload).toLowerCase().includes(R);return z||K}return!0}),[T,c,d]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[C?s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,children:[s.jsx(Nd,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Te,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[s.jsx(Wc,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||T.length===0,children:[s.jsx(vn,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>y(),disabled:x,children:s.jsx(Dr,{className:`w-4 h-4 ${x?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:i,onChange:k=>a(k.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[O.length,"/",T.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ml,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:k=>u(k.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),c&&s.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(zt,{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(U0,{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(kp,{className:"w-3 h-3"}),"Out"]})]})]})]}),s.jsx("div",{ref:g,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!C&&s.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):O.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages match your filter"}),s.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):s.jsx("div",{className:"space-y-1",children:O.map((k,R)=>{const z=o.has(R),D=k.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${z?"bg-bambu-dark-secondary":""}`,onClick:()=>w(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:A(k.timestamp)}),s.jsx("span",{className:`shrink-0 ${D?"text-blue-400":"text-green-400"}`,title:D?"Incoming":"Outgoing",children:D?s.jsx(U0,{className:"w-3 h-3"}):s.jsx(kp,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:k.topic})]}),z?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:N(k.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:N(k.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:C?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):s.jsx("span",{children:"Logging stopped"})}),s.jsx(Te,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const m3={"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 bhe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Cn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Cn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Na};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Sd}}}function p3(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 yhe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=p3(e.attr,n);return m3[r]!==void 0})}function vhe(){return"https://wiki.bambulab.com/en/hms/home"}function _he({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=p3(i.attr,a);return m3[o]!==void 0});return S.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Cn,{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(zt,{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(Na,{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}=bhe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=p3(i.attr,d),g=m3[f],p=vhe(),x=f.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",x,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:o})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:g}),s.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(qr,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function whe(t){if(!t)return"ASAP";const e=di(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 She({printerId:t}){const{data:e}=ht({queryKey:["queue",t,"pending"],queryFn:()=>be.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(Ac,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(Wr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),s.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[s.jsx(ur,{className:"w-3 h-3"}),whe(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function pW(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=pW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function In(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=pW(t))&&(r&&(r+=" "),r+=e);return r}var Mhe=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function CR(t){if(typeof t!="string")return!1;var e=Mhe;return e.includes(t)}var Ehe=["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"],Nhe=new Set(Ehe);function gW(t){return typeof t!="string"?!1:Nhe.has(t)}function xW(t){return typeof t=="string"&&t.startsWith("data-")}function za(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(gW(n)||xW(n))&&(e[n]=t[n]);return e}function ff(t){if(t==null)return null;if(S.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return za(e)}return typeof t=="object"&&!Array.isArray(t)?za(t):null}function fa(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(gW(n)||xW(n)||CR(n))&&(e[n]=t[n]);return e}function Ahe(t){return t==null?null:S.isValidElement(t)?fa(t.props):typeof t=="object"&&!Array.isArray(t)?fa(t):null}var The=["children","width","height","viewBox","className","style","title","desc"];function g3(){return g3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},g3.apply(null,arguments)}function Che(t,e){if(t==null)return{};var n,r,i=khe(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 khe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var kR=S.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=Che(t,The),f=a||{width:r,height:i,x:0,y:0},g=In("recharts-surface",o);return S.createElement("svg",g3({},fa(d),{className:g,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),S.createElement("title",null,c),S.createElement("desc",null,u),n)}),jhe=["children","className"];function x3(){return x3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},x3.apply(null,arguments)}function Phe(t,e){if(t==null)return{};var n,r,i=Rhe(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 Rhe(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 Lr=S.forwardRef((t,e)=>{var{children:n,className:r}=t,i=Phe(t,jhe),a=In("recharts-layer",r);return S.createElement("g",x3({className:a},fa(i),{ref:e}),n)}),bW=S.createContext(null),Dhe=()=>S.useContext(bW);function br(t){return function(){return t}}const yW=Math.cos,nw=Math.sin,Qo=Math.sqrt,rw=Math.PI,bM=2*rw,b3=Math.PI,y3=2*b3,Sh=1e-6,Ohe=y3-Sh;function vW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function Lhe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return vW;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 Ihe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?vW:Lhe(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,g=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(g>Sh)if(!(Math.abs(f*c-u*d)>Sh)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let p=r-o,x=i-l,y=c*c+u*u,b=p*p+x*x,v=Math.sqrt(y),E=Math.sqrt(g),w=a*Math.tan((b3-Math.acos((y+g-b)/(2*v*E)))/2),A=w/E,N=w/v;Math.abs(A-1)>Sh&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*p>d*x)},${this._x1=e+N*c},${this._y1=n+N*u}`}}arc(e,n,r,i,a,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,g=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Sh||Math.abs(this._y1-d)>Sh)&&this._append`L${u},${d}`,r&&(g<0&&(g=g%y3+y3),g>Ohe?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:g>Sh&&this._append`A${r},${r},0,${+(g>=b3)},${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 jR(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 Ihe(e)}function PR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function _W(t){this._context=t}_W.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 yM(t){return new _W(t)}function wW(t){return t[0]}function SW(t){return t[1]}function MW(t,e){var n=br(!0),r=null,i=yM,a=null,o=jR(l);t=typeof t=="function"?t:t===void 0?wW:br(t),e=typeof e=="function"?e:e===void 0?SW:br(e);function l(c){var u,d=(c=PR(c)).length,f,g=!1,p;for(r==null&&(a=i(p=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===g&&((g=!g)?a.lineStart():a.lineEnd()),g&&a.point(+t(f,u,c),+e(f,u,c));if(p)return a=null,p+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:br(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:br(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:br(!!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 Iv(t,e,n){var r=null,i=br(!0),a=null,o=yM,l=null,c=jR(u);t=typeof t=="function"?t:t===void 0?wW:br(+t),e=typeof e=="function"?e:br(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?SW:br(+n);function u(f){var g,p,x,y=(f=PR(f)).length,b,v=!1,E,w=new Array(y),A=new Array(y);for(a==null&&(l=o(E=c())),g=0;g<=y;++g){if(!(g<y&&i(b=f[g],g,f))===v)if(v=!v)p=g,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=g-1;x>=p;--x)l.point(w[x],A[x]);l.lineEnd(),l.areaEnd()}v&&(w[g]=+t(b,g,f),A[g]=+e(b,g,f),l.point(r?+r(b,g,f):w[g],n?+n(b,g,f):A[g]))}if(E)return l=null,E+""||null}function d(){return MW().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:br(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:br(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:br(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:br(+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:br(!!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 EW{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 Fhe(t){return new EW(t,!0)}function Uhe(t){return new EW(t,!1)}const RR={draw(t,e){const n=Qo(e/rw);t.moveTo(n,0),t.arc(0,0,n,0,bM)}},zhe={draw(t,e){const n=Qo(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},NW=Qo(1/3),Bhe=NW*2,Hhe={draw(t,e){const n=Qo(e/Bhe),r=n*NW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},$he={draw(t,e){const n=Qo(e),r=-n/2;t.rect(r,r,n,n)}},Vhe=.8908130915292852,AW=nw(rw/10)/nw(7*rw/10),Ghe=nw(bM/10)*AW,Whe=-yW(bM/10)*AW,qhe={draw(t,e){const n=Qo(e*Vhe),r=Ghe*n,i=Whe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=bM*a/5,l=yW(o),c=nw(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},lA=Qo(3),Khe={draw(t,e){const n=-Qo(e/(lA*3));t.moveTo(0,n*2),t.lineTo(-lA*n,-n),t.lineTo(lA*n,-n),t.closePath()}},qs=-.5,Ks=Qo(3)/2,v3=1/Qo(12),Xhe=(v3/2+1)*3,Yhe={draw(t,e){const n=Qo(e/Xhe),r=n/2,i=n*v3,a=r,o=n*v3+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(qs*r-Ks*i,Ks*r+qs*i),t.lineTo(qs*a-Ks*o,Ks*a+qs*o),t.lineTo(qs*l-Ks*c,Ks*l+qs*c),t.lineTo(qs*r+Ks*i,qs*i-Ks*r),t.lineTo(qs*a+Ks*o,qs*o-Ks*a),t.lineTo(qs*l+Ks*c,qs*c-Ks*l),t.closePath()}};function Zhe(t,e){let n=null,r=jR(i);t=typeof t=="function"?t:br(t||RR),e=typeof e=="function"?e:br(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:br(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:br(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function iw(){}function aw(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 TW(t){this._context=t}TW.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:aw(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:aw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Qhe(t){return new TW(t)}function CW(t){this._context=t}CW.prototype={areaStart:iw,areaEnd:iw,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:aw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Jhe(t){return new CW(t)}function kW(t){this._context=t}kW.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:aw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function efe(t){return new kW(t)}function jW(t){this._context=t}jW.prototype={areaStart:iw,areaEnd:iw,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 tfe(t){return new jW(t)}function FU(t){return t<0?-1:1}function UU(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(FU(a)+FU(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function zU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function cA(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 sw(t){this._context=t}sw.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:cA(this,this._t0,zU(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(t=+t,e=+e,!(t===this._x1&&e===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,cA(this,zU(this,n=UU(this,t,e)),n);break;default:cA(this,this._t0,n=UU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function PW(t){this._context=new RW(t)}(PW.prototype=Object.create(sw.prototype)).point=function(t,e){sw.prototype.point.call(this,e,t)};function RW(t){this._context=t}RW.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 nfe(t){return new sw(t)}function rfe(t){return new PW(t)}function DW(t){this._context=t}DW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var r=BU(t),i=BU(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[o],e[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function BU(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function ife(t){return new DW(t)}function vM(t,e){this._context=t,this._t=e}vM.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 afe(t){return new vM(t,.5)}function sfe(t){return new vM(t,0)}function ofe(t){return new vM(t,1)}function Ip(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 _3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function lfe(t,e){return t[e]}function cfe(t){const e=[];return e.key=t,e}function ufe(){var t=br([]),e=_3,n=Ip,r=lfe;function i(a){var o=Array.from(t.apply(this,arguments),cfe),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=PR(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:br(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:br(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?_3:typeof a=="function"?a:br(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Ip,i):n},i}function dfe(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}Ip(t,e)}}function hfe(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}Ip(t,e)}}function ffe(t,e){if(!(!((o=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,g=d[r-1][1]||0,p=(f-g)/2,x=0;x<l;++x){var y=t[e[x]],b=y[r][1]||0,v=y[r-1][1]||0;p+=b-v}c+=f,u+=p*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Ip(t,e)}}var uA={},dA={},HU;function mfe(){return HU||(HU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(dA)),dA}var hA={},$U;function OW(){return $U||($U=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}t.isDeepKey=e})(hA)),hA}var fA={},VU;function DR(){return VU||(VU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="string"||typeof n=="symbol"?n:Object.is(n?.valueOf?.(),-0)?"-0":String(n)}t.toKey=e})(fA)),fA}var mA={},pA={},GU;function pfe(){return GU||(GU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(n==null)return"";if(typeof n=="string")return n;if(Array.isArray(n))return n.map(e).join(",");const r=String(n);return r==="0"&&Object.is(Number(n),-0)?"-0":r}t.toString=e})(pA)),pA}var WU;function OR(){return WU||(WU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pfe(),n=DR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(mA)),mA}var qU;function LR(){return qU||(qU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mfe(),n=OW(),r=DR(),i=OR();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(uA)),uA}var gA,KU;function gfe(){return KU||(KU=1,gA=LR().get),gA}var xfe=gfe();const mf=_o(xfe);var Wi=t=>t===0?0:t>0?1:-1,hs=t=>typeof t=="number"&&t!=+t,qc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ot=t=>(typeof t=="number"||t instanceof Number)&&!hs(t),bo=t=>Ot(t)||typeof t=="string",bfe=0,G0=t=>{var e=++bfe;return"".concat(t||"").concat(e)},Ea=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Ot(e)&&typeof e!="string")return r;var a;if(qc(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return hs(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},LW=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[t[r]])n[t[r]]=!0;else return!0;return!1};function Wn(t,e,n){return Ot(t)&&Ot(e)?t+n*(e-t):e}function IW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):mf(r,e))===n)}var Nr=t=>t===null||typeof t>"u",Fb=t=>Nr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function yfe(t){return t!=null}function Ub(){}var vfe=["type","size","sizeType"];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 XU(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function YU(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XU(Object(n),!0).forEach(function(r){_fe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function _fe(t,e,n){return(e=wfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wfe(t){var e=Sfe(t,"string");return typeof e=="symbol"?e:e+""}function Sfe(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 Mfe(t,e){if(t==null)return{};var n,r,i=Efe(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 Efe(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 FW={symbolCircle:RR,symbolCross:zhe,symbolDiamond:Hhe,symbolSquare:$he,symbolStar:qhe,symbolTriangle:Khe,symbolWye:Yhe},Nfe=Math.PI/180,Afe=t=>{var e="symbol".concat(Fb(t));return FW[e]||RR},Tfe=(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*Nfe;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}},Cfe=(t,e)=>{FW["symbol".concat(Fb(t))]=e},IR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Mfe(t,vfe),a=YU(YU({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var g=Afe(o),p=Zhe().type(g).size(Tfe(n,r,o)),x=p();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=fa(a);return Ot(u)&&Ot(d)&&Ot(n)?S.createElement("path",w3({},f,{className:In("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};IR.registerSymbol=Cfe;var UW=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,FR=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(S.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{CR(i)&&(r[i]=(a=>n[i](n,a)))}),r},kfe=(t,e,n)=>r=>(t(e,n,r),null),zb=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];CR(i)&&typeof a=="function"&&(r||(r={}),r[i]=kfe(a,e,n))}),r};function ZU(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function jfe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZU(Object(n),!0).forEach(function(r){Pfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pfe(t,e,n){return(e=Rfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rfe(t){var e=Dfe(t,"string");return typeof e=="symbol"?e:e+""}function Dfe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ir(t,e){var n=jfe({},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 ow(){return ow=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},ow.apply(null,arguments)}function QU(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ofe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QU(Object(n),!0).forEach(function(r){Lfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QU(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lfe(t,e,n){return(e=Ife(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ife(t){var e=Ffe(t,"string");return typeof e=="symbol"?e:e+""}function Ffe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Js=32,Ufe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function zfe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Js/2,a=Js/6,o=Js/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return S.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:Js,y2:i,className:"recharts-legend-icon"})}if(c==="line")return S.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(Js,"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 S.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(Js/8,"h").concat(Js,"v").concat(Js*3/4,"h").concat(-Js,"z"),className:"recharts-legend-icon"});if(S.isValidElement(e.legendIcon)){var d=Ofe({},e);return delete d.legendIcon,S.cloneElement(e.legendIcon,d)}return S.createElement(IR,{fill:l,cx:i,cy:i,size:Js,sizeType:"diameter",type:c})}function Bfe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:Js,height:Js},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var g=d.formatter||i,p=In({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,y=g?g(d.value,d,f):d.value;return S.createElement("li",ow({className:p,style:c,key:"legend-item-".concat(f)},zb(t,d,f)),S.createElement(kR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},S.createElement(zfe,{data:d,iconType:o,inactiveColor:a})),S.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var Hfe=t=>{var e=Ir(t,Ufe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return S.createElement("ul",{className:"recharts-default-legend",style:a},S.createElement(Bfe,ow({},e,{payload:n})))},xA={},bA={},JU;function $fe(){return JU||(JU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(bA)),bA}var yA={},ez;function zW(){return ez||(ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(yA)),yA}var vA={},_A={},wA={},tz;function Vfe(){return tz||(tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(wA)),wA}var nz;function UR(){return nz||(nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Vfe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(_A)),_A}var SA={},rz;function Gfe(){return rz||(rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(SA)),SA}var iz;function Wfe(){return iz||(iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UR(),n=Gfe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(vA)),vA}var MA={},EA={},az;function qfe(){return az||(az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(EA)),EA}var NA={},AA={},TA={},CA={},sz;function BW(){return sz||(sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(CA)),CA}var kA={},oz;function HW(){return oz||(oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null||typeof n!="object"&&typeof n!="function"}t.isPrimitive=e})(kA)),kA}var jA={},lz;function $W(){return lz||(lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.eq=e})(jA)),jA}var cz;function Kfe(){return cz||(cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=BW(),n=HW(),r=$W();function i(d,f,g){return typeof g!="function"?i(d,f,()=>{}):a(d,f,function p(x,y,b,v,E,w){const A=g(x,y,b,v,E,w);return A!==void 0?!!A:a(x,y,p,w)},new Map)}function a(d,f,g,p){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,g,p);case"function":return Object.keys(f).length>0?a(d,{...f},g,p):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,g,p){if(f==null)return!0;if(Array.isArray(f))return c(d,f,g,p);if(f instanceof Map)return l(d,f,g,p);if(f instanceof Set)return u(d,f,g,p);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(p?.has(f))return p.get(f)===d;p?.set(f,d);try{for(let y=0;y<x.length;y++){const b=x[y];if(!n.isPrimitive(d)&&!(b in d)||f[b]===void 0&&d[b]!==void 0||f[b]===null&&d[b]!==null||!g(d[b],f[b],b,d,f,p))return!1}return!0}finally{p?.delete(f)}}function l(d,f,g,p){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of f.entries()){const b=d.get(x);if(g(b,y,x,d,f,p)===!1)return!1}return!0}function c(d,f,g,p){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<f.length;y++){const b=f[y];let v=!1;for(let E=0;E<d.length;E++){if(x.has(E))continue;const w=d[E];let A=!1;if(g(w,b,y,d,f,p)&&(A=!0),A){x.add(E),v=!0;break}}if(!v)return!1}return!0}function u(d,f,g,p){return f.size===0?!0:d instanceof Set?c([...d],[...f],g,p):!1}t.isMatchWith=i,t.isSetMatch=u})(TA)),TA}var uz;function VW(){return uz||(uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Kfe();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(AA)),AA}var PA={},RA={},DA={},dz;function Xfe(){return dz||(dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}t.getSymbols=e})(DA)),DA}var OA={},hz;function GW(){return hz||(hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}t.getTag=e})(OA)),OA}var LA={},fz;function WW(){return fz||(fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",g="[object ArrayBuffer]",p="[object Object]",x="[object Error]",y="[object DataView]",b="[object Uint8Array]",v="[object Uint8ClampedArray]",E="[object Uint16Array]",w="[object Uint32Array]",A="[object BigUint64Array]",N="[object Int8Array]",C="[object Int16Array]",T="[object Int32Array]",O="[object BigInt64Array]",k="[object Float32Array]",R="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=g,t.arrayTag=d,t.bigInt64ArrayTag=O,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=k,t.float64ArrayTag=R,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=T,t.int8ArrayTag=N,t.mapTag=c,t.numberTag=r,t.objectTag=p,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=E,t.uint32ArrayTag=w,t.uint8ArrayTag=b,t.uint8ClampedArrayTag=v})(LA)),LA}var IA={},mz;function Yfe(){return mz||(mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(IA)),IA}var pz;function qW(){return pz||(pz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Xfe(),n=GW(),r=WW(),i=HW(),a=Yfe();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,g,p=new Map,x=void 0){const y=x?.(d,f,g,p);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(p.has(d))return p.get(d);if(Array.isArray(d)){const b=new Array(d.length);p.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,g,p,x);return Object.hasOwn(d,"index")&&(b.index=d.index),Object.hasOwn(d,"input")&&(b.input=d.input),b}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const b=new RegExp(d.source,d.flags);return b.lastIndex=d.lastIndex,b}if(d instanceof Map){const b=new Map;p.set(d,b);for(const[v,E]of d)b.set(v,l(E,v,g,p,x));return b}if(d instanceof Set){const b=new Set;p.set(d,b);for(const v of d)b.add(l(v,void 0,g,p,x));return b}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const b=new(Object.getPrototypeOf(d)).constructor(d.length);p.set(d,b);for(let v=0;v<d.length;v++)b[v]=l(d[v],v,g,p,x);return b}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const b=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return p.set(d,b),c(b,d,g,p,x),b}if(typeof File<"u"&&d instanceof File){const b=new File([d],d.name,{type:d.type});return p.set(d,b),c(b,d,g,p,x),b}if(typeof Blob<"u"&&d instanceof Blob){const b=new Blob([d],{type:d.type});return p.set(d,b),c(b,d,g,p,x),b}if(d instanceof Error){const b=new d.constructor;return p.set(d,b),b.message=d.message,b.name=d.name,b.stack=d.stack,b.cause=d.cause,c(b,d,g,p,x),b}if(d instanceof Boolean){const b=new Boolean(d.valueOf());return p.set(d,b),c(b,d,g,p,x),b}if(d instanceof Number){const b=new Number(d.valueOf());return p.set(d,b),c(b,d,g,p,x),b}if(d instanceof String){const b=new String(d.valueOf());return p.set(d,b),c(b,d,g,p,x),b}if(typeof d=="object"&&u(d)){const b=Object.create(Object.getPrototypeOf(d));return p.set(d,b),c(b,d,g,p,x),b}return d}function c(d,f,g=d,p,x){const y=[...Object.keys(f),...e.getSymbols(f)];for(let b=0;b<y.length;b++){const v=y[b],E=Object.getOwnPropertyDescriptor(d,v);(E==null||E.writable)&&(d[v]=l(f[v],v,g,p,x))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(RA)),RA}var gz;function Zfe(){return gz||(gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qW();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(PA)),PA}var xz;function Qfe(){return xz||(xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VW(),n=Zfe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(NA)),NA}var FA={},UA={},zA={},bz;function Jfe(){return bz||(bz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qW(),n=WW();function r(i,a){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=a?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(zA)),zA}var yz;function eme(){return yz||(yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Jfe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(UA)),UA}var BA={},HA={},vz;function KW(){return vz||(vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return e.test(r)}}t.isIndex=n})(HA)),HA}var $A={},_z;function tme(){return _z||(_z=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GW();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})($A)),$A}var wz;function nme(){return wz||(wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=OW(),n=KW(),r=tme(),i=OR();function a(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(BA)),BA}var Sz;function rme(){return Sz||(Sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VW(),n=DR(),r=eme(),i=LR(),a=nme();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})(FA)),FA}var Mz;function ime(){return Mz||(Mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zW(),n=qfe(),r=Qfe(),i=rme();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})(MA)),MA}var Ez;function ame(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$fe(),n=zW(),r=Wfe(),i=ime();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})(xA)),xA}var VA,Nz;function sme(){return Nz||(Nz=1,VA=ame().uniqBy),VA}var ome=sme();const Az=_o(ome);function XW(t,e,n){return e===!0?Az(t,n):typeof e=="function"?Az(t,e):t}var GA={exports:{}},WA={};var Tz;function lme(){if(Tz)return WA;Tz=1;var t=lg(),e=pG();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 WA.useSyncExternalStoreWithSelector=function(u,d,f,g,p){var x=a(null);if(x.current===null){var y={hasValue:!1,value:null};x.current=y}else y=x.current;x=l(function(){function v(C){if(!E){if(E=!0,w=C,C=g(C),p!==void 0&&y.hasValue){var T=y.value;if(p(T,C))return A=T}return A=C}if(T=A,r(w,C))return T;var O=g(C);return p!==void 0&&p(T,O)?(w=C,T):(w=C,A=O)}var E=!1,w,A,N=f===void 0?null:f;return[function(){return v(d())},N===null?void 0:function(){return v(N())}]},[d,f,g,p]);var b=i(u,x[0],x[1]);return o(function(){y.hasValue=!0,y.value=b},[b]),c(b),b},WA}var Cz;function cme(){return Cz||(Cz=1,GA.exports=lme()),GA.exports}var YW=cme(),zR=S.createContext(null),ume=t=>t,xr=()=>{var t=S.useContext(zR);return t?t.store.dispatch:ume},w1=()=>{},dme=()=>w1,hme=(t,e)=>t===e;function Rt(t){var e=S.useContext(zR);return YW.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:dme,e?e.store.getState:w1,e?e.store.getState:w1,e?t:w1,hme)}function fme(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function mme(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function pme(t,e="expected all items to be functions, instead received the following types: "){if(!t.every(n=>typeof n=="function")){const n=t.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${e}[${n}]`)}}var kz=t=>Array.isArray(t)?t:[t];function gme(t){const e=Array.isArray(t[0])?t[0]:t;return pme(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function xme(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var bme=class{constructor(t){this.value=t}deref(){return this.value}},yme=typeof WeakRef<"u"?WeakRef:bme,vme=0,jz=1;function Fv(){return{s:vme,v:void 0,o:null,p:null}}function ZW(t,e={}){let n=Fv();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,g=c;f<g;f++){const p=arguments[f];if(typeof p=="function"||typeof p=="object"&&p!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const y=x.get(p);y===void 0?(l=Fv(),x.set(p,l)):l=y}else{let x=l.p;x===null&&(l.p=x=new Map);const y=x.get(p);y===void 0?(l=Fv(),x.set(p,l)):l=y}}const u=l;let d;if(l.s===jz)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 yme(d):d}return u.s=jz,u.v=d,d}return o.clearCache=()=>{n=Fv(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function _me(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()),fme(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:g=[],argsMemoize:p=ZW,argsMemoizeOptions:x=[]}=d,y=kz(g),b=kz(x),v=gme(i),E=f(function(){return a++,u.apply(null,arguments)},...y),w=p(function(){o++;const N=xme(v,arguments);return l=E.apply(null,N),l},...b);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:v,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:p})};return Object.assign(r,{withTypes:()=>r}),r}var Qe=_me(ZW),wme=Object.assign((t,e=Qe)=>{mme(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:()=>wme}),qA={},KA={},XA={},Pz;function Sme(){return Pz||(Pz=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})(XA)),XA}var YA={},ZA={},Rz;function QW(){return Rz||(Rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(ZA)),ZA}var Dz;function Mme(){return Dz||(Dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QW(),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})(YA)),YA}var Oz;function Eme(){return Oz||(Oz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Sme(),n=Mme(),r=OR();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(p=>String(p));const u=(p,x)=>{let y=p;for(let b=0;b<x.length&&y!=null;++b)y=y[x[b]];return y},d=(p,x)=>x==null||p==null?x:typeof p=="object"&&"key"in p?Object.hasOwn(x,p.key)?x[p.key]:u(x,p.path):typeof p=="function"?p(x):Array.isArray(p)?u(x,p):typeof x=="object"?x[p]:x,f=o.map(p=>(Array.isArray(p)&&p.length===1&&(p=p[0]),p==null||typeof p=="function"||Array.isArray(p)||n.isKey(p)?p:{key:p,path:r.toPath(p)}));return a.map(p=>({original:p,criteria:f.map(x=>d(x,p))})).slice().sort((p,x)=>{for(let y=0;y<f.length;y++){const b=e.compareValues(p.criteria[y],x.criteria[y],l[y]);if(b!==0)return b}return 0}).map(p=>p.original)}t.orderBy=i})(KA)),KA}var QA={},Lz;function Nme(){return Lz||(Lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(QA)),QA}var JA={},Iz;function JW(){return Iz||(Iz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KW(),n=UR(),r=BW(),i=$W();function a(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],o):!1}t.isIterateeCall=a})(JA)),JA}var Fz;function Ame(){return Fz||(Fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Eme(),n=Nme(),r=JW();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})(qA)),qA}var eT,Uz;function Tme(){return Uz||(Uz=1,eT=Ame().sortBy),eT}var Cme=Tme();const _M=_o(Cme);var eq=t=>t.legend.settings,kme=t=>t.legend.size,jme=t=>t.legend.payload,Pme=Qe([jme,eq],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?_M(r,n):r});function Rme(){return Rt(Pme)}var Uv=1;function tq(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=S.useState({height:0,left:0,top:0,width:0}),r=S.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>Uv||Math.abs(o.left-e.left)>Uv||Math.abs(o.top-e.top)>Uv||Math.abs(o.width-e.width)>Uv)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function aa(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var Dme=typeof Symbol=="function"&&Symbol.observable||"@@observable",zz=Dme,tT=()=>Math.random().toString(36).substring(7).split("").join("."),Ome={INIT:`@@redux/INIT${tT()}`,REPLACE:`@@redux/REPLACE${tT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${tT()}`},lw=Ome;function BR(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function nq(t,e,n){if(typeof t!="function")throw new Error(aa(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(aa(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(aa(1));return n(nq)(t,e)}let r=t,i=e,a=new Map,o=a,l=0,c=!1;function u(){o===a&&(o=new Map,a.forEach((b,v)=>{o.set(v,b)}))}function d(){if(c)throw new Error(aa(3));return i}function f(b){if(typeof b!="function")throw new Error(aa(4));if(c)throw new Error(aa(5));let v=!0;u();const E=l++;return o.set(E,b),function(){if(v){if(c)throw new Error(aa(6));v=!1,u(),o.delete(E),a=null}}}function g(b){if(!BR(b))throw new Error(aa(7));if(typeof b.type>"u")throw new Error(aa(8));if(typeof b.type!="string")throw new Error(aa(17));if(c)throw new Error(aa(9));try{c=!0,i=r(i,b)}finally{c=!1}return(a=o).forEach(E=>{E()}),b}function p(b){if(typeof b!="function")throw new Error(aa(10));r=b,g({type:lw.REPLACE})}function x(){const b=f;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(aa(11));function E(){const A=v;A.next&&A.next(d())}return E(),{unsubscribe:b(E)}},[zz](){return this}}}return g({type:lw.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:p,[zz]:x}}function Lme(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:lw.INIT})>"u")throw new Error(aa(12));if(typeof n(void 0,{type:lw.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(aa(13))})}function rq(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{Lme(n)}catch(a){i=a}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],g=n[f],p=o[f],x=g(p,l);if(typeof x>"u")throw l&&l.type,new Error(aa(14));u[f]=x,c=c||x!==p}return c=c||r.length!==Object.keys(o).length,c?u:o}}function cw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function Ime(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(aa(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=cw(...l)(i.dispatch),{...i,dispatch:a}}}function iq(t){return BR(t)&&"type"in t&&typeof t.type=="string"}var aq=Symbol.for("immer-nothing"),Bz=Symbol.for("immer-draftable"),Ba=Symbol.for("immer-state");function Do(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Ps=Object,Fp=Ps.getPrototypeOf,uw="constructor",wM="prototype",S3="configurable",dw="enumerable",S1="writable",W0="value",Kc=t=>!!t&&!!t[Ba];function Ko(t){return t?sq(t)||SM(t)||!!t[Bz]||!!t[uw]?.[Bz]||MM(t)||EM(t):!1}var Fme=Ps[wM][uw].toString(),Hz=new WeakMap;function sq(t){if(!t||!HR(t))return!1;const e=Fp(t);if(e===null||e===Ps[wM])return!0;const n=Ps.hasOwnProperty.call(e,uw)&&e[uw];if(n===Object)return!0;if(!ip(n))return!1;let r=Hz.get(n);return r===void 0&&(r=Function.toString.call(n),Hz.set(n,r)),r===Fme}function Bb(t,e,n=!0){Hb(t)===0?(n?Reflect.ownKeys(t):Ps.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Hb(t){const e=t[Ba];return e?e.type_:SM(t)?1:MM(t)?2:EM(t)?3:0}var $z=(t,e,n=Hb(t))=>n===2?t.has(e):Ps[wM].hasOwnProperty.call(t,e),M3=(t,e,n=Hb(t))=>n===2?t.get(e):t[e],hw=(t,e,n,r=Hb(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function Ume(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var SM=Array.isArray,MM=t=>t instanceof Map,EM=t=>t instanceof Set,HR=t=>typeof t=="object",ip=t=>typeof t=="function",nT=t=>typeof t=="boolean",wc=t=>t.copy_||t.base_,$R=t=>t.modified_?t.copy_:t.base_;function E3(t,e){if(MM(t))return new Map(t);if(EM(t))return new Set(t);if(SM(t))return Array[wM].slice.call(t);const n=sq(t);if(e===!0||e==="class_only"&&!n){const r=Ps.getOwnPropertyDescriptors(t);delete r[Ba];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[S1]===!1&&(l[S1]=!0,l[S3]=!0),(l.get||l.set)&&(r[o]={[S3]:!0,[S1]:!0,[dw]:l[dw],[W0]:t[o]})}return Ps.create(Fp(t),r)}else{const r=Fp(t);if(r!==null&&n)return{...t};const i=Ps.create(r);return Ps.assign(i,t)}}function VR(t,e=!1){return NM(t)||Kc(t)||!Ko(t)||(Hb(t)>1&&Ps.defineProperties(t,{set:zv,add:zv,clear:zv,delete:zv}),Ps.freeze(t),e&&Bb(t,(n,r)=>{VR(r,!0)},!1)),t}function zme(){Do(2)}var zv={[W0]:zme};function NM(t){return t===null||!HR(t)?!0:Ps.isFrozen(t)}var fw="MapSet",N3="Patches",oq={};function Up(t){const e=oq[t];return e||Do(0,t),e}var Bme=t=>!!oq[t],q0,lq=()=>q0,Hme=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Bme(fw)?Up(fw):void 0});function Vz(t,e){e&&(t.patchPlugin_=Up(N3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function A3(t){T3(t),t.drafts_.forEach($me),t.drafts_=null}function T3(t){t===q0&&(q0=t.parent_)}var Gz=t=>q0=Hme(q0,t);function $me(t){const e=t[Ba];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Wz(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Ba].modified_&&(A3(e),Do(4)),Ko(t)&&(t=qz(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Ba].base_,t,e)}else t=qz(e,n);return Vme(e,t,!0),A3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==aq?t:void 0}function qz(t,e){if(NM(e))return e;const n=e[Ba];if(!n)return GR(e,t.handledSet_,t);if(!AM(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);dq(n,t)}return n.copy_}function Vme(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&VR(e,n)}function cq(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var AM=(t,e)=>t.scope_===e,Gme=[];function uq(t,e,n,r){const i=wc(t),a=t.type_;if(r!==void 0&&M3(i,r,a)===e){hw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Bb(i,(c,u)=>{if(Kc(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??Gme;for(const l of o)hw(i,l,n,a)}function Wme(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!AM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=$R(a);uq(t,a.draft_??a,o,n),dq(a,i)})}function dq(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}cq(t)}}function qme(t,e,n){const{scope_:r}=t;if(Kc(n)){const i=n[Ba];AM(i,r)&&i.callbacks_.push(function(){M1(t);const o=$R(i);uq(t,n,o,e)})}else Ko(n)&&t.callbacks_.push(function(){const a=wc(t);M3(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&GR(M3(t.copy_,e,t.type_),r.handledSet_,r)})}function GR(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Kc(t)||e.has(t)||!Ko(t)||NM(t)||(e.add(t),Bb(t,(r,i)=>{if(Kc(i)){const a=i[Ba];if(AM(a,n)){const o=$R(a);hw(t,r,o,t.type_),cq(a)}}else Ko(i)&&GR(i,e,n)})),t}function Kme(t,e){const n=SM(t),r={type_:n?1:0,scope_:e?e.scope_:lq(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=WR;n&&(i=[r],a=K0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var WR={get(t,e){if(e===Ba)return t;const n=wc(t);if(!$z(n,e,t.type_))return Xme(t,n,e);const r=n[e];if(t.finalized_||!Ko(r))return r;if(r===rT(t.base_,e)){M1(t);const i=t.type_===1?+e:e,a=k3(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in wc(t)},ownKeys(t){return Reflect.ownKeys(wc(t))},set(t,e,n){const r=hq(wc(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=rT(wc(t),e),a=i?.[Ba];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(Ume(n,i)&&(n!==void 0||$z(t.base_,e,t.type_)))return!0;M1(t),C3(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),qme(t,e,n)),!0},deleteProperty(t,e){return M1(t),rT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),C3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=wc(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[S1]:!0,[S3]:t.type_!==1||e!=="length",[dw]:r[dw],[W0]:n[e]}},defineProperty(){Do(11)},getPrototypeOf(t){return Fp(t.base_)},setPrototypeOf(){Do(12)}},K0={};Bb(WR,(t,e)=>{K0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});K0.deleteProperty=function(t,e){return K0.set.call(this,t,e,void 0)};K0.set=function(t,e,n){return WR.set.call(this,t[0],e,n,t[0])};function rT(t,e){const n=t[Ba];return(n?wc(n):t)[e]}function Xme(t,e,n){const r=hq(e,n);return r?W0 in r?r[W0]:r.get?.call(t.draft_):void 0}function hq(t,e){if(!(e in t))return;let n=Fp(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Fp(n)}}function C3(t){t.modified_||(t.modified_=!0,t.parent_&&C3(t.parent_))}function M1(t){t.copy_||(t.assigned_=new Map,t.copy_=E3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Yme=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(ip(n)&&!ip(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}ip(r)||Do(6),i!==void 0&&!ip(i)&&Do(7);let a;if(Ko(n)){const o=Gz(this),l=k3(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?A3(o):T3(o)}return Vz(o,i),Wz(a,o)}else if(!n||!HR(n)){if(a=r(n),a===void 0&&(a=n),a===aq&&(a=void 0),this.autoFreeze_&&VR(a,!0),i){const o=[],l=[];Up(N3).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else Do(1,n)},this.produceWithPatches=(n,r)=>{if(ip(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]},nT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),nT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),nT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ko(e)||Do(8),Kc(e)&&(e=$o(e));const n=Gz(this),r=k3(n,e,void 0);return r[Ba].isManual_=!0,T3(n),r}finishDraft(e,n){const r=e&&e[Ba];(!r||!r.isManual_)&&Do(9);const{scope_:i}=r;return Vz(i,n),Wz(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=Up(N3).applyPatches_;return Kc(e)?i(e,n):this.produce(e,a=>i(a,n))}};function k3(t,e,n,r){const[i,a]=MM(e)?Up(fw).proxyMap_(e,n):EM(e)?Up(fw).proxySet_(e,n):Kme(e,n);return(n?.scope_??lq()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Wme(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function $o(t){return Kc(t)||Do(10,t),fq(t)}function fq(t){if(!Ko(t)||NM(t))return t;const e=t[Ba];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=E3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=E3(t,!0);return Bb(n,(i,a)=>{hw(n,i,fq(a))},r),e&&(e.finalized_=!1),n}var Zme=new Yme,mq=Zme.produce;function pq(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Qme=pq(),Jme=pq,epe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?cw:cw.apply(null,arguments)};function yo(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Rs(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=>iq(r)&&r.type===t,n}var gq=class Jx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Jx.prototype)}static get[Symbol.species](){return Jx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Jx(...e[0].concat(this)):new Jx(...e.concat(this))}};function Kz(t){return Ko(t)?mq(t,()=>{}):t}function Bv(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function tpe(t){return typeof t=="boolean"}var npe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new gq;return n&&(tpe(n)?o.push(Qme):o.push(Jme(n.extraArgument))),o},xq="RTK_autoBatch",Tr=()=>t=>({payload:t,meta:{[xq]:!0}}),Xz=t=>e=>{setTimeout(e,t)},bq=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:Xz(10):t.type==="callback"?t.queueNotification:Xz(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),g=r.subscribe(f);return l.add(d),()=>{g(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[xq],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},rpe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new gq(t);return r&&i.push(bq(typeof r=="object"?r:void 0)),i};function ipe(t){const e=npe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(BR(n))l=rq(n);else throw new Error(Rs(1));let c;typeof r=="function"?c=r(e):c=e();let u=cw;i&&(u=epe({trace:!1,...typeof i=="object"&&i}));const d=Ime(...c),f=rpe(d);let g=typeof o=="function"?o(f):f();const p=u(...g);return nq(l,a,p)}function yq(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Rs(28));if(l in e)throw new Error(Rs(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 ape(t){return typeof t=="function"}function spe(t,e){let[n,r,i]=yq(e),a;if(ape(t))a=()=>Kz(t());else{const l=Kz(t);a=()=>l}function o(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Kc(d)){const p=f(d,c);return p===void 0?d:p}else{if(Ko(d))return mq(d,g=>f(g,c));{const g=f(d,c);if(g===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return g}}return d},l)}return o.getInitialState=a,o}var ope="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",lpe=(t=21)=>{let e="",n=t;for(;n--;)e+=ope[Math.random()*64|0];return e},cpe=Symbol.for("rtk-slice-createasyncthunk");function upe(t,e){return`${t}/${e}`}function dpe({creators:t}={}){const e=t?.asyncThunk?.[cpe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Rs(11));const o=(typeof r.reducers=="function"?r.reducers(fpe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,A){const N=typeof w=="string"?w:w.type;if(!N)throw new Error(Rs(12));if(N in c.sliceCaseReducersByType)throw new Error(Rs(13));return c.sliceCaseReducersByType[N]=A,u},addMatcher(w,A){return c.sliceMatchers.push({matcher:w,reducer:A}),u},exposeAction(w,A){return c.actionCreators[w]=A,u},exposeCaseReducer(w,A){return c.sliceCaseReducersByName[w]=A,u}};l.forEach(w=>{const A=o[w],N={reducerName:w,type:upe(i,w),createNotation:typeof r.reducers=="function"};ppe(A)?xpe(N,A,u,e):mpe(N,A,u)});function d(){const[w={},A=[],N=void 0]=typeof r.extraReducers=="function"?yq(r.extraReducers):[r.extraReducers],C={...w,...c.sliceCaseReducersByType};return spe(r.initialState,T=>{for(let O in C)T.addCase(O,C[O]);for(let O of c.sliceMatchers)T.addMatcher(O.matcher,O.reducer);for(let O of A)T.addMatcher(O.matcher,O.reducer);N&&T.addDefaultCase(N)})}const f=w=>w,g=new Map,p=new WeakMap;let x;function y(w,A){return x||(x=d()),x(w,A)}function b(){return x||(x=d()),x.getInitialState()}function v(w,A=!1){function N(T){let O=T[w];return typeof O>"u"&&A&&(O=Bv(p,N,b)),O}function C(T=f){const O=Bv(g,A,()=>new WeakMap);return Bv(O,T,()=>{const k={};for(const[R,z]of Object.entries(r.selectors??{}))k[R]=hpe(z,T,()=>Bv(p,T,b),A);return k})}return{reducerPath:w,getSelectors:C,get selectors(){return C(N)},selectSlice:N}}const E={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:b,...v(a),injectInto(w,{reducerPath:A,...N}={}){const C=A??a;return w.inject({reducerPath:C,reducer:y},N),{...E,...v(C,!0)}}};return E}}function hpe(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 fs=dpe();function fpe(){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 mpe({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!gpe(r))throw new Error(Rs(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?yo(t,o):yo(t))}function ppe(t){return t._reducerDefinitionType==="asyncThunk"}function gpe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function xpe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Rs(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||Hv,pending:l||Hv,rejected:c||Hv,settled:u||Hv})}function Hv(){}var bpe="task",vq="listener",_q="completed",qR="cancelled",ype=`task-${qR}`,vpe=`task-${_q}`,j3=`${vq}-${qR}`,_pe=`${vq}-${_q}`,TM=class{constructor(t){this.code=t,this.message=`${bpe} ${qR} (reason: ${t})`}name="TaskAbortError";message},KR=(t,e)=>{if(typeof t!="function")throw new TypeError(Rs(32))},mw=()=>{},wq=(t,e=mw)=>(t.catch(e),t),Sq=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Vh=(t,e)=>{const n=t.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:e,configurable:!0,writable:!0}),t.abort(e))},Gh=t=>{if(t.aborted){const{reason:e}=t;throw new TM(e)}};function Mq(t,e){let n=mw;return new Promise((r,i)=>{const a=()=>i(new TM(t.reason));if(t.aborted){a();return}n=Sq(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=mw})}var wpe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof TM?"cancelled":"rejected",error:n}}finally{e?.()}},pw=t=>e=>wq(Mq(t,e).then(n=>(Gh(t),n))),Eq=t=>{const e=pw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:bp}=Object,Yz={},CM="listenerMiddleware",Spe=(t,e)=>{const n=r=>Sq(t,()=>Vh(r,t.reason));return(r,i)=>{KR(r);const a=new AbortController;n(a);const o=wpe(async()=>{Gh(t),Gh(a.signal);const l=await r({pause:pw(a.signal),delay:Eq(a.signal),signal:a.signal});return Gh(a.signal),l},()=>Vh(a,vpe));return i?.autoJoin&&e.push(o.catch(mw)),{result:pw(t)(o),cancel(){Vh(a,ype)}}}},Mpe=(t,e)=>{const n=async(r,i)=>{Gh(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,g)=>{g.unsubscribe(),c([f,g.getState(),g.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await Mq(e,Promise.race(l));return Gh(e),c}finally{a()}};return(r,i)=>wq(n(r,i))},Nq=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=yo(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Rs(21));return KR(a),{predicate:i,type:e,effect:a}},Aq=bp(t=>{const{type:e,predicate:n,effect:r}=Nq(t);return{id:lpe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Rs(22))}}},{withTypes:()=>Aq}),Zz=(t,e)=>{const{type:n,effect:r,predicate:i}=Nq(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},P3=t=>{t.pending.forEach(e=>{Vh(e,j3)})},Epe=(t,e)=>()=>{for(const n of e.keys())P3(n);t.clear()},Qz=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},Tq=bp(yo(`${CM}/add`),{withTypes:()=>Tq}),Npe=yo(`${CM}/removeAll`),Cq=bp(yo(`${CM}/remove`),{withTypes:()=>Cq}),Ape=(...t)=>{console.error(`${CM}/error`,...t)},$b=(t={})=>{const e=new Map,n=new Map,r=p=>{const x=n.get(p)??0;n.set(p,x+1)},i=p=>{const x=n.get(p)??1;x===1?n.delete(p):n.set(p,x-1)},{extra:a,onError:o=Ape}=t;KR(o);const l=p=>(p.unsubscribe=()=>e.delete(p.id),e.set(p.id,p),x=>{p.unsubscribe(),x?.cancelActive&&P3(p)}),c=p=>{const x=Zz(e,p)??Aq(p);return l(x)};bp(c,{withTypes:()=>c});const u=p=>{const x=Zz(e,p);return x&&(x.unsubscribe(),p.cancelActive&&P3(x)),!!x};bp(u,{withTypes:()=>u});const d=async(p,x,y,b)=>{const v=new AbortController,E=Mpe(c,v.signal),w=[];try{p.pending.add(v),r(p),await Promise.resolve(p.effect(x,bp({},y,{getOriginalState:b,condition:(A,N)=>E(A,N).then(Boolean),take:E,delay:Eq(v.signal),pause:pw(v.signal),extra:a,signal:v.signal,fork:Spe(v.signal,w),unsubscribe:p.unsubscribe,subscribe:()=>{e.set(p.id,p)},cancelActiveListeners:()=>{p.pending.forEach((A,N,C)=>{A!==v&&(Vh(A,j3),C.delete(A))})},cancel:()=>{Vh(v,j3),p.pending.delete(v)},throwIfCancelled:()=>{Gh(v.signal)}})))}catch(A){A instanceof TM||Qz(o,A,{raisedBy:"effect"})}finally{await Promise.all(w),Vh(v,_pe),i(p),p.pending.delete(v)}},f=Epe(e,n);return{middleware:p=>x=>y=>{if(!iq(y))return x(y);if(Tq.match(y))return c(y.payload);if(Npe.match(y)){f();return}if(Cq.match(y))return u(y.payload);let b=p.getState();const v=()=>{if(b===Yz)throw new Error(Rs(23));return b};let E;try{if(E=x(y),e.size>0){const w=p.getState(),A=Array.from(e.values());for(const N of A){let C=!1;try{C=N.predicate(y,w,b)}catch(T){C=!1,Qz(o,T,{raisedBy:"predicate"})}C&&d(N,y,p,v)}}}finally{b=Yz}return E},startListening:c,stopListening:u,clearListeners:f}};function Rs(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 Tpe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},kq=fs({name:"chartLayout",initialState:Tpe,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:Cpe,setLayout:kpe,setChartSize:jpe,setScale:Ppe}=kq.actions,Rpe=kq.reducer;function jq(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Jz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function up(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Jz(Object(n),!0).forEach(function(r){Dpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dpe(t,e,n){return(e=Ope(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ope(t){var e=Lpe(t,"string");return typeof e=="symbol"?e:e+""}function Lpe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Jn(t,e,n){return Nr(t)||Nr(e)?n:bo(e)?mf(t,e,n):typeof e=="function"?e(t):n}var Ipe=(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"&&Ot(t[a]))return up(up({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Ot(t[o]))return up(up({},t),{},{[o]:t[o]+(i||0)})}return t},Ll=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",Pq=(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},Rq=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:g,axisType:p}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,y=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(y=p==="angleAxis"&&a&&a.length>=2?Wi(a[0]-a[1])*2*y:y,f||g){var b=(f||g||[]).map((v,E)=>{var w=r?r.indexOf(v):v;return{coordinate:o(w)+y,value:v,offset:y,index:E}});return b.filter(v=>!hs(v.coordinate))}return c&&u?u.map((v,E)=>({coordinate:o(v)+y,value:v,index:E,offset:y})):o.ticks&&d!=null?o.ticks(d).map((v,E)=>({coordinate:o(v)+y,value:v,offset:y,index:E})):o.domain().map((v,E)=>({coordinate:o(v)+y,value:r?r[v]:v,index:E,offset:y}))},eB=1e-4,Fpe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-eB,a=Math.max(r[0],r[1])+eB,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},Upe=(t,e)=>{if(!e||e.length!==2||!Ot(e[0])||!Ot(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(!Ot(t[0])||t[0]<n)&&(i[0]=n),(!Ot(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},zpe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,o=0;o<e;++o){var l=hs(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=a,t[o][n][1]=a+l,a=t[o][n][1])}},Bpe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var o=hs(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},Hpe={sign:zpe,expand:dfe,none:Ip,silhouette:hfe,wiggle:ffe,positive:Bpe},$pe=(t,e,n)=>{var r=Hpe[n],i=ufe().keys(e).value((a,o)=>Number(Jn(a,o,0))).order(_3).offset(r);return i(t)};function Dq(t){return t==null?void 0:String(t)}function gw(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Nr(i[e.dataKey])){var l=IW(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Jn(i,Nr(o)?e.dataKey:o);return Nr(c)?null:e.scale(c)}var tB=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=Jn(a,e.dataKey,e.scale.domain()[o]);return Nr(l)?null:e.scale(l)-i/2+r},Vpe=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]},Gpe=t=>{var e=t.flat(2).filter(Ot);return[Math.min(...e),Math.max(...e)]},Wpe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],qpe=(t,e,n)=>{if(t!=null)return Wpe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=jq(u,e,n),f=Gpe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},nB=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,rB=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Td=(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=_M(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function iB(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return up(up({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Bd(t,e){if(t)return String(t);if(typeof e=="string")return e}var Kpe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Xpe=(t,e)=>e==="centric"?t.angle:t.radius,nu=t=>t.layout.width,ru=t=>t.layout.height,Ype=t=>t.layout.scale,Oq=t=>t.layout.margin,kM=Qe(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),jM=Qe(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),Lq="data-recharts-item-index",Iq="data-recharts-item-data-key",Vb=60;function aB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $v(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aB(Object(n),!0).forEach(function(r){Zpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zpe(t,e,n){return(e=Qpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qpe(t){var e=Jpe(t,"string");return typeof e=="symbol"?e:e+""}function Jpe(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 ege=t=>t.brush.height;function tge(t){var e=jM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Vb;return n+i}return n},0)}function nge(t){var e=jM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Vb;return n+i}return n},0)}function rge(t){var e=kM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function ige(t){var e=kM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ki=Qe([nu,ru,Oq,ege,tge,nge,rge,ige,eq,kme],(t,e,n,r,i,a,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},g=$v($v({},f),d),p=g.bottom;g.bottom+=r,g=Ipe(g,c,u);var x=t-g.left-g.right,y=e-g.top-g.bottom;return $v($v({brushBottom:p},g),{},{width:Math.max(x,0),height:Math.max(y,0)})}),age=Qe(ki,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),XR=Qe(nu,ru,(t,e)=>({x:0,y:0,width:t,height:e})),sge=S.createContext(null),ji=()=>S.useContext(sge)!=null,PM=t=>t.brush,RM=Qe([PM,ki,Oq],(t,e,n)=>({height:t.height,x:Ot(t.x)?t.x:e.left,y:Ot(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ot(t.width)?t.width:e.width})),iT={},aT={},sT={},sB;function oge(){return sB||(sB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),y()};let g=null;const p=()=>{g!=null&&clearTimeout(g),g=setTimeout(()=>{g=null,f()},r)},x=()=>{g!==null&&(clearTimeout(g),g=null)},y=()=>{x(),o=void 0,l=null},b=()=>{d()},v=function(...E){if(i?.aborted)return;o=this,l=E;const w=g==null;p(),c&&w&&d()};return v.schedule=p,v.cancel=y,v.flush=b,i?.addEventListener("abort",y,{once:!0}),v}t.debounce=e})(sT)),sT}var oB;function lge(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oge();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const g=e.debounce(function(...y){d=r.apply(this,y),f=null},i,{edges:u}),p=function(...y){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,y),f=Date.now(),g.cancel(),g.schedule(),d):(g.apply(this,y),d)},x=()=>(g.flush(),d);return p.cancel=g.cancel,p.flush=x,p}t.debounce=n})(aT)),aT}var lB;function cge(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lge();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})(iT)),iT}var oT,cB;function uge(){return cB||(cB=1,oT=cge().throttle),oT}var dge=uge();const hge=_o(dge);var xw=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++]))}},Fq=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=qc(r)?t:Number(r),c=qc(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}},fge={width:0,height:0,overflow:"visible"},mge={width:0,overflowX:"visible"},pge={height:0,overflowY:"visible"},gge={},xge=t=>{var{width:e,height:n}=t,r=qc(e),i=qc(n);return r&&i?fge:r?mge:i?pge:gge};function bge(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function er(t){return Number.isFinite(t)}function El(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function R3(){return R3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},R3.apply(null,arguments)}function uB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function dB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uB(Object(n),!0).forEach(function(r){yge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yge(t,e,n){return(e=vge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vge(t){var e=_ge(t,"string");return typeof e=="symbol"?e:e+""}function _ge(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 Uq=S.createContext({width:-1,height:-1});function wge(t){return El(t.width)&&El(t.height)}function zq(t){var{children:e,width:n,height:r}=t,i=S.useMemo(()=>({width:n,height:r}),[n,r]);return wge(i)?S.createElement(Uq.Provider,{value:i},e):null}var YR=()=>S.useContext(Uq),Sge=S.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:g,onResize:p,style:x={}}=t,y=S.useRef(null),b=S.useRef();b.current=p,S.useImperativeHandle(e,()=>y.current);var[v,E]=S.useState({containerWidth:r.width,containerHeight:r.height}),w=S.useCallback((O,k)=>{E(R=>{var z=Math.round(O),D=Math.round(k);return R.containerWidth===z&&R.containerHeight===D?R:{containerWidth:z,containerHeight:D}})},[]);S.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return Ub;var O=D=>{var K,{width:P,height:W}=D[0].contentRect;w(P,W),(K=b.current)===null||K===void 0||K.call(b,P,W)};d>0&&(O=hge(O,d,{trailing:!0,leading:!1}));var k=new ResizeObserver(O),{width:R,height:z}=y.current.getBoundingClientRect();return w(R,z),k.observe(y.current),()=>{k.disconnect()}},[w,d]);var{containerWidth:A,containerHeight:N}=v;xw(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:T}=Fq(A,N,{width:i,height:a,aspect:n,maxHeight:c});return xw(C!=null&&C>0||T!=null&&T>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,C,T,i,a,o,l,n),S.createElement("div",{id:f?"".concat(f):void 0,className:In("recharts-responsive-container",g),style:dB(dB({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:y},S.createElement("div",{style:xge({width:i,height:a})},S.createElement(zq,{width:C,height:T},u)))}),E1=S.forwardRef((t,e)=>{var n=YR();if(El(n.width)&&El(n.height))return t.children;var{width:r,height:i}=bge({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=Fq(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ot(a)&&Ot(o)?S.createElement(zq,{width:a,height:o},t.children):S.createElement(Sge,R3({},t,{width:r,height:i,ref:e}))});function Bq(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 Gb=()=>{var t,e=ji(),n=Rt(age),r=Rt(RM),i=(t=Rt(PM))===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}},Mge={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Hq=()=>{var t;return(t=Rt(ki))!==null&&t!==void 0?t:Mge},ZR=()=>Rt(nu),QR=()=>Rt(ru),Ege=()=>Rt(t=>t.layout.margin),kn=t=>t.layout.layoutType,jf=()=>Rt(kn),Nge=()=>{var t=jf();if(t==="horizontal"||t==="vertical")return t},Age=()=>{var t=jf();return t!==void 0},DM=t=>{var e=xr(),n=ji(),{width:r,height:i}=t,a=YR(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),S.useEffect(()=>{!n&&El(o)&&El(l)&&e(jpe({width:o,height:l}))},[e,n,o,l]),null},$q=Symbol.for("immer-nothing"),hB=Symbol.for("immer-draftable"),Is=Symbol.for("immer-state");function Oo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var X0=Object.getPrototypeOf;function zp(t){return!!t&&!!t[Is]}function pf(t){return t?Vq(t)||Array.isArray(t)||!!t[hB]||!!t.constructor?.[hB]||Wb(t)||LM(t):!1}var Tge=Object.prototype.constructor.toString(),fB=new WeakMap;function Vq(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let r=fB.get(n);return r===void 0&&(r=Function.toString.call(n),fB.set(n,r)),r===Tge}function bw(t,e,n=!0){OM(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 OM(t){const e=t[Is];return e?e.type_:Array.isArray(t)?1:Wb(t)?2:LM(t)?3:0}function D3(t,e){return OM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Gq(t,e,n){const r=OM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Cge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Wb(t){return t instanceof Map}function LM(t){return t instanceof Set}function Mh(t){return t.copy_||t.base_}function O3(t,e){if(Wb(t))return new Map(t);if(LM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Vq(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Is];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(X0(t),r)}else{const r=X0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function JR(t,e=!1){return IM(t)||zp(t)||!pf(t)||(OM(t)>1&&Object.defineProperties(t,{set:Vv,add:Vv,clear:Vv,delete:Vv}),Object.freeze(t),e&&Object.values(t).forEach(n=>JR(n,!0))),t}function kge(){Oo(2)}var Vv={value:kge};function IM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var jge={};function gf(t){const e=jge[t];return e||Oo(0,t),e}var Y0;function Wq(){return Y0}function Pge(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function mB(t,e){e&&(gf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function L3(t){I3(t),t.drafts_.forEach(Rge),t.drafts_=null}function I3(t){t===Y0&&(Y0=t.parent_)}function pB(t){return Y0=Pge(Y0,t)}function Rge(t){const e=t[Is];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function gB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Is].modified_&&(L3(e),Oo(4)),pf(t)&&(t=yw(e,t),e.parent_||vw(e,t)),e.patches_&&gf("Patches").generateReplacementPatches_(n[Is].base_,t,e.patches_,e.inversePatches_)):t=yw(e,n,[]),L3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==$q?t:void 0}function yw(t,e,n){if(IM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Is];if(!i)return bw(e,(a,o)=>xB(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return vw(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),bw(o,(c,u)=>xB(t,i,a,c,u,n,l),r),vw(t,a,!1),n&&t.patches_&&gf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function xB(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=IM(i);if(!(l&&!o)){if(zp(i)){const c=a&&e&&e.type_!==3&&!D3(e.assigned_,r)?a.concat(r):void 0,u=yw(t,i,c);if(Gq(n,r,u),zp(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(pf(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;yw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Wb(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&vw(t,i)}}}function vw(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&JR(e,n)}function Dge(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Wq(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=eD;n&&(i=[r],a=Z0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var eD={get(t,e){if(e===Is)return t;const n=Mh(t);if(!D3(n,e))return Oge(t,n,e);const r=n[e];return t.finalized_||!pf(r)?r:r===lT(t.base_,e)?(cT(t),t.copy_[e]=U3(r,t)):r},has(t,e){return e in Mh(t)},ownKeys(t){return Reflect.ownKeys(Mh(t))},set(t,e,n){const r=qq(Mh(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=lT(Mh(t),e),a=i?.[Is];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Cge(n,i)&&(n!==void 0||D3(t.base_,e)))return!0;cT(t),F3(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 lT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,cT(t),F3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Mh(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Oo(11)},getPrototypeOf(t){return X0(t.base_)},setPrototypeOf(){Oo(12)}},Z0={};bw(eD,(t,e)=>{Z0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});Z0.deleteProperty=function(t,e){return Z0.set.call(this,t,e,void 0)};Z0.set=function(t,e,n){return eD.set.call(this,t[0],e,n,t[0])};function lT(t,e){const n=t[Is];return(n?Mh(n):t)[e]}function Oge(t,e,n){const r=qq(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function qq(t,e){if(!(e in t))return;let n=X0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=X0(n)}}function F3(t){t.modified_||(t.modified_=!0,t.parent_&&F3(t.parent_))}function cT(t){t.copy_||(t.copy_=O3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Lge=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"&&Oo(6),r!==void 0&&typeof r!="function"&&Oo(7);let i;if(pf(e)){const a=pB(this),o=U3(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?L3(a):I3(a)}return mB(a,r),gB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===$q&&(i=void 0),this.autoFreeze_&&JR(i,!0),r){const a=[],o=[];gf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Oo(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){pf(t)||Oo(8),zp(t)&&(t=Ige(t));const e=pB(this),n=U3(t,void 0);return n[Is].isManual_=!0,I3(e),n}finishDraft(t,e){const n=t&&t[Is];(!n||!n.isManual_)&&Oo(9);const{scope_:r}=n;return mB(r,e),gB(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=gf("Patches").applyPatches_;return zp(t)?r(t,e):this.produce(t,i=>r(i,e))}};function U3(t,e){const n=Wb(t)?gf("MapSet").proxyMap_(t,e):LM(t)?gf("MapSet").proxySet_(t,e):Dge(t,e);return(e?e.scope_:Wq()).drafts_.push(n),n}function Ige(t){return zp(t)||Oo(10,t),Kq(t)}function Kq(t){if(!pf(t)||IM(t))return t;const e=t[Is];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=O3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=O3(t,!0);return bw(n,(i,a)=>{Gq(n,i,Kq(a))},r),e&&(e.finalized_=!1),n}var Fge=new Lge;Fge.produce;var Uge={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},Xq=fs({name:"legend",initialState:Uge,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:Tr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=$o(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Tr()},removeLegendPayload:{reducer(t,e){var n=$o(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Tr()}}}),{setLegendSize:bB,setLegendSettings:zge,addLegendPayload:Yq,replaceLegendPayload:Zq,removeLegendPayload:Qq}=Xq.actions,Bge=Xq.reducer,Hge=["contextPayload"];function z3(){return z3=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},z3.apply(null,arguments)}function yB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Bp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yB(Object(n),!0).forEach(function(r){$ge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $ge(t,e,n){return(e=Vge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vge(t){var e=Gge(t,"string");return typeof e=="symbol"?e:e+""}function Gge(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 Wge(t,e){if(t==null)return{};var n,r,i=qge(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 qge(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 Kge(t){return t.value}function Xge(t){var{contextPayload:e}=t,n=Wge(t,Hge),r=XW(e,t.payloadUniqBy,Kge),i=Bp(Bp({},n),{},{payload:r});return S.isValidElement(t.content)?S.cloneElement(t.content,i):typeof t.content=="function"?S.createElement(t.content,i):S.createElement(Hfe,i)}function Yge(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}),Bp(Bp({},u),d)}function Zge(t){var e=xr();return S.useEffect(()=>{e(zge(t))},[e,t]),null}function Qge(t){var e=xr();return S.useEffect(()=>(e(bB(t)),()=>{e(bB({width:0,height:0}))}),[e,t]),null}function Jge(t,e,n,r){return t==="vertical"&&Ot(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var exe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function tD(t){var e=Ir(t,exe),n=Rme(),r=Dhe(),i=Ege(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=tq([n]),f=ZR(),g=QR();if(f==null||g==null)return null;var p=f-(i?.left||0)-(i?.right||0),x=Jge(e.layout,o,a,p),y=c?l:Bp(Bp({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},Yge(l,e,i,f,g,u)),l),b=c??r;if(b==null||n==null)return null;var v=S.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},S.createElement(Zge,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&S.createElement(Qge,{width:u.width,height:u.height}),S.createElement(Xge,z3({},e,x,{margin:i,chartWidth:f,chartHeight:g,contextPayload:n})));return Tc.createPortal(v,b)}tD.displayName="Legend";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 vB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function uT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vB(Object(n),!0).forEach(function(r){txe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function txe(t,e,n){return(e=nxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nxe(t){var e=rxe(t,"string");return typeof e=="symbol"?e:e+""}function rxe(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 ixe(t){return Array.isArray(t)&&bo(t[0])&&bo(t[1])?t.join(" ~ "):t}var axe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:g=!1}=t,p=()=>{if(a&&a.length){var N={padding:0,margin:0},C=(l?_M(a,l):a).map((T,O)=>{if(T.type==="none")return null;var k=T.formatter||o||ixe,{value:R,name:z}=T,D=R,K=z;if(k){var P=k(R,z,T,O,a);if(Array.isArray(P))[D,K]=P;else if(P!=null)D=P;else return null}var W=uT({display:"block",paddingTop:4,paddingBottom:4,color:T.color||"#000"},r);return S.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(O),style:W},bo(K)?S.createElement("span",{className:"recharts-tooltip-item-name"},K):null,bo(K)?S.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,S.createElement("span",{className:"recharts-tooltip-item-value"},D),S.createElement("span",{className:"recharts-tooltip-item-unit"},T.unit||""))});return S.createElement("ul",{className:"recharts-tooltip-item-list",style:N},C)}return null},x=uT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=uT({margin:0},i),b=!Nr(d),v=b?d:"",E=In("recharts-default-tooltip",c),w=In("recharts-tooltip-label",u);b&&f&&a!==void 0&&a!==null&&(v=f(d,a));var A=g?{role:"status","aria-live":"assertive"}:{};return S.createElement("div",B3({className:E,style:x},A),S.createElement("p",{className:w,style:y},S.isValidElement(v)?v:"".concat(v)),p())},Ax="recharts-tooltip-wrapper",sxe={visibility:"hidden"};function oxe(t){var{coordinate:e,translateX:n,translateY:r}=t;return In(Ax,{["".concat(Ax,"-right")]:Ot(n)&&e&&Ot(e.x)&&n>=e.x,["".concat(Ax,"-left")]:Ot(n)&&e&&Ot(e.x)&&n<e.x,["".concat(Ax,"-bottom")]:Ot(r)&&e&&Ot(e.y)&&r>=e.y,["".concat(Ax,"-top")]:Ot(r)&&e&&Ot(e.y)&&r<e.y})}function _B(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Ot(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var g=c[r];if(g==null)return 0;if(o[r]){var p=d,x=g;return p<x?Math.max(f,g):Math.max(d,g)}if(u==null)return 0;var y=f+l,b=g+u;return y>b?Math.max(d,g):Math.max(f,g)}function lxe(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 cxe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=_B({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=_B({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=lxe({translateX:d,translateY:f,useTranslate3d:l})):u=sxe,{cssProperties:u,cssClasses:oxe({translateX:d,translateY:f,coordinate:n})}}function wB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Gv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wB(Object(n),!0).forEach(function(r){H3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function H3(t,e,n){return(e=uxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uxe(t){var e=dxe(t,"string");return typeof e=="symbol"?e:e+""}function dxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class hxe extends S.PureComponent{constructor(){super(...arguments),H3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),H3(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:g,viewBox:p,wrapperStyle:x,lastBoundingBox:y,innerRef:b,hasPortalFromProps:v}=this.props,{cssClasses:E,cssProperties:w}=cxe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:y.height,width:y.width},useTranslate3d:g,viewBox:p}),A=v?{}:Gv(Gv({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),N=Gv(Gv({},A),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return S.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:N,ref:b},a)}}var Jq=()=>{var t;return(t=Rt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function $3(){return $3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$3.apply(null,arguments)}function SB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function MB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SB(Object(n),!0).forEach(function(r){fxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fxe(t,e,n){return(e=mxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mxe(t){var e=pxe(t,"string");return typeof e=="symbol"?e:e+""}function pxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var EB={curveBasisClosed:Jhe,curveBasisOpen:efe,curveBasis:Qhe,curveBumpX:Fhe,curveBumpY:Uhe,curveLinearClosed:tfe,curveLinear:yM,curveMonotoneX:nfe,curveMonotoneY:rfe,curveNatural:ife,curveStep:afe,curveStepAfter:ofe,curveStepBefore:sfe},_w=t=>er(t.x)&&er(t.y),NB=t=>t.base!=null&&_w(t.base)&&_w(t),Tx=t=>t.x,Cx=t=>t.y,gxe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Fb(t));return(n==="curveMonotone"||n==="curveBump")&&e?EB["".concat(n).concat(e==="vertical"?"Y":"X")]:EB[n]||yM},xxe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=gxe(e,i),l=a?n.filter(_w):n,c;if(Array.isArray(r)){var u=n.map((p,x)=>MB(MB({},p),{},{base:r[x]}));i==="vertical"?c=Iv().y(Cx).x1(Tx).x0(p=>p.base.x):c=Iv().x(Tx).y1(Cx).y0(p=>p.base.y);var d=c.defined(NB).curve(o),f=a?u.filter(NB):u;return d(f)}i==="vertical"&&Ot(r)?c=Iv().y(Cx).x1(Tx).x0(r):Ot(r)?c=Iv().x(Tx).y1(Cx).y0(r):c=MW().x(Tx).y(Cx);var g=c.defined(_w).curve(o);return g(l)},yp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?xxe(t):r;return S.createElement("path",$3({},za(t),FR(t),{className:In("recharts-curve",e),d:a===null?void 0:a,ref:i}))},bxe=["x","y","top","left","width","height","className"];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 AB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yxe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AB(Object(n),!0).forEach(function(r){vxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vxe(t,e,n){return(e=_xe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _xe(t){var e=wxe(t,"string");return typeof e=="symbol"?e:e+""}function wxe(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 Sxe(t,e){if(t==null)return{};var n,r,i=Mxe(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 Mxe(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 Exe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Nxe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=Sxe(t,bxe),u=yxe({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Ot(e)||!Ot(n)||!Ot(a)||!Ot(o)||!Ot(r)||!Ot(i)?null:S.createElement("path",V3({},fa(u),{className:In("recharts-cross",l),d:Exe(e,n,a,o,r,i)}))};function Axe(t,e,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-i:n.left+.5,y:t==="horizontal"?n.top+.5:e.y-i,width:t==="horizontal"?r:n.width-1,height:t==="horizontal"?n.height-1:r}}function TB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function CB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TB(Object(n),!0).forEach(function(r){Txe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Txe(t,e,n){return(e=Cxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cxe(t){var e=kxe(t,"string");return typeof e=="symbol"?e:e+""}function kxe(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 jxe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),eK=(t,e,n)=>t.map(r=>"".concat(jxe(r)," ").concat(e,"ms ").concat(n)).join(","),Pxe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),Q0=(t,e)=>Object.keys(e).reduce((n,r)=>CB(CB({},n),{},{[r]:t(r,e[r])}),{});function kB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _i(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kB(Object(n),!0).forEach(function(r){Rxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Rxe(t,e,n){return(e=Dxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Dxe(t){var e=Oxe(t,"string");return typeof e=="symbol"?e:e+""}function Oxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var ww=(t,e,n)=>t+(e-t)*n,G3=t=>{var{from:e,to:n}=t;return e!==n},tK=(t,e,n)=>{var r=Q0((i,a)=>{if(G3(a)){var[o,l]=t(a.from,a.to,a.velocity);return _i(_i({},a),{},{from:o,velocity:l})}return a},e);return n<1?Q0((i,a)=>G3(a)?_i(_i({},a),{},{velocity:ww(a.velocity,r[i].velocity,n),from:ww(a.from,r[i].from,n)}):a,e):tK(t,r,n-1)};function Lxe(t,e,n,r,i,a){var o,l=r.reduce((g,p)=>_i(_i({},g),{},{[p]:{from:t[p],velocity:0,to:e[p]}}),{}),c=()=>Q0((g,p)=>p.from,l),u=()=>!Object.values(l).filter(G3).length,d=null,f=g=>{o||(o=g);var p=g-o,x=p/n.dt;l=tK(n,l,x),i(_i(_i(_i({},t),e),c())),o=g,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var g;(g=d)===null||g===void 0||g()})}function Ixe(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,g)=>_i(_i({},f),{},{[g]:[t[g],e[g]]}),{}),u,d=f=>{u||(u=f);var g=(f-u)/r,p=Q0((y,b)=>ww(...b,n(g)),c);if(a(_i(_i(_i({},t),e),p)),g<1)l=o.setTimeout(d);else{var x=Q0((y,b)=>ww(...b,n(1)),c);a(_i(_i(_i({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const Fxe=(t,e,n,r,i,a)=>{var o=Pxe(t,e);return n==null?()=>(i(_i(_i({},t),e)),()=>{}):n.isStepper===!0?Lxe(t,e,n,o,i,a):Ixe(t,e,n,r,o,i,a)};var Sw=1e-4,nK=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],rK=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),jB=(t,e)=>n=>{var r=nK(t,e);return rK(r,n)},Uxe=(t,e)=>n=>{var r=nK(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return rK(i,n)},zxe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=a[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},Bxe=(t,e,n,r)=>{var i=jB(t,n),a=jB(e,r),o=Uxe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,g=0;g<8;++g){var p=i(f)-d,x=o(f);if(Math.abs(p-d)<Sw||x<Sw)return a(f);f=l(f-p/x)}return a(f)};return c.isStepper=!1,c},PB=function(){return Bxe(...zxe(...arguments))},Hxe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,g=c*i/1e3+o;return Math.abs(g-l)<Sw&&Math.abs(f)<Sw?[l,0]:[g,f]};return a.isStepper=!0,a.dt=i,a},$xe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return PB(t);case"spring":return Hxe();default:if(t.split("(")[0]==="cubic-bezier")return PB(t)}return typeof t=="function"?t:null};function Vxe(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 Gxe{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 Wxe(){return Vxe(new Gxe)}var qxe=S.createContext(Wxe);function Kxe(t,e){var n=S.useContext(qxe);return S.useMemo(()=>e??n(t),[t,e,n])}var Xxe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),pg={devToolsEnabled:!1,isSsr:Xxe()},Yxe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},RB={t:0},dT={t:1};function gg(t){var e=Ir(t,Yxe),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!pg.isSsr:n,f=Kxe(e.animationId,e.animationManager),[g,p]=S.useState(d?RB:dT),x=S.useRef(null);return S.useEffect(()=>{d||p(dT)},[d]),S.useEffect(()=>{if(!d||!r)return Ub;var y=Fxe(RB,dT,$xe(a),i,p,f.getTimeoutController()),b=()=>{x.current=y()};return f.start([c,o,b,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,o,c,l,f]),u(g.t)}function xg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=S.useRef(G0(e)),r=S.useRef(t);return r.current!==t&&(n.current=G0(e),r.current=t),n.current}var Zxe=["radius"],Qxe=["radius"];function DB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function OB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?DB(Object(n),!0).forEach(function(r){Jxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):DB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jxe(t,e,n){return(e=e0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e0e(t){var e=t0e(t,"string");return typeof e=="symbol"?e:e+""}function t0e(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 Mw(){return Mw=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},Mw.apply(null,arguments)}function LB(t,e){if(t==null)return{};var n,r,i=n0e(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 n0e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var IB=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,g=4;f<g;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var p=Math.min(a,i);u="M ".concat(t,",").concat(e+o*p,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+l*p,",").concat(e,`
- L `).concat(t+n-l*p,",").concat(e,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*p,`
- L `).concat(t+n,",").concat(e+r-o*p,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t+n-l*p,",").concat(e+r,`
- L `).concat(t+l*p,",").concat(e+r,`
- A `).concat(p,",").concat(p,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*p," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},FB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},iK=t=>{var e=Ir(t,FB),n=S.useRef(null),[r,i]=S.useState(-1);S.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:g,animationBegin:p,isAnimationActive:x,isUpdateAnimationActive:y}=e,b=S.useRef(l),v=S.useRef(c),E=S.useRef(a),w=S.useRef(o),A=S.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),N=xg(A,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=In("recharts-rectangle",d);if(!y){var T=fa(e),{radius:O}=T,k=LB(T,Zxe);return S.createElement("path",Mw({},k,{radius:typeof u=="number"?u:void 0,className:C,d:IB(a,o,l,c,u)}))}var R=b.current,z=v.current,D=E.current,K=w.current,P="0px ".concat(r===-1?1:r,"px"),W="".concat(r,"px 0px"),Z=eK(["strokeDasharray"],g,typeof f=="string"?f:FB.animationEasing);return S.createElement(gg,{animationId:N,key:N,canBegin:r>0,duration:g,easing:f,isActive:y,begin:p},G=>{var Y=Wn(R,l,G),X=Wn(z,c,G),q=Wn(D,a,G),F=Wn(K,o,G);n.current&&(b.current=Y,v.current=X,E.current=q,w.current=F);var V;x?G>0?V={transition:Z,strokeDasharray:W}:V={strokeDasharray:P}:V={strokeDasharray:W};var te=fa(e),{radius:re}=te,ae=LB(te,Qxe);return S.createElement("path",Mw({},ae,{radius:typeof u=="number"?u:void 0,className:C,d:IB(q,F,Y,X,u),ref:n,style:OB(OB({},V),e.style)}))})};function UB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function zB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UB(Object(n),!0).forEach(function(r){r0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function r0e(t,e,n){return(e=i0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i0e(t){var e=a0e(t,"string");return typeof e=="symbol"?e:e+""}function a0e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ew=Math.PI/180,s0e=t=>t*180/Math.PI,fi=(t,e,n,r)=>({x:t+Math.cos(-Ew*r)*n,y:e+Math.sin(-Ew*r)*n}),aK=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},o0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},l0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=o0e({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:s0e(c),angleInRadian:c}},c0e=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}},u0e=(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},d0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=l0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=c0e(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?zB(zB({},e),{},{radius:i,angle:u0e(d,e)}):null};function sK(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=fi(e,n,r,i),l=fi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}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)}var h0e=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Wv=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)/Ew,f=c?i:i+a*d,g=fi(e,n,u,f),p=fi(e,n,r,f),x=c?i-a*d:i,y=fi(e,n,u*Math.cos(d*Ew),x);return{center:g,circleTangency:p,lineTangency:y,theta:d}},oK=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=h0e(a,o),c=a+l,u=fi(e,n,i,a),d=fi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var g=fi(e,n,r,a),p=fi(e,n,r,c);f+="L ".concat(p.x,",").concat(p.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
- `).concat(g.x,",").concat(g.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},f0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Wi(u-c),{circleTangency:f,lineTangency:g,theta:p}=Wv({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:y,theta:b}=Wv({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),v=l?Math.abs(c-u):Math.abs(c-u)-p-b;if(v<0)return o?"M ".concat(g.x,",").concat(g.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):oK({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var E="M ".concat(g.x,",").concat(g.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(v>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
- `);if(r>0){var{circleTangency:w,lineTangency:A,theta:N}=Wv({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:T,theta:O}=Wv({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),k=l?Math.abs(c-u):Math.abs(c-u)-N-O;if(k<0&&a===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(T.x,",").concat(T.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(k>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},m0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},lK=t=>{var e=Ir(t,m0e),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var g=In("recharts-sector",f),p=a-i,x=Ea(o,p,0,!0),y;return x>0&&Math.abs(u-d)<360?y=f0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,p/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=oK({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),S.createElement("path",W3({},fa(e),{className:g,d:y}))};function p0e(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(UW(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=fi(r,i,a,l),u=fi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return sK(e)}}var hT={},fT={},mT={},BB;function g0e(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QW();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(mT)),mT}var HB;function x0e(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=g0e();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})(fT)),fT}var $B;function b0e(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=JW(),n=x0e();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})(hT)),hT}var pT,VB;function y0e(){return VB||(VB=1,pT=b0e().range),pT}var v0e=y0e();const cK=_o(v0e);function md(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function _0e(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function nD(t){let e,n,r;t.length!==2?(e=md,n=(l,c)=>md(t(l),c),r=(l,c)=>t(l)-c):(e=t===md||t===_0e?t:w0e,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 w0e(){return 0}function uK(t){return t===null?NaN:+t}function*S0e(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const M0e=nD(md),qb=M0e.right;nD(uK).center;class GB extends Map{constructor(e,n=A0e){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(WB(this,e))}has(e){return super.has(WB(this,e))}set(e,n){return super.set(E0e(this,e),n)}delete(e){return super.delete(N0e(this,e))}}function WB({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function E0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function N0e({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function A0e(t){return t!==null&&typeof t=="object"?t.valueOf():t}function T0e(t=md){if(t===md)return dK;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 dK(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const C0e=Math.sqrt(50),k0e=Math.sqrt(10),j0e=Math.sqrt(2);function Nw(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>=C0e?10:a>=k0e?5:a>=j0e?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?Nw(t,e,n*2):[l,c,u]}function q3(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?Nw(e,t,n):Nw(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 K3(t,e,n){return e=+e,t=+t,n=+n,Nw(t,e,n)[2]}function X3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?K3(e,t,n):K3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function qB(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function KB(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function hK(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?dK:T0e(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),g=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),p=Math.max(n,Math.floor(e-u*f/c+g)),x=Math.min(r,Math.floor(e+(c-u)*f/c+g));hK(t,e,p,x,i)}const a=t[e];let o=n,l=r;for(kx(t,n,e),i(t[r],a)>0&&kx(t,n,r);o<l;){for(kx(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?kx(t,n,l):(++l,kx(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function kx(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function P0e(t,e,n){if(t=Float64Array.from(S0e(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return KB(t);if(e>=1)return qB(t);var r,i=(r-1)*e,a=Math.floor(i),o=qB(hK(t,a).subarray(0,a+1)),l=KB(t.subarray(a+1));return o+(l-o)*(i-a)}}function R0e(t,e,n=uK){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 D0e(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 wo(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function iu(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 Y3=Symbol("implicit");function rD(){var t=new GB,e=[],n=[],r=Y3;function i(a){let o=t.get(a);if(o===void 0){if(r!==Y3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new GB;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return rD(e,n).unknown(r)},wo.apply(i,arguments),i}function iD(){var t=rD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var g=e().length,p=i<r,x=p?i:r,y=p?r:i;a=(y-x)/Math.max(1,g-c+u*2),l&&(a=Math.floor(a)),x+=(y-x-a*(g-c))*d,o=a*(1-c),l&&(x=Math.round(x),o=Math.round(o));var b=D0e(g).map(function(v){return x+a*v});return n(p?b.reverse():b)}return t.domain=function(g){return arguments.length?(e(g),f()):e()},t.range=function(g){return arguments.length?([r,i]=g,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(g){return[r,i]=g,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(g){return arguments.length?(l=!!g,f()):l},t.padding=function(g){return arguments.length?(c=Math.min(1,u=+g),f()):c},t.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),f()):c},t.paddingOuter=function(g){return arguments.length?(u=+g,f()):u},t.align=function(g){return arguments.length?(d=Math.max(0,Math.min(1,g)),f()):d},t.copy=function(){return iD(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},wo.apply(f(),arguments)}function fK(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return fK(e())},t}function O0e(){return fK(iD.apply(null,arguments).paddingInner(1))}function aD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function mK(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Kb(){}var J0=.7,Aw=1/J0,vp="\\s*([+-]?\\d+)\\s*",eb="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_l="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",L0e=/^#([0-9a-f]{3,8})$/,I0e=new RegExp(`^rgb\\(${vp},${vp},${vp}\\)$`),F0e=new RegExp(`^rgb\\(${_l},${_l},${_l}\\)$`),U0e=new RegExp(`^rgba\\(${vp},${vp},${vp},${eb}\\)$`),z0e=new RegExp(`^rgba\\(${_l},${_l},${_l},${eb}\\)$`),B0e=new RegExp(`^hsl\\(${eb},${_l},${_l}\\)$`),H0e=new RegExp(`^hsla\\(${eb},${_l},${_l},${eb}\\)$`),XB={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};aD(Kb,tb,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:YB,formatHex:YB,formatHex8:$0e,formatHsl:V0e,formatRgb:ZB,toString:ZB});function YB(){return this.rgb().formatHex()}function $0e(){return this.rgb().formatHex8()}function V0e(){return pK(this).formatHsl()}function ZB(){return this.rgb().formatRgb()}function tb(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=L0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?QB(e):n===3?new as(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?qv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?qv(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=I0e.exec(t))?new as(e[1],e[2],e[3],1):(e=F0e.exec(t))?new as(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=U0e.exec(t))?qv(e[1],e[2],e[3],e[4]):(e=z0e.exec(t))?qv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=B0e.exec(t))?t8(e[1],e[2]/100,e[3]/100,1):(e=H0e.exec(t))?t8(e[1],e[2]/100,e[3]/100,e[4]):XB.hasOwnProperty(t)?QB(XB[t]):t==="transparent"?new as(NaN,NaN,NaN,0):null}function QB(t){return new as(t>>16&255,t>>8&255,t&255,1)}function qv(t,e,n,r){return r<=0&&(t=e=n=NaN),new as(t,e,n,r)}function G0e(t){return t instanceof Kb||(t=tb(t)),t?(t=t.rgb(),new as(t.r,t.g,t.b,t.opacity)):new as}function Z3(t,e,n,r){return arguments.length===1?G0e(t):new as(t,e,n,r??1)}function as(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}aD(as,Z3,mK(Kb,{brighter(t){return t=t==null?Aw:Math.pow(Aw,t),new as(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?J0:Math.pow(J0,t),new as(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new as(Wh(this.r),Wh(this.g),Wh(this.b),Tw(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:JB,formatHex:JB,formatHex8:W0e,formatRgb:e8,toString:e8}));function JB(){return`#${Oh(this.r)}${Oh(this.g)}${Oh(this.b)}`}function W0e(){return`#${Oh(this.r)}${Oh(this.g)}${Oh(this.b)}${Oh((isNaN(this.opacity)?1:this.opacity)*255)}`}function e8(){const t=Tw(this.opacity);return`${t===1?"rgb(":"rgba("}${Wh(this.r)}, ${Wh(this.g)}, ${Wh(this.b)}${t===1?")":`, ${t})`}`}function Tw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Wh(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Oh(t){return t=Wh(t),(t<16?"0":"")+t.toString(16)}function t8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Lo(t,e,n,r)}function pK(t){if(t instanceof Lo)return new Lo(t.h,t.s,t.l,t.opacity);if(t instanceof Kb||(t=tb(t)),!t)return new Lo;if(t instanceof Lo)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 Lo(o,l,c,t.opacity)}function q0e(t,e,n,r){return arguments.length===1?pK(t):new Lo(t,e,n,r??1)}function Lo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}aD(Lo,q0e,mK(Kb,{brighter(t){return t=t==null?Aw:Math.pow(Aw,t),new Lo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?J0:Math.pow(J0,t),new Lo(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new as(gT(t>=240?t-240:t+120,i,r),gT(t,i,r),gT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Lo(n8(this.h),Kv(this.s),Kv(this.l),Tw(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=Tw(this.opacity);return`${t===1?"hsl(":"hsla("}${n8(this.h)}, ${Kv(this.s)*100}%, ${Kv(this.l)*100}%${t===1?")":`, ${t})`}`}}));function n8(t){return t=(t||0)%360,t<0?t+360:t}function Kv(t){return Math.max(0,Math.min(1,t||0))}function gT(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const sD=t=>()=>t;function K0e(t,e){return function(n){return t+n*e}}function X0e(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 Y0e(t){return(t=+t)==1?gK:function(e,n){return n-e?X0e(e,n,t):sD(isNaN(e)?n:e)}}function gK(t,e){var n=e-t;return n?K0e(t,n):sD(isNaN(t)?e:t)}const r8=(function t(e){var n=Y0e(e);function r(i,a){var o=n((i=Z3(i)).r,(a=Z3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=gK(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 Z0e(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 Q0e(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function J0e(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]=bg(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 ebe(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Cw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function tbe(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]=bg(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var Q3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xT=new RegExp(Q3.source,"g");function nbe(t){return function(){return t}}function rbe(t){return function(e){return t(e)+""}}function ibe(t,e){var n=Q3.lastIndex=xT.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=Q3.exec(t))&&(i=xT.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:Cw(r,i)})),n=xT.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?rbe(c[0].x):nbe(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 bg(t,e){var n=typeof e,r;return e==null||n==="boolean"?sD(e):(n==="number"?Cw:n==="string"?(r=tb(e))?(e=r,r8):ibe:e instanceof tb?r8:e instanceof Date?ebe:Q0e(e)?Z0e:Array.isArray(e)?J0e:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?tbe:Cw)(t,e)}function oD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function abe(t,e){e===void 0&&(e=t,t=bg);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 sbe(t){return function(){return t}}function kw(t){return+t}var i8=[0,1];function Ia(t){return t}function J3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:sbe(isNaN(e)?NaN:.5)}function obe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function lbe(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=J3(i,r),a=n(o,a)):(r=J3(r,i),a=n(a,o)),function(l){return a(r(l))}}function cbe(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]=J3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=qb(t,l,1,r)-1;return a[c](i[c](l))}}function Xb(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function FM(){var t=i8,e=i8,n=bg,r,i,a,o=Ia,l,c,u;function d(){var g=Math.min(t.length,e.length);return o!==Ia&&(o=obe(t[0],t[g-1])),l=g>2?cbe:lbe,c=u=null,f}function f(g){return g==null||isNaN(g=+g)?a:(c||(c=l(t.map(r),e,n)))(r(o(g)))}return f.invert=function(g){return o(i((u||(u=l(e,t.map(r),Cw)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,kw),d()):t.slice()},f.range=function(g){return arguments.length?(e=Array.from(g),d()):e.slice()},f.rangeRound=function(g){return e=Array.from(g),n=oD,d()},f.clamp=function(g){return arguments.length?(o=g?!0:Ia,d()):o!==Ia},f.interpolate=function(g){return arguments.length?(n=g,d()):n},f.unknown=function(g){return arguments.length?(a=g,f):a},function(g,p){return r=g,i=p,d()}}function lD(){return FM()(Ia,Ia)}function ube(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function jw(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Hp(t){return t=jw(Math.abs(t)),t?t[1]:NaN}function dbe(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 hbe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var fbe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function nb(t){if(!(e=fbe.exec(t)))throw new Error("invalid format: "+t);var e;return new cD({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}nb.prototype=cD.prototype;function cD(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}cD.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function mbe(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 xK;function pbe(t,e){var n=jw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(xK=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")+jw(t,Math.max(0,e+a-1))[0]}function a8(t,e){var n=jw(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const s8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:ube,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>a8(t*100,e),r:a8,s:pbe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function o8(t){return t}var l8=Array.prototype.map,c8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function gbe(t){var e=t.grouping===void 0||t.thousands===void 0?o8:dbe(l8.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?o8:hbe(l8.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=nb(f);var g=f.fill,p=f.align,x=f.sign,y=f.symbol,b=f.zero,v=f.width,E=f.comma,w=f.precision,A=f.trim,N=f.type;N==="n"?(E=!0,N="g"):s8[N]||(w===void 0&&(w=12),A=!0,N="g"),(b||g==="0"&&p==="=")&&(b=!0,g="0",p="=");var C=y==="$"?n:y==="#"&&/[boxX]/.test(N)?"0"+N.toLowerCase():"",T=y==="$"?r:/[%p]/.test(N)?o:"",O=s8[N],k=/[defgprs%]/.test(N);w=w===void 0?6:/[gprs]/.test(N)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function R(z){var D=C,K=T,P,W,Z;if(N==="c")K=O(z)+K,z="";else{z=+z;var G=z<0||1/z<0;if(z=isNaN(z)?c:O(Math.abs(z),w),A&&(z=mbe(z)),G&&+z==0&&x!=="+"&&(G=!1),D=(G?x==="("?x:l:x==="-"||x==="("?"":x)+D,K=(N==="s"?c8[8+xK/3]:"")+K+(G&&x==="("?")":""),k){for(P=-1,W=z.length;++P<W;)if(Z=z.charCodeAt(P),48>Z||Z>57){K=(Z===46?i+z.slice(P+1):z.slice(P))+K,z=z.slice(0,P);break}}}E&&!b&&(z=e(z,1/0));var Y=D.length+z.length+K.length,X=Y<v?new Array(v-Y+1).join(g):"";switch(E&&b&&(z=e(X+z,X.length?v-K.length:1/0),X=""),p){case"<":z=D+z+K+X;break;case"=":z=D+X+z+K;break;case"^":z=X.slice(0,Y=X.length>>1)+D+z+K+X.slice(Y);break;default:z=X+D+z+K;break}return a(z)}return R.toString=function(){return f+""},R}function d(f,g){var p=u((f=nb(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Hp(g)/3)))*3,y=Math.pow(10,-x),b=c8[8+x/3];return function(v){return p(y*v)+b}}return{format:u,formatPrefix:d}}var Xv,uD,bK;xbe({thousands:",",grouping:[3],currency:["$",""]});function xbe(t){return Xv=gbe(t),uD=Xv.format,bK=Xv.formatPrefix,Xv}function bbe(t){return Math.max(0,-Hp(Math.abs(t)))}function ybe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Hp(e)/3)))*3-Hp(Math.abs(t)))}function vbe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Hp(e)-Hp(t))+1}function yK(t,e,n,r){var i=X3(t,e,n),a;switch(r=nb(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=ybe(i,o))&&(r.precision=a),bK(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=vbe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=bbe(i))&&(r.precision=a-(r.type==="%")*2);break}}return uD(r)}function Hd(t){var e=t.domain;return t.ticks=function(n){var r=e();return q3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return yK(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=K3(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 vK(){var t=lD();return t.copy=function(){return Xb(t,vK())},wo.apply(t,arguments),Hd(t)}function _K(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,kw),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return _K(t).unknown(e)},t=arguments.length?Array.from(t,kw):[0,1],Hd(n)}function wK(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function u8(t){return Math.log(t)}function d8(t){return Math.exp(t)}function _be(t){return-Math.log(-t)}function wbe(t){return-Math.exp(-t)}function Sbe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function Mbe(t){return t===10?Sbe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function Ebe(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function h8(t){return(e,n)=>-t(-e,n)}function dD(t){const e=t(u8,d8),n=e.domain;let r=10,i,a;function o(){return i=Ebe(r),a=Mbe(r),n()[0]<0?(i=h8(i),a=h8(a),t(_be,wbe)):t(u8,d8),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let g=i(u),p=i(d),x,y;const b=l==null?10:+l;let v=[];if(!(r%1)&&p-g<b){if(g=Math.floor(g),p=Math.ceil(p),u>0){for(;g<=p;++g)for(x=1;x<r;++x)if(y=g<0?x/a(-g):x*a(g),!(y<u)){if(y>d)break;v.push(y)}}else for(;g<=p;++g)for(x=r-1;x>=1;--x)if(y=g>0?x/a(-g):x*a(g),!(y<u)){if(y>d)break;v.push(y)}v.length*2<b&&(v=q3(u,d,b))}else v=q3(g,p,Math.min(p-g,b)).map(a);return f?v.reverse():v},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=nb(c)).precision==null&&(c.trim=!0),c=uD(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(wK(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function SK(){const t=dD(FM()).domain([1,10]);return t.copy=()=>Xb(t,SK()).base(t.base()),wo.apply(t,arguments),t}function f8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function m8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function hD(t){var e=1,n=t(f8(e),m8(e));return n.constant=function(r){return arguments.length?t(f8(e=+r),m8(e)):e},Hd(n)}function MK(){var t=hD(FM());return t.copy=function(){return Xb(t,MK()).constant(t.constant())},wo.apply(t,arguments)}function p8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function Nbe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Abe(t){return t<0?-t*t:t*t}function fD(t){var e=t(Ia,Ia),n=1;function r(){return n===1?t(Ia,Ia):n===.5?t(Nbe,Abe):t(p8(n),p8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Hd(e)}function mD(){var t=fD(FM());return t.copy=function(){return Xb(t,mD()).exponent(t.exponent())},wo.apply(t,arguments),t}function Tbe(){return mD.apply(null,arguments).exponent(.5)}function g8(t){return Math.sign(t)*t*t}function Cbe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function EK(){var t=lD(),e=[0,1],n=!1,r;function i(a){var o=Cbe(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(g8(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,kw)).map(g8)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return EK(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},wo.apply(i,arguments),Hd(i)}function NK(){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]=R0e(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[qb(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(md),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 NK().domain(t).range(e).unknown(r)},wo.apply(a,arguments)}function AK(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[qb(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 AK().domain([t,e]).range(i).unknown(a)},wo.apply(Hd(o),arguments)}function TK(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[qb(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 TK().domain(t).range(e).unknown(n)},wo.apply(i,arguments)}const bT=new Date,yT=new Date;function Pi(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=>Pi(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)=>(bT.setTime(+a),yT.setTime(+o),t(bT),t(yT),Math.floor(n(bT,yT))),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 Pw=Pi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Pw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Pi(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Pw);Pw.range;const Cc=1e3,uo=Cc*60,kc=uo*60,Xc=kc*24,pD=Xc*7,x8=Xc*30,vT=Xc*365,Lh=Pi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Cc)},(t,e)=>(e-t)/Cc,t=>t.getUTCSeconds());Lh.range;const gD=Pi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Cc)},(t,e)=>{t.setTime(+t+e*uo)},(t,e)=>(e-t)/uo,t=>t.getMinutes());gD.range;const xD=Pi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*uo)},(t,e)=>(e-t)/uo,t=>t.getUTCMinutes());xD.range;const bD=Pi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Cc-t.getMinutes()*uo)},(t,e)=>{t.setTime(+t+e*kc)},(t,e)=>(e-t)/kc,t=>t.getHours());bD.range;const yD=Pi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*kc)},(t,e)=>(e-t)/kc,t=>t.getUTCHours());yD.range;const Yb=Pi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*uo)/Xc,t=>t.getDate()-1);Yb.range;const UM=Pi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Xc,t=>t.getUTCDate()-1);UM.range;const CK=Pi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Xc,t=>Math.floor(t/Xc));CK.range;function Pf(t){return Pi(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*uo)/pD)}const zM=Pf(0),Rw=Pf(1),kbe=Pf(2),jbe=Pf(3),$p=Pf(4),Pbe=Pf(5),Rbe=Pf(6);zM.range;Rw.range;kbe.range;jbe.range;$p.range;Pbe.range;Rbe.range;function Rf(t){return Pi(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/pD)}const BM=Rf(0),Dw=Rf(1),Dbe=Rf(2),Obe=Rf(3),Vp=Rf(4),Lbe=Rf(5),Ibe=Rf(6);BM.range;Dw.range;Dbe.range;Obe.range;Vp.range;Lbe.range;Ibe.range;const vD=Pi(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());vD.range;const _D=Pi(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());_D.range;const Yc=Pi(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());Yc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Pi(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)});Yc.range;const Zc=Pi(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());Zc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Pi(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)});Zc.range;function kK(t,e,n,r,i,a){const o=[[Lh,1,Cc],[Lh,5,5*Cc],[Lh,15,15*Cc],[Lh,30,30*Cc],[a,1,uo],[a,5,5*uo],[a,15,15*uo],[a,30,30*uo],[i,1,kc],[i,3,3*kc],[i,6,6*kc],[i,12,12*kc],[r,1,Xc],[r,2,2*Xc],[n,1,pD],[e,1,x8],[e,3,3*x8],[t,1,vT]];function l(u,d,f){const g=d<u;g&&([u,d]=[d,u]);const p=f&&typeof f.range=="function"?f:c(u,d,f),x=p?p.range(u,+d+1):[];return g?x.reverse():x}function c(u,d,f){const g=Math.abs(d-u)/f,p=nD(([,,b])=>b).right(o,g);if(p===o.length)return t.every(X3(u/vT,d/vT,f));if(p===0)return Pw.every(Math.max(X3(u,d,f),1));const[x,y]=o[g/o[p-1][2]<o[p][2]/g?p-1:p];return x.every(y)}return[l,c]}const[Fbe,Ube]=kK(Zc,_D,BM,CK,yD,xD),[zbe,Bbe]=kK(Yc,vD,zM,Yb,bD,gD);function _T(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 wT(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 jx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function Hbe(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Px(i),d=Rx(i),f=Px(a),g=Rx(a),p=Px(o),x=Rx(o),y=Px(l),b=Rx(l),v=Px(c),E=Rx(c),w={a:G,A:Y,b:X,B:q,c:null,d:S8,e:S8,f:dye,g:_ye,G:Sye,H:lye,I:cye,j:uye,L:jK,m:hye,M:fye,p:F,q:V,Q:N8,s:A8,S:mye,u:pye,U:gye,V:xye,w:bye,W:yye,x:null,X:null,y:vye,Y:wye,Z:Mye,"%":E8},A={a:te,A:re,b:ae,B:he,c:null,d:M8,e:M8,f:Tye,g:Fye,G:zye,H:Eye,I:Nye,j:Aye,L:RK,m:Cye,M:kye,p:ue,q:ce,Q:N8,s:A8,S:jye,u:Pye,U:Rye,V:Dye,w:Oye,W:Lye,x:null,X:null,y:Iye,Y:Uye,Z:Bye,"%":E8},N={a:R,A:z,b:D,B:K,c:P,d:_8,e:_8,f:iye,g:v8,G:y8,H:w8,I:w8,j:eye,L:rye,m:Jbe,M:tye,p:k,q:Qbe,Q:sye,s:oye,S:nye,u:qbe,U:Kbe,V:Xbe,w:Wbe,W:Ybe,x:W,X:Z,y:v8,Y:y8,Z:Zbe,"%":aye};w.x=C(n,w),w.X=C(r,w),w.c=C(e,w),A.x=C(n,A),A.X=C(r,A),A.c=C(e,A);function C(fe,pe){return function(_e){var ne=[],He=-1,B=0,H=fe.length,le,$,ee;for(_e instanceof Date||(_e=new Date(+_e));++He<H;)fe.charCodeAt(He)===37&&(ne.push(fe.slice(B,He)),($=b8[le=fe.charAt(++He)])!=null?le=fe.charAt(++He):$=le==="e"?" ":"0",(ee=pe[le])&&(le=ee(_e,$)),ne.push(le),B=He+1);return ne.push(fe.slice(B,He)),ne.join("")}}function T(fe,pe){return function(_e){var ne=jx(1900,void 0,1),He=O(ne,fe,_e+="",0),B,H;if(He!=_e.length)return null;if("Q"in ne)return new Date(ne.Q);if("s"in ne)return new Date(ne.s*1e3+("L"in ne?ne.L:0));if(pe&&!("Z"in ne)&&(ne.Z=0),"p"in ne&&(ne.H=ne.H%12+ne.p*12),ne.m===void 0&&(ne.m="q"in ne?ne.q:0),"V"in ne){if(ne.V<1||ne.V>53)return null;"w"in ne||(ne.w=1),"Z"in ne?(B=wT(jx(ne.y,0,1)),H=B.getUTCDay(),B=H>4||H===0?Dw.ceil(B):Dw(B),B=UM.offset(B,(ne.V-1)*7),ne.y=B.getUTCFullYear(),ne.m=B.getUTCMonth(),ne.d=B.getUTCDate()+(ne.w+6)%7):(B=_T(jx(ne.y,0,1)),H=B.getDay(),B=H>4||H===0?Rw.ceil(B):Rw(B),B=Yb.offset(B,(ne.V-1)*7),ne.y=B.getFullYear(),ne.m=B.getMonth(),ne.d=B.getDate()+(ne.w+6)%7)}else("W"in ne||"U"in ne)&&("w"in ne||(ne.w="u"in ne?ne.u%7:"W"in ne?1:0),H="Z"in ne?wT(jx(ne.y,0,1)).getUTCDay():_T(jx(ne.y,0,1)).getDay(),ne.m=0,ne.d="W"in ne?(ne.w+6)%7+ne.W*7-(H+5)%7:ne.w+ne.U*7-(H+6)%7);return"Z"in ne?(ne.H+=ne.Z/100|0,ne.M+=ne.Z%100,wT(ne)):_T(ne)}}function O(fe,pe,_e,ne){for(var He=0,B=pe.length,H=_e.length,le,$;He<B;){if(ne>=H)return-1;if(le=pe.charCodeAt(He++),le===37){if(le=pe.charAt(He++),$=N[le in b8?pe.charAt(He++):le],!$||(ne=$(fe,_e,ne))<0)return-1}else if(le!=_e.charCodeAt(ne++))return-1}return ne}function k(fe,pe,_e){var ne=u.exec(pe.slice(_e));return ne?(fe.p=d.get(ne[0].toLowerCase()),_e+ne[0].length):-1}function R(fe,pe,_e){var ne=p.exec(pe.slice(_e));return ne?(fe.w=x.get(ne[0].toLowerCase()),_e+ne[0].length):-1}function z(fe,pe,_e){var ne=f.exec(pe.slice(_e));return ne?(fe.w=g.get(ne[0].toLowerCase()),_e+ne[0].length):-1}function D(fe,pe,_e){var ne=v.exec(pe.slice(_e));return ne?(fe.m=E.get(ne[0].toLowerCase()),_e+ne[0].length):-1}function K(fe,pe,_e){var ne=y.exec(pe.slice(_e));return ne?(fe.m=b.get(ne[0].toLowerCase()),_e+ne[0].length):-1}function P(fe,pe,_e){return O(fe,e,pe,_e)}function W(fe,pe,_e){return O(fe,n,pe,_e)}function Z(fe,pe,_e){return O(fe,r,pe,_e)}function G(fe){return o[fe.getDay()]}function Y(fe){return a[fe.getDay()]}function X(fe){return c[fe.getMonth()]}function q(fe){return l[fe.getMonth()]}function F(fe){return i[+(fe.getHours()>=12)]}function V(fe){return 1+~~(fe.getMonth()/3)}function te(fe){return o[fe.getUTCDay()]}function re(fe){return a[fe.getUTCDay()]}function ae(fe){return c[fe.getUTCMonth()]}function he(fe){return l[fe.getUTCMonth()]}function ue(fe){return i[+(fe.getUTCHours()>=12)]}function ce(fe){return 1+~~(fe.getUTCMonth()/3)}return{format:function(fe){var pe=C(fe+="",w);return pe.toString=function(){return fe},pe},parse:function(fe){var pe=T(fe+="",!1);return pe.toString=function(){return fe},pe},utcFormat:function(fe){var pe=C(fe+="",A);return pe.toString=function(){return fe},pe},utcParse:function(fe){var pe=T(fe+="",!0);return pe.toString=function(){return fe},pe}}}var b8={"-":"",_:" ",0:"0"},Yi=/^\s*\d+/,$be=/^%/,Vbe=/[\\^$*+?|[\]().{}]/g;function Hn(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 Gbe(t){return t.replace(Vbe,"\\$&")}function Px(t){return new RegExp("^(?:"+t.map(Gbe).join("|")+")","i")}function Rx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Wbe(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function qbe(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Kbe(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Xbe(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Ybe(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function y8(t,e,n){var r=Yi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function v8(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Zbe(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 Qbe(t,e,n){var r=Yi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Jbe(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function _8(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function eye(t,e,n){var r=Yi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function w8(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function tye(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function nye(t,e,n){var r=Yi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function rye(t,e,n){var r=Yi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function iye(t,e,n){var r=Yi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function aye(t,e,n){var r=$be.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function sye(t,e,n){var r=Yi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function oye(t,e,n){var r=Yi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function S8(t,e){return Hn(t.getDate(),e,2)}function lye(t,e){return Hn(t.getHours(),e,2)}function cye(t,e){return Hn(t.getHours()%12||12,e,2)}function uye(t,e){return Hn(1+Yb.count(Yc(t),t),e,3)}function jK(t,e){return Hn(t.getMilliseconds(),e,3)}function dye(t,e){return jK(t,e)+"000"}function hye(t,e){return Hn(t.getMonth()+1,e,2)}function fye(t,e){return Hn(t.getMinutes(),e,2)}function mye(t,e){return Hn(t.getSeconds(),e,2)}function pye(t){var e=t.getDay();return e===0?7:e}function gye(t,e){return Hn(zM.count(Yc(t)-1,t),e,2)}function PK(t){var e=t.getDay();return e>=4||e===0?$p(t):$p.ceil(t)}function xye(t,e){return t=PK(t),Hn($p.count(Yc(t),t)+(Yc(t).getDay()===4),e,2)}function bye(t){return t.getDay()}function yye(t,e){return Hn(Rw.count(Yc(t)-1,t),e,2)}function vye(t,e){return Hn(t.getFullYear()%100,e,2)}function _ye(t,e){return t=PK(t),Hn(t.getFullYear()%100,e,2)}function wye(t,e){return Hn(t.getFullYear()%1e4,e,4)}function Sye(t,e){var n=t.getDay();return t=n>=4||n===0?$p(t):$p.ceil(t),Hn(t.getFullYear()%1e4,e,4)}function Mye(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Hn(e/60|0,"0",2)+Hn(e%60,"0",2)}function M8(t,e){return Hn(t.getUTCDate(),e,2)}function Eye(t,e){return Hn(t.getUTCHours(),e,2)}function Nye(t,e){return Hn(t.getUTCHours()%12||12,e,2)}function Aye(t,e){return Hn(1+UM.count(Zc(t),t),e,3)}function RK(t,e){return Hn(t.getUTCMilliseconds(),e,3)}function Tye(t,e){return RK(t,e)+"000"}function Cye(t,e){return Hn(t.getUTCMonth()+1,e,2)}function kye(t,e){return Hn(t.getUTCMinutes(),e,2)}function jye(t,e){return Hn(t.getUTCSeconds(),e,2)}function Pye(t){var e=t.getUTCDay();return e===0?7:e}function Rye(t,e){return Hn(BM.count(Zc(t)-1,t),e,2)}function DK(t){var e=t.getUTCDay();return e>=4||e===0?Vp(t):Vp.ceil(t)}function Dye(t,e){return t=DK(t),Hn(Vp.count(Zc(t),t)+(Zc(t).getUTCDay()===4),e,2)}function Oye(t){return t.getUTCDay()}function Lye(t,e){return Hn(Dw.count(Zc(t)-1,t),e,2)}function Iye(t,e){return Hn(t.getUTCFullYear()%100,e,2)}function Fye(t,e){return t=DK(t),Hn(t.getUTCFullYear()%100,e,2)}function Uye(t,e){return Hn(t.getUTCFullYear()%1e4,e,4)}function zye(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Vp(t):Vp.ceil(t),Hn(t.getUTCFullYear()%1e4,e,4)}function Bye(){return"+0000"}function E8(){return"%"}function N8(t){return+t}function A8(t){return Math.floor(+t/1e3)}var xm,OK,LK;Hye({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 Hye(t){return xm=Hbe(t),OK=xm.format,xm.parse,LK=xm.utcFormat,xm.utcParse,xm}function $ye(t){return new Date(t)}function Vye(t){return t instanceof Date?+t:+new Date(+t)}function wD(t,e,n,r,i,a,o,l,c,u){var d=lD(),f=d.invert,g=d.domain,p=u(".%L"),x=u(":%S"),y=u("%I:%M"),b=u("%I %p"),v=u("%a %d"),E=u("%b %d"),w=u("%B"),A=u("%Y");function N(C){return(c(C)<C?p:l(C)<C?x:o(C)<C?y:a(C)<C?b:r(C)<C?i(C)<C?v:E:n(C)<C?w:A)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?g(Array.from(C,Vye)):g().map($ye)},d.ticks=function(C){var T=g();return t(T[0],T[T.length-1],C??10)},d.tickFormat=function(C,T){return T==null?N:u(T)},d.nice=function(C){var T=g();return(!C||typeof C.range!="function")&&(C=e(T[0],T[T.length-1],C??10)),C?g(wK(T,C)):d},d.copy=function(){return Xb(d,wD(t,e,n,r,i,a,o,l,c,u))},d}function Gye(){return wo.apply(wD(zbe,Bbe,Yc,vD,zM,Yb,bD,gD,Lh,OK).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Wye(){return wo.apply(wD(Fbe,Ube,Zc,_D,BM,UM,yD,xD,Lh,LK).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function HM(){var t=0,e=1,n,r,i,a,o=Ia,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(g){var p,x;return arguments.length?([p,x]=g,o=f(p,x),u):[o(0),o(1)]}}return u.range=d(bg),u.rangeRound=d(oD),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function $d(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function IK(){var t=Hd(HM()(Ia));return t.copy=function(){return $d(t,IK())},iu.apply(t,arguments)}function FK(){var t=dD(HM()).domain([1,10]);return t.copy=function(){return $d(t,FK()).base(t.base())},iu.apply(t,arguments)}function UK(){var t=hD(HM());return t.copy=function(){return $d(t,UK()).constant(t.constant())},iu.apply(t,arguments)}function SD(){var t=fD(HM());return t.copy=function(){return $d(t,SD()).exponent(t.exponent())},iu.apply(t,arguments)}function qye(){return SD.apply(null,arguments).exponent(.5)}function zK(){var t=[],e=Ia;function n(r){if(r!=null&&!isNaN(r=+r))return e((qb(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(md),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)=>P0e(t,a/r))},n.copy=function(){return zK(e).domain(t)},iu.apply(n,arguments)}function $M(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=Ia,d,f=!1,g;function p(y){return isNaN(y=+y)?g:(y=.5+((y=+d(y))-a)*(r*y<r*a?l:c),u(f?Math.max(0,Math.min(1,y)):y))}p.domain=function(y){return arguments.length?([t,e,n]=y,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[t,e,n]},p.clamp=function(y){return arguments.length?(f=!!y,p):f},p.interpolator=function(y){return arguments.length?(u=y,p):u};function x(y){return function(b){var v,E,w;return arguments.length?([v,E,w]=b,u=abe(y,[v,E,w]),p):[u(0),u(.5),u(1)]}}return p.range=x(bg),p.rangeRound=x(oD),p.unknown=function(y){return arguments.length?(g=y,p):g},function(y){return d=y,i=y(t),a=y(e),o=y(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function BK(){var t=Hd($M()(Ia));return t.copy=function(){return $d(t,BK())},iu.apply(t,arguments)}function HK(){var t=dD($M()).domain([.1,1,10]);return t.copy=function(){return $d(t,HK()).base(t.base())},iu.apply(t,arguments)}function $K(){var t=hD($M());return t.copy=function(){return $d(t,$K()).constant(t.constant())},iu.apply(t,arguments)}function MD(){var t=fD($M());return t.copy=function(){return $d(t,MD()).exponent(t.exponent())},iu.apply(t,arguments)}function Kye(){return MD.apply(null,arguments).exponent(.5)}const e0=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:iD,scaleDiverging:BK,scaleDivergingLog:HK,scaleDivergingPow:MD,scaleDivergingSqrt:Kye,scaleDivergingSymlog:$K,scaleIdentity:_K,scaleImplicit:Y3,scaleLinear:vK,scaleLog:SK,scaleOrdinal:rD,scalePoint:O0e,scalePow:mD,scaleQuantile:NK,scaleQuantize:AK,scaleRadial:EK,scaleSequential:IK,scaleSequentialLog:FK,scaleSequentialPow:SD,scaleSequentialQuantile:zK,scaleSequentialSqrt:qye,scaleSequentialSymlog:UK,scaleSqrt:Tbe,scaleSymlog:MK,scaleThreshold:TK,scaleTime:Gye,scaleUtc:Wye,tickFormat:yK},Symbol.toStringTag,{value:"Module"}));var Vd=t=>t.chartData,ED=Qe([Vd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Zb=(t,e,n,r)=>r?ED(t):Vd(t);function Cd(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(er(e)&&er(n))return!0}return!1}function T8(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function VK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(er(n))i=n;else if(typeof n=="function")return;if(er(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Cd(o))return o}}function Xye(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Cd(r))return T8(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Ot(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&nB.test(i)){var c=nB.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(Ot(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&rB.test(a)){var d=rB.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var g=[o,l];if(Cd(g))return e==null?g:T8(g,e,n)}}}var yg=1e9,Yye={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},AD,jr=!0,vo="[DecimalError] ",qh=vo+"Invalid argument: ",ND=vo+"Exponent out of range: ",vg=Math.floor,Eh=Math.pow,Zye=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Cs,$i=1e7,Er=7,GK=9007199254740991,Ow=vg(GK/Er),Lt={};Lt.absoluteValue=Lt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Lt.comparedTo=Lt.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};Lt.decimalPlaces=Lt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Er;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Lt.dividedBy=Lt.div=function(t){return Lc(this,new this.constructor(t))};Lt.dividedToIntegerBy=Lt.idiv=function(t){var e=this,n=e.constructor;return gr(Lc(e,new n(t),0,1),n.precision)};Lt.equals=Lt.eq=function(t){return!this.cmp(t)};Lt.exponent=function(){return pi(this)};Lt.greaterThan=Lt.gt=function(t){return this.cmp(t)>0};Lt.greaterThanOrEqualTo=Lt.gte=function(t){return this.cmp(t)>=0};Lt.isInteger=Lt.isint=function(){return this.e>this.d.length-2};Lt.isNegative=Lt.isneg=function(){return this.s<0};Lt.isPositive=Lt.ispos=function(){return this.s>0};Lt.isZero=function(){return this.s===0};Lt.lessThan=Lt.lt=function(t){return this.cmp(t)<0};Lt.lessThanOrEqualTo=Lt.lte=function(t){return this.cmp(t)<1};Lt.logarithm=Lt.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(Cs))throw Error(vo+"NaN");if(n.s<1)throw Error(vo+(n.s?"NaN":"-Infinity"));return n.eq(Cs)?new r(0):(jr=!1,e=Lc(rb(n,a),rb(t,a),a),jr=!0,gr(e,i))};Lt.minus=Lt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?KK(e,t):WK(e,(t.s=-t.s,t))};Lt.modulo=Lt.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(vo+"NaN");return n.s?(jr=!1,e=Lc(n,t,0,1).times(t),jr=!0,n.minus(e)):gr(new r(n),i)};Lt.naturalExponential=Lt.exp=function(){return qK(this)};Lt.naturalLogarithm=Lt.ln=function(){return rb(this)};Lt.negated=Lt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Lt.plus=Lt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?WK(e,t):KK(e,(t.s=-t.s,t))};Lt.precision=Lt.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(qh+t);if(e=pi(i)+1,r=i.d.length-1,n=r*Er+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};Lt.squareRoot=Lt.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(vo+"NaN")}for(t=pi(l),jr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=xl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=vg((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(a=r,r=a.plus(Lc(l,a,o+2)).times(.5),xl(a.d).slice(0,o)===(e=xl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(gr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return jr=!0,gr(r,n)};Lt.times=Lt.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,g=d.d,p=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=g.length,u=p.length,c<u&&(a=g,g=p,p=a,o=c,c=u,u=o),a=[],o=c+u,r=o;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=a[i]+p[r]*g[i-r-1]+e,a[i--]=l%$i|0,e=l/$i|0;a[i]=(a[i]+e)%$i|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,jr?gr(t,f.precision):t};Lt.toDecimalPlaces=Lt.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(Nl(t,0,yg),e===void 0?e=r.rounding:Nl(e,0,8),gr(n,t+pi(n)+1,e))};Lt.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=xf(r,!0):(Nl(t,0,yg),e===void 0?e=i.rounding:Nl(e,0,8),r=gr(new i(r),t+1,e),n=xf(r,!0,t+1)),n};Lt.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?xf(i):(Nl(t,0,yg),e===void 0?e=a.rounding:Nl(e,0,8),r=gr(new a(i),t+pi(i)+1,e),n=xf(r.abs(),!1,t+pi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};Lt.toInteger=Lt.toint=function(){var t=this,e=t.constructor;return gr(new e(t),pi(t)+1,e.rounding)};Lt.toNumber=function(){return+this};Lt.toPower=Lt.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(Cs);if(l=new c(l),!l.s){if(t.s<1)throw Error(vo+"Infinity");return l}if(l.eq(Cs))return l;if(r=c.precision,t.eq(Cs))return gr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=GK){for(i=new c(Cs),e=Math.ceil(r/Er+4),jr=!1;n%2&&(i=i.times(l),k8(i.d,e)),n=vg(n/2),n!==0;)l=l.times(l),k8(l.d,e);return jr=!0,t.s<0?new c(Cs).div(i):gr(i,r)}}else if(a<0)throw Error(vo+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,jr=!1,i=t.times(rb(l,r+u)),jr=!0,i=qK(i),i.s=a,i};Lt.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=pi(i),r=xf(i,n<=a.toExpNeg||n>=a.toExpPos)):(Nl(t,1,yg),e===void 0?e=a.rounding:Nl(e,0,8),i=gr(new a(i),t,e),n=pi(i),r=xf(i,t<=n||n<=a.toExpNeg,t)),r};Lt.toSignificantDigits=Lt.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(Nl(t,1,yg),e===void 0?e=r.rounding:Nl(e,0,8)),gr(new r(n),t,e)};Lt.toString=Lt.valueOf=Lt.val=Lt.toJSON=Lt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=pi(t),n=t.constructor;return xf(t,e<=n.toExpNeg||e>=n.toExpPos)};function WK(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)),jr?gr(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Er),l=o>l?o+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/$i|0,c[a]%=$i;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,jr?gr(e,f):e}function Nl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(qh+t)}function xl(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Er-r.length,n&&(a+=qu(n)),a+=r;o=t[e],r=o+"",n=Er-r.length,n&&(a+=qu(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var Lc=(function(){function t(r,i){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+o,r[l]=a%$i|0,o=a/$i|0;return o&&r.unshift(o),r}function e(r,i,a,o){var l,c;if(a!=o)c=a>o?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]<i[a]?1:0,r[a]=o*$i+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,g,p,x,y,b,v,E,w,A,N,C,T,O,k=r.constructor,R=r.s==i.s?1:-1,z=r.d,D=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(vo+"Division by zero");for(c=r.e-i.e,T=D.length,N=z.length,p=new k(R),x=p.d=[],u=0;D[u]==(z[u]||0);)++u;if(D[u]>(z[u]||0)&&--c,a==null?E=a=k.precision:o?E=a+(pi(r)-pi(i))+1:E=a,E<0)return new k(0);if(E=E/Er+2|0,u=0,T==1)for(d=0,D=D[0],E++;(u<N||d)&&E--;u++)w=d*$i+(z[u]||0),x[u]=w/D|0,d=w%D|0;else{for(d=$i/(D[0]+1)|0,d>1&&(D=t(D,d),z=t(z,d),T=D.length,N=z.length),A=T,y=z.slice(0,T),b=y.length;b<T;)y[b++]=0;O=D.slice(),O.unshift(0),C=D[0],D[1]>=$i/2&&++C;do d=0,l=e(D,y,T,b),l<0?(v=y[0],T!=b&&(v=v*$i+(y[1]||0)),d=v/C|0,d>1?(d>=$i&&(d=$i-1),f=t(D,d),g=f.length,b=y.length,l=e(f,y,g,b),l==1&&(d--,n(f,T<g?O:D,g))):(d==0&&(l=d=1),f=D.slice()),g=f.length,g<b&&f.unshift(0),n(y,f,b),l==-1&&(b=y.length,l=e(D,y,T,b),l<1&&(d++,n(y,T<b?O:D,b))),b=y.length):l===0&&(d++,y=[0]),x[u++]=d,l&&y[0]?y[b++]=z[A]||0:(y=[z[A]],b=1);while((A++<N||y[0]!==void 0)&&E--)}return x[0]||x.shift(),p.e=c,gr(p,o?a+pi(p)+1:a)}})();function qK(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(pi(t)>16)throw Error(ND+pi(t));if(!t.s)return new d(Cs);for(jr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Eh(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(Cs),d.precision=l;;){if(i=gr(i.times(t),l),n=n.times(++c),o=a.plus(Lc(i,n,l)),xl(o.d).slice(0,l)===xl(a.d).slice(0,l)){for(;u--;)a=gr(a.times(a),l);return d.precision=f,e==null?(jr=!0,gr(a,f)):a}a=o}}function pi(t){for(var e=t.e*Er,n=t.d[0];n>=10;n/=10)e++;return e}function ST(t,e,n){if(e>t.LN10.sd())throw jr=!0,n&&(t.precision=n),Error(vo+"LN10 precision limit exceeded");return gr(new t(t.LN10),e)}function qu(t){for(var e="";t--;)e+="0";return e}function rb(t,e){var n,r,i,a,o,l,c,u,d,f=1,g=10,p=t,x=p.d,y=p.constructor,b=y.precision;if(p.s<1)throw Error(vo+(p.s?"NaN":"-Infinity"));if(p.eq(Cs))return new y(0);if(e==null?(jr=!1,u=b):u=e,p.eq(10))return e==null&&(jr=!0),ST(y,u);if(u+=g,y.precision=u,n=xl(x),r=n.charAt(0),a=pi(p),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)p=p.times(t),n=xl(p.d),r=n.charAt(0),f++;a=pi(p),r>1?(p=new y("0."+n),a++):p=new y(r+"."+n.slice(1))}else return c=ST(y,u+2,b).times(a+""),p=rb(new y(r+"."+n.slice(1)),u-g).plus(c),y.precision=b,e==null?(jr=!0,gr(p,b)):p;for(l=o=p=Lc(p.minus(Cs),p.plus(Cs),u),d=gr(p.times(p),u),i=3;;){if(o=gr(o.times(d),u),c=l.plus(Lc(o,new y(i),u)),xl(c.d).slice(0,u)===xl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(ST(y,u+2,b).times(a+""))),l=Lc(l,new y(f),u),y.precision=b,e==null?(jr=!0,gr(l,b)):l;l=c,i+=2}}function C8(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=vg(n/Er),t.d=[],r=(n+1)%Er,n<0&&(r+=Er),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Er;r<i;)t.d.push(+e.slice(r,r+=Er));e=e.slice(r),r=Er-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),jr&&(t.e>Ow||t.e<-Ow))throw Error(ND+n)}else t.s=0,t.e=0,t.d=[0];return t}function gr(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=Er,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Er),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Er,i=r-Er+o}if(n!==void 0&&(a=Eh(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/Eh(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=pi(t),f.length=1,e=e-a-1,f[0]=Eh(10,(Er-e%Er)%Er),t.e=vg(-e/Er)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=Eh(10,Er-r),f[d]=i>0?(u/Eh(10,o-i)%Eh(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==$i&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=$i)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(jr&&(t.e>Ow||t.e<-Ow))throw Error(ND+pi(t));return t}function KK(t,e){var n,r,i,a,o,l,c,u,d,f,g=t.constructor,p=g.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new g(t),jr?gr(e,p):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(p/Er),l)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}o=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=$i-1;--c[a],c[i]+=$i}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,jr?gr(e,p):e):new g(0)}function xf(t,e,n){var r,i=pi(t),a=xl(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+qu(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+qu(-i-1)+a,n&&(r=n-o)>0&&(a+=qu(r))):i>=o?(a+=qu(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+qu(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=qu(r))),t.s<0?"-"+a:a}function k8(t,e){if(t.length>e)return t.length=e,!0}function XK(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(qh+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return C8(o,a.toString())}else if(typeof a!="string")throw Error(qh+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,Zye.test(a))C8(o,a);else throw Error(qh+a)}if(i.prototype=Lt,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=XK,i.config=i.set=Qye,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 Qye(t){if(!t||typeof t!="object")throw Error(vo+"Object expected");var e,n,r,i=["precision",1,yg,"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(vg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(qh+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(qh+n+": "+r);return this}var AD=XK(Yye);Cs=new AD(1);const Zn=AD;var Jye=t=>t,YK={},ZK=t=>t===YK,j8=t=>function e(){return arguments.length===0||arguments.length===1&&ZK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},QK=(t,e)=>t===1?e:j8(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(o=>o!==YK).length;return a>=t?e(...r):QK(t-a,j8(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>ZK(d)?l.shift():d);return e(...u,...l)}))}),eve=t=>QK(t.length,t),ej=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},tve=eve((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),nve=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Jye;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},tj=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function JK(t){var e;return t===0?e=1:e=Math.floor(new Zn(t).abs().log(10).toNumber())+1,e}function eX(t,e,n){for(var r=new Zn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var tX=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},nX=(t,e,n)=>{if(t.lte(0))return new Zn(0);var r=JK(t.toNumber()),i=new Zn(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new Zn(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new Zn(c.toNumber()):new Zn(Math.ceil(c.toNumber()))},rve=(t,e,n)=>{var r=new Zn(1),i=new Zn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Zn(10).pow(JK(t)-1),i=new Zn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Zn(Math.floor(t)))}else t===0?i=new Zn(Math.floor((e-1)/2)):n||(i=new Zn(Math.floor(t)));var o=Math.floor((e-1)/2),l=nve(tve(c=>i.add(new Zn(c-o).mul(r)).toNumber()),ej);return l(0,e)},rX=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new Zn(0),tickMin:new Zn(0),tickMax:new Zn(0)};var o=nX(new Zn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Zn(0):(l=new Zn(e).add(n).div(2),l=l.sub(new Zn(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new Zn(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?rX(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new Zn(c).mul(o)),tickMax:l.add(new Zn(u).mul(o))})},ive=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]=tX([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...ej(0,i-1).map(()=>1/0)]:[...ej(0,i-1).map(()=>-1/0),c];return n>r?tj(u):u}if(l===c)return rve(l,i,a);var{step:d,tickMin:f,tickMax:g}=rX(l,c,o,a,0),p=eX(f,g.add(new Zn(.1).mul(d)),d);return n>r?tj(p):p},ave=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=tX([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=nX(new Zn(l).sub(o).div(c-1),a,0),d=[...eX(new Zn(o),new Zn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?tj(d):d},iX=t=>t.rootProps.maxBarSize,sve=t=>t.rootProps.barGap,aX=t=>t.rootProps.barCategoryGap,ove=t=>t.rootProps.barSize,Qb=t=>t.rootProps.stackOffset,sX=t=>t.rootProps.reverseStackOrder,TD=t=>t.options.chartName,CD=t=>t.rootProps.syncId,oX=t=>t.rootProps.syncMethod,kD=t=>t.options.eventEmitter,lve=t=>t.rootProps.baseValue,Kr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Sc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},As={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},VM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},cve={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Sc.angleAxisId,includeHidden:!1,name:void 0,reversed:Sc.reversed,scale:Sc.scale,tick:Sc.tick,tickCount:void 0,ticks:void 0,type:Sc.type,unit:void 0},uve={allowDataOverflow:As.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:As.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:As.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:As.scale,tick:As.tick,tickCount:As.tickCount,ticks:void 0,type:As.type,unit:void 0},dve={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Sc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Sc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Sc.scale,tick:Sc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},hve={allowDataOverflow:As.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:As.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:As.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:As.scale,tick:As.tick,tickCount:As.tickCount,ticks:void 0,type:"category",unit:void 0},jD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?dve:cve,PD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?hve:uve,GM=t=>t.polarOptions,RD=Qe([nu,ru,ki],aK),lX=Qe([GM,RD],(t,e)=>{if(t!=null)return Ea(t.innerRadius,e,0)}),cX=Qe([GM,RD],(t,e)=>{if(t!=null)return Ea(t.outerRadius,e,e*.8)}),fve=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},uX=Qe([GM],fve);Qe([jD,uX],VM);var dX=Qe([RD,lX,cX],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Qe([PD,dX],VM);var hX=Qe([kn,GM,lX,cX,nu,ru],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:Ea(o,i,i/2),cy:Ea(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),Pr=(t,e)=>e,Jb=(t,e,n)=>n;function WM(t){return t?.id}function fX(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=WM(l);u.forEach((f,g)=>{var p=a==null||i?g:String(Jn(f,a,null)),x=Jn(f,l.dataKey,0),y;o.has(p)?y=o.get(p):y={},Object.assign(y,{[d]:x}),o.set(p,y)})}}),Array.from(o.values())}function qM(t){return t.stackId!=null&&t.dataKey!=null}var KM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function XM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function mve(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var Ri=t=>{var e=kn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},_g=t=>t.tooltip.settings.axisId;function P8(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 Lw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P8(Object(n),!0).forEach(function(r){pve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pve(t,e,n){return(e=gve(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gve(t){var e=xve(t,"string");return typeof e=="symbol"?e:e+""}function xve(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 nj=[0,"auto"],Bi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"bottom",padding:{left:0,right:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"category",unit:void 0},mX=(t,e)=>t.cartesianAxis.xAxis[e],Il=(t,e)=>{var n=mX(t,e);return n??Bi},Hi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:nj,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:Vb},pX=(t,e)=>t.cartesianAxis.yAxis[e],Fl=(t,e)=>{var n=pX(t,e);return n??Hi},bve={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},DD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??bve},Fr=(t,e,n)=>{switch(e){case"xAxis":return Il(t,n);case"yAxis":return Fl(t,n);case"zAxis":return DD(t,n);case"angleAxis":return jD(t,n);case"radiusAxis":return PD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},yve=(t,e,n)=>{switch(e){case"xAxis":return Il(t,n);case"yAxis":return Fl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},ey=(t,e,n)=>{switch(e){case"xAxis":return Il(t,n);case"yAxis":return Fl(t,n);case"angleAxis":return jD(t,n);case"radiusAxis":return PD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},gX=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function OD(t,e){return n=>{switch(t){case"xAxis":return"xAxisId"in n&&n.xAxisId===e;case"yAxis":return"yAxisId"in n&&n.yAxisId===e;case"zAxis":return"zAxisId"in n&&n.zAxisId===e;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===e;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===e;default:return!1}}}var ty=t=>t.graphicalItems.cartesianItems,vve=Qe([Pr,Jb],OD),LD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),ny=Qe([ty,Fr,vve],LD,{memoizeOptions:{resultEqualityCheck:XM}}),xX=Qe([ny],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(qM)),bX=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),_ve=Qe([ny],bX),ID=t=>t.map(e=>e.data).filter(Boolean).flat(1),wve=Qe([ny],ID,{memoizeOptions:{resultEqualityCheck:XM}}),FD=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},UD=Qe([wve,Zb],FD),zD=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Jn(i,r)}))):t.map(r=>({value:r})),YM=Qe([UD,Fr,ny],zD);function yX(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function N1(t){if(bo(t)||t instanceof Date){var e=Number(t);if(er(e))return e}}function R8(t){if(Array.isArray(t)){var e=[N1(t[0]),N1(t[1])];return Cd(e)?e:void 0}var n=N1(t);if(n!=null)return[n,n]}function Qc(t){return t.map(N1).filter(yfe)}function Sve(t,e,n){return!n||typeof e!="number"||hs(e)?[]:n.length?Qc(n.flatMap(r=>{var i=Jn(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!er(a)||!er(o)))return[e-a,e+o]})):[]}var Di=t=>{var e=Ri(t),n=_g(t);return ey(t,e,n)},ry=Qe([Di],t=>t?.dataKey),Mve=Qe([xX,Zb,Di],fX),vX=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(WM);return[l,{stackedData:$pe(t,d,n),graphicalItems:u}]}))},ib=Qe([Mve,xX,Qb,sX],vX),_X=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=qpe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Eve=Qe([Fr],t=>t.allowDataOverflow),BD=t=>{var e;if(t==null||!("domain"in t))return nj;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Qc(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:nj},HD=Qe([Fr],BD),$D=Qe([HD,Eve],VK),Nve=Qe([ib,Vd,Pr,$D],_X,{memoizeOptions:{resultEqualityCheck:KM}}),ZM=t=>t.errorBars,Ave=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>yX(n,r)),Iw=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),o=Math.min(...a),l=Math.max(...a);return[o,l]}},VD=(t,e,n,r,i)=>{var a,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(v=>yX(i,v)),g=Jn(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),p=Sve(l,g,f);if(p.length>=2){var x=Math.min(...p),y=Math.max(...p);(a==null||x<a)&&(a=x),(o==null||y>o)&&(o=y)}var b=R8(g);b!=null&&(a=a==null?b[0]:Math.min(a,b[0]),o=o==null?b[1]:Math.max(o,b[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=R8(Jn(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),er(a)&&er(o))return[a,o]},Tve=Qe([UD,Fr,_ve,ZM,Pr],VD,{memoizeOptions:{resultEqualityCheck:KM}});function Cve(t){var{value:e}=t;if(bo(e)||e instanceof Date)return e}var kve=(t,e,n)=>{var r=t.map(Cve).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&LW(r))?cK(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},wX=t=>t.referenceElements.dots,wg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),jve=Qe([wX,Pr,Jb],wg),SX=t=>t.referenceElements.areas,Pve=Qe([SX,Pr,Jb],wg),MX=t=>t.referenceElements.lines,Rve=Qe([MX,Pr,Jb],wg),EX=(t,e)=>{var n=Qc(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Dve=Qe(jve,Pr,EX),NX=(t,e)=>{var n=Qc(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)]},Ove=Qe([Pve,Pr],NX);function Lve(t){var e;if(t.x!=null)return Qc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Qc(n)}function Ive(t){var e;if(t.y!=null)return Qc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Qc(n)}var AX=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?Lve(r):Ive(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Fve=Qe([Rve,Pr],AX),Uve=Qe(Dve,Fve,Ove,(t,e,n)=>Iw(t,n,e)),GD=(t,e,n,r,i,a,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?Iw(r,a,i):Iw(a,i);return Xye(e,u,t.allowDataOverflow)},zve=Qe([Fr,HD,$D,Nve,Tve,Uve,kn,Pr],GD,{memoizeOptions:{resultEqualityCheck:KM}}),Bve=[0,1],WD=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Ll(e,a);if(u&&l==null){var d;return cK(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?kve(r,t,u):i==="expand"?Bve:o}},qD=Qe([Fr,kn,UD,YM,Qb,Pr,zve],WD),TX=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:o}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof a=="string"){var l="scale".concat(Fb(a));return l in e0?l:"point"}}},Sg=Qe([Fr,kn,gX,TD,Pr],TX);function Hve(t){if(t!=null){if(t in e0)return e0[t]();var e="scale".concat(Fb(t));if(e in e0)return e0[e]()}}function KD(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=Hve(e);if(i!=null){var a=i.domain(n).range(r);return Fpe(a),a}}}var XD=(t,e,n)=>{var r=BD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Cd(t))return ive(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Cd(t))return ave(t,e.tickCount,e.allowDecimals)}},YD=Qe([qD,ey,Sg],XD),ZD=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Cd(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(o,l)]}return e},$ve=Qe([Fr,qD,YD,Pr],ZD),Vve=Qe(YM,Fr,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Qc(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var o=r[a+1]-r[a];n=Math.min(n,o)}return n/i}}),CX=Qe(Vve,kn,aX,ki,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!er(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=Ea(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),Gve=(t,e)=>{var n=Il(t,e);return n==null||typeof n.padding!="string"?0:CX(t,"xAxis",e,n.padding)},Wve=(t,e)=>{var n=Fl(t,e);return n==null||typeof n.padding!="string"?0:CX(t,"yAxis",e,n.padding)},qve=Qe(Il,Gve,(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}}),Kve=Qe(Fl,Wve,(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}}),Xve=Qe([ki,qve,RM,PM,(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]}),Yve=Qe([ki,kn,Kve,RM,PM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),iy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return Xve(t,n,r);case"yAxis":return Yve(t,n,r);case"zAxis":return(i=DD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return uX(t);case"radiusAxis":return dX(t,n);default:return}},kX=Qe([Fr,iy],VM),kd=Qe([Fr,Sg,$ve,kX],KD);Qe([ny,ZM,Pr],Ave);function jX(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var QM=(t,e)=>e,JM=(t,e,n)=>n,Zve=Qe(kM,QM,JM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(jX)),Qve=Qe(jM,QM,JM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(jX)),PX=(t,e)=>({width:t.width,height:e.height}),Jve=(t,e)=>{var n=typeof e.width=="number"?e.width:Vb;return{width:n,height:t.height}},RX=Qe(ki,Il,PX),e_e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},t_e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},n_e=Qe(ru,ki,Zve,QM,JM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=PX(e,l);o==null&&(o=e_e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),a}),r_e=Qe(nu,ki,Qve,QM,JM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=Jve(e,l);o==null&&(o=t_e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),a}),i_e=(t,e)=>{var n=Il(t,e);if(n!=null)return n_e(t,n.orientation,n.mirror)},a_e=Qe([ki,Il,i_e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:t.left,y:0}:{x:t.left,y:i}}}),s_e=(t,e)=>{var n=Fl(t,e);if(n!=null)return r_e(t,n.orientation,n.mirror)},o_e=Qe([ki,Fl,s_e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:0,y:t.top}:{x:i,y:t.top}}}),DX=Qe(ki,Fl,(t,e)=>{var n=typeof e.width=="number"?e.width:Vb;return{width:n,height:t.height}}),D8=(t,e,n)=>{switch(e){case"xAxis":return RX(t,n).width;case"yAxis":return DX(t,n).height;default:return}},OX=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Ll(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&LW(c))return c}},QD=Qe([kn,YM,Fr,Pr],OX),LX=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Ll(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},JD=Qe([kn,YM,ey,Pr],LX),O8=Qe([kn,yve,Sg,kd,QD,JD,iy,YD,Pr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=Ll(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),l_e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Ll(t,c),{type:d,ticks:f,tickCount:g}=e,p=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/p:0;x=c==="angleAxis"&&a!=null&&a.length>=2?Wi(a[0]-a[1])*2*x:x;var y=f||i;if(y){var b=y.map((v,E)=>{var w=o?o.indexOf(v):v;return{index:E,coordinate:r(w)+x,value:v,offset:x}});return b.filter(v=>er(v.coordinate))}return u&&l?l.map((v,E)=>({coordinate:r(v)+x,value:v,index:E,offset:x})).filter(v=>er(v.coordinate)):r.ticks?r.ticks(g).map(v=>({coordinate:r(v)+x,value:v,offset:x})):r.domain().map((v,E)=>({coordinate:r(v)+x,value:o?o[v]:v,index:E,offset:x}))}},IX=Qe([kn,ey,Sg,kd,YD,iy,QD,JD,Pr],l_e),c_e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Ll(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Wi(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},Al=Qe([kn,ey,kd,iy,QD,JD,Pr],c_e),Tl=Qe(Fr,kd,(t,e)=>{if(!(t==null||e==null))return Lw(Lw({},t),{},{scale:e})}),u_e=Qe([Fr,Sg,qD,kX],KD);Qe((t,e,n)=>DD(t,n),u_e,(t,e)=>{if(!(t==null||e==null))return Lw(Lw({},t),{},{scale:e})});var d_e=Qe([kn,kM,jM],(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}}),FX=t=>t.options.defaultTooltipEventType,UX=t=>t.options.validateTooltipEventTypes;function zX(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function eO(t,e){var n=FX(t),r=UX(t);return zX(e,n,r)}function h_e(t){return Rt(e=>eO(e,t))}var BX=(t,e)=>{var n,r=Number(e);if(!(hs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},f_e=t=>t.tooltip.settings,td={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},m_e={itemInteraction:{click:td,hover:td},axisInteraction:{click:td,hover:td},keyboardInteraction:td,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}},HX=fs({name:"tooltip",initialState:m_e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Tr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=$o(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Tr()},removeTooltipEntrySettings:{reducer(t,e){var n=$o(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Tr()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:p_e,replaceTooltipEntrySettings:g_e,removeTooltipEntrySettings:x_e,setTooltipSettingsState:b_e,setActiveMouseOverItemIndex:$X,mouseLeaveItem:y_e,mouseLeaveChart:VX,setActiveClickItemIndex:v_e,setMouseOverAxisIndex:GX,setMouseClickAxisIndex:__e,setSyncInteraction:rj,setKeyboardInteraction:ij}=HX.actions,w_e=HX.reducer;function L8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Yv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L8(Object(n),!0).forEach(function(r){S_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function S_e(t,e,n){return(e=M_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function M_e(t){var e=E_e(t,"string");return typeof e=="symbol"?e:e+""}function E_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function N_e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function A_e(t){return t.index!=null}var WX=(t,e,n,r)=>{if(e==null)return td;var i=N_e(t,e,n);if(i==null)return td;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(A_e(i)){if(a)return Yv(Yv({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Yv(Yv({},td),{},{coordinate:i.coordinate})};function T_e(t){if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(t instanceof Date){var e=t.valueOf();return Number.isFinite(e)?e:void 0}var n=Number(t);return Number.isFinite(n)?n:void 0}function C_e(t,e){var n=T_e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function k_e(t,e,n){if(n==null||e==null)return!0;var r=Jn(t,e);return r==null||!Cd(n)?!0:C_e(r,n)}var tO=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!er(a))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(a,l)),u=e[c];return u==null||k_e(u,n,r)?String(c):null},qX=(t,e,n,r,i,a,o,l)=>{if(!(a==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},KX=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var o;return((o=a.settings)===null||o===void 0?void 0:o.dataKey)===i})},ay=t=>t.options.tooltipPayloadSearcher,Mg=t=>t.tooltip;function I8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function F8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I8(Object(n),!0).forEach(function(r){j_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function j_e(t,e,n){return(e=P_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function P_e(t){var e=R_e(t,"string");return typeof e=="symbol"?e:e+""}function R_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function D_e(t,e){return t??e}var XX=(t,e,n,r,i,a,o)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((g,p)=>{var x,{dataDefinedOnItem:y,settings:b}=p,v=D_e(y,l),E=Array.isArray(v)?jq(v,u,d):v,w=(x=b?.dataKey)!==null&&x!==void 0?x:r,A=b?.nameKey,N;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&o==="axis"?N=IW(E,r,i):N=a(E,e,c,A),Array.isArray(N))N.forEach(T=>{var O=F8(F8({},b),{},{name:T.name,unit:T.unit,color:void 0,fill:void 0});g.push(iB({tooltipEntrySettings:O,dataKey:T.dataKey,payload:T.payload,value:Jn(T.payload,T.dataKey),name:T.name}))});else{var C;g.push(iB({tooltipEntrySettings:b,dataKey:w,payload:N,value:Jn(N,w),name:(C=Jn(N,A))!==null&&C!==void 0?C:b?.name}))}return g},f)}},nO=Qe([Di,kn,gX,TD,Ri],TX),O_e=Qe([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),L_e=Qe([Ri,_g],OD),sy=Qe([O_e,Di,L_e],LD,{memoizeOptions:{resultEqualityCheck:XM}}),I_e=Qe([sy],t=>t.filter(qM)),F_e=Qe([sy],ID,{memoizeOptions:{resultEqualityCheck:XM}}),Eg=Qe([F_e,Vd],FD),U_e=Qe([I_e,Vd,Di],fX),rO=Qe([Eg,Di,sy],zD),YX=Qe([Di],BD),z_e=Qe([Di],t=>t.allowDataOverflow),ZX=Qe([YX,z_e],VK),B_e=Qe([sy],t=>t.filter(qM)),H_e=Qe([U_e,B_e,Qb,sX],vX),$_e=Qe([H_e,Vd,Ri,ZX],_X),V_e=Qe([sy],bX),G_e=Qe([Eg,Di,V_e,ZM,Ri],VD,{memoizeOptions:{resultEqualityCheck:KM}}),W_e=Qe([wX,Ri,_g],wg),q_e=Qe([W_e,Ri],EX),K_e=Qe([SX,Ri,_g],wg),X_e=Qe([K_e,Ri],NX),Y_e=Qe([MX,Ri,_g],wg),Z_e=Qe([Y_e,Ri],AX),Q_e=Qe([q_e,Z_e,X_e],Iw),J_e=Qe([Di,YX,ZX,$_e,G_e,Q_e,kn,Ri],GD),oy=Qe([Di,kn,Eg,rO,Qb,Ri,J_e],WD),e1e=Qe([oy,Di,nO],XD),t1e=Qe([Di,oy,e1e,Ri],ZD),QX=t=>{var e=Ri(t),n=_g(t),r=!1;return iy(t,e,n,r)},JX=Qe([Di,QX],VM),eY=Qe([Di,nO,t1e,JX],KD),n1e=Qe([kn,rO,Di,Ri],OX),r1e=Qe([kn,rO,Di,Ri],LX),i1e=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=Ll(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?Wi(i[0]-i[1])*2*f:f,u&&o?o.map((g,p)=>({coordinate:r(g)+f,value:g,index:p,offset:f})):r.domain().map((g,p)=>({coordinate:r(g)+f,value:a?a[g]:g,index:p,offset:f}))}}},au=Qe([kn,Di,nO,eY,QX,n1e,r1e,Ri],i1e),iO=Qe([FX,UX,f_e],(t,e,n)=>zX(n.shared,t,e)),tY=t=>t.tooltip.settings.trigger,aO=t=>t.tooltip.settings.defaultIndex,ly=Qe([Mg,iO,tY,aO],WX),jd=Qe([ly,Eg,ry,oy],tO),nY=Qe([au,jd],BX),sO=Qe([ly],t=>{if(t)return t.dataKey}),a1e=Qe([ly],t=>{if(t)return t.graphicalItemId}),rY=Qe([Mg,iO,tY,aO],KX),s1e=Qe([nu,ru,kn,ki,au,aO,rY,ay],qX),o1e=Qe([ly,s1e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),l1e=Qe([ly],t=>t.active),c1e=Qe([rY,jd,Vd,ry,nY,ay,iO],XX),u1e=Qe([c1e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function U8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function z8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U8(Object(n),!0).forEach(function(r){d1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function d1e(t,e,n){return(e=h1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h1e(t){var e=f1e(t,"string");return typeof e=="symbol"?e:e+""}function f1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var m1e=()=>Rt(Di),p1e=()=>{var t=m1e(),e=Rt(au),n=Rt(eY);return Td(!t||!n?void 0:z8(z8({},t),{},{scale:n}),e)};function B8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function bm(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){g1e(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 g1e(t,e,n){return(e=x1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x1e(t){var e=b1e(t,"string");return typeof e=="symbol"?e:e+""}function b1e(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 y1e=(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}},v1e=(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 bm(bm(bm({},r),fi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return bm(bm(bm({},r),fi(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 _1e(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 iY=(t,e,n,r,i)=>{var a,o=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,g=void 0;if(Wi(d-u)!==Wi(f-d)){var p=[];if(Wi(f-d)===Wi(i[1]-i[0])){g=f;var x=d+i[1]-i[0];p[0]=Math.min(x,(x+u)/2),p[1]=Math.max(x,(x+u)/2)}else{g=u;var y=f+i[1]-i[0];p[0]=Math.min(d,(y+d)/2),p[1]=Math.max(d,(y+d)/2)}var b=[Math.min(d,(g+d)/2),Math.max(d,(g+d)/2)];if(t>b[0]&&t<=b[1]||t>=p[0]&&t<=p[1]){({index:o}=n[c]);break}}else{var v=Math.min(u,f),E=Math.max(u,f);if(t>(v+d)/2&&t<=(E+d)/2){({index:o}=n[c]);break}}}else if(e){for(var w=0;w<l;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:o}=e[w]);break}}return o},aY=()=>Rt(TD),oO=(t,e)=>e,sY=(t,e,n)=>n,lO=(t,e,n,r)=>r,w1e=Qe(au,t=>_M(t,e=>e.coordinate)),cO=Qe([Mg,oO,sY,lO],WX),uO=Qe([cO,Eg,ry,oy],tO),S1e=(t,e,n)=>{if(e!=null){var r=Mg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},oY=Qe([Mg,oO,sY,lO],KX),Fw=Qe([nu,ru,kn,ki,au,lO,oY,ay],qX),M1e=Qe([cO,Fw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),lY=Qe([au,uO],BX),E1e=Qe([oY,uO,Vd,ry,lY,ay,oO],XX),N1e=Qe([cO,uO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),A1e=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&_1e(t,o)){var l=Kpe(t,e),c=iY(l,a,i,n,r),u=y1e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},T1e=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=d0e(t,n);if(l){var c=Xpe(l,e),u=iY(c,o,a,r,i),d=v1e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},C1e=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?A1e(t,e,r,i,a,o,l):T1e(t,e,n,r,i,a,o)},k1e=Qe(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),j1e=Qe(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Kr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:mve}});function H8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H8(Object(n),!0).forEach(function(r){P1e(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 P1e(t,e,n){return(e=R1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function R1e(t){var e=D1e(t,"string");return typeof e=="symbol"?e:e+""}function D1e(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 O1e={},L1e={zIndexMap:Object.values(Kr).reduce((t,e)=>$8($8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),O1e)},I1e=new Set(Object.values(Kr));function F1e(t){return I1e.has(t)}var cY=fs({name:"zIndex",initialState:L1e,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:Tr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!F1e(n)&&delete t.zIndexMap[n])},prepare:Tr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:Tr()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:Tr()}}}),{registerZIndexPortal:U1e,unregisterZIndexPortal:z1e,registerZIndexPortalId:B1e,unregisterZIndexPortalId:H1e}=cY.actions,$1e=cY.reducer;function Ta(t){var{zIndex:e,children:n}=t,r=Age(),i=r&&e!==void 0&&e!==0,a=ji(),o=xr();S.useLayoutEffect(()=>i?(o(U1e({zIndex:e})),()=>{o(z1e({zIndex:e}))}):Ub,[o,e,i]);var l=Rt(u=>k1e(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Tc.createPortal(n,c):null}function aj(){return aj=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},aj.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 Zv(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){V1e(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 V1e(t,e,n){return(e=G1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function G1e(t){var e=W1e(t,"string");return typeof e=="symbol"?e:e+""}function W1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function q1e(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return S.isValidElement(e)?S.cloneElement(e,r):S.createElement(n,r)}function K1e(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,g=r,p=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,y,b;if(d==="ScatterChart")x=f,y=Nxe,b=Kr.cursorLine;else if(d==="BarChart")x=Axe(l,f,a,o),y=iK,b=Kr.cursorRectangle;else if(l==="radial"&&UW(f)){var{cx:v,cy:E,radius:w,startAngle:A,endAngle:N}=sK(f);x={cx:v,cy:E,startAngle:A,endAngle:N,innerRadius:w,outerRadius:w},y=lK,b=Kr.cursorLine}else x={points:p0e(l,f,a)},y=yp,b=Kr.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,T=Zv(Zv(Zv(Zv({stroke:"#ccc",pointerEvents:"none"},a),x),ff(c)),{},{payload:g,payloadIndex:p,className:In("recharts-tooltip-cursor",C)});return S.createElement(Ta,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:b},S.createElement(q1e,{cursor:c,cursorComp:y,cursorProps:T}))}function X1e(t){var e=p1e(),n=Hq(),r=jf(),i=aY();return e==null||n==null||r==null||i==null?null:S.createElement(K1e,aj({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var uY=S.createContext(null),Y1e=()=>S.useContext(uY),MT={exports:{}},G8;function Z1e(){return G8||(G8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new i(d,f||c,g),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],p]:c._events[x].push(p):(c._events[x]=p,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var g=0,p=f.length,x=new Array(p);g<p;g++)x[g]=f[g].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,g,p,x){var y=n?n+u:u;if(!this._events[y])return!1;var b=this._events[y],v=arguments.length,E,w;if(b.fn){switch(b.once&&this.removeListener(u,b.fn,void 0,!0),v){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,d),!0;case 3:return b.fn.call(b.context,d,f),!0;case 4:return b.fn.call(b.context,d,f,g),!0;case 5:return b.fn.call(b.context,d,f,g,p),!0;case 6:return b.fn.call(b.context,d,f,g,p,x),!0}for(w=1,E=new Array(v-1);w<v;w++)E[w-1]=arguments[w];b.fn.apply(b.context,E)}else{var A=b.length,N;for(w=0;w<A;w++)switch(b[w].once&&this.removeListener(u,b[w].fn,void 0,!0),v){case 1:b[w].fn.call(b[w].context);break;case 2:b[w].fn.call(b[w].context,d);break;case 3:b[w].fn.call(b[w].context,d,f);break;case 4:b[w].fn.call(b[w].context,d,f,g);break;default:if(!E)for(N=1,E=new Array(v-1);N<v;N++)E[N-1]=arguments[N];b[w].fn.apply(b[w].context,E)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,g){var p=n?n+u:u;if(!this._events[p])return this;if(!d)return o(this,p),this;var x=this._events[p];if(x.fn)x.fn===d&&(!g||x.once)&&(!f||x.context===f)&&o(this,p);else{for(var y=0,b=[],v=x.length;y<v;y++)(x[y].fn!==d||g&&!x[y].once||f&&x[y].context!==f)&&b.push(x[y]);b.length?this._events[p]=b.length===1?b[0]:b:o(this,p)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(MT)),MT.exports}var Q1e=Z1e();const J1e=_o(Q1e);var ab=new J1e,sj="recharts.syncEvent.tooltip",W8="recharts.syncEvent.brush";function e2(t,e){if(e){var n=Number.parseInt(e,10);if(!hs(n))return t?.[n]}}var ewe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},dY=fs({name:"options",initialState:ewe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),twe=dY.reducer,{createEventEmitter:nwe}=dY.actions;function rwe(t){return t.tooltip.syncInteraction}var iwe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},hY=fs({name:"chartData",initialState:iwe,reducers:{setChartData(t,e){if(t.chartData=e.payload,e.payload==null){t.dataStartIndex=0,t.dataEndIndex=0;return}e.payload.length>0&&t.dataEndIndex!==e.payload.length-1&&(t.dataEndIndex=e.payload.length-1)},setComputedData(t,e){t.computedData=e.payload},setDataStartEndIndexes(t,e){var{startIndex:n,endIndex:r}=e.payload;n!=null&&(t.dataStartIndex=n),r!=null&&(t.dataEndIndex=r)}}}),{setChartData:q8,setDataStartEndIndexes:awe,setComputedData:xqe}=hY.actions,swe=hY.reducer,owe=["x","y"];function K8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ym(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K8(Object(n),!0).forEach(function(r){lwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lwe(t,e,n){return(e=cwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cwe(t){var e=uwe(t,"string");return typeof e=="symbol"?e:e+""}function uwe(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 dwe(t,e){if(t==null)return{};var n,r,i=hwe(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 hwe(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 fwe(){var t=Rt(CD),e=Rt(kD),n=xr(),r=Rt(oX),i=Rt(au),a=jf(),o=Gb(),l=Rt(c=>c.rootProps.className);S.useEffect(()=>{if(t==null)return Ub;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var g;if(o&&d!==null&&d!==void 0&&(g=d.payload)!==null&&g!==void 0&&g.coordinate&&d.payload.sourceViewBox){var p=d.payload.coordinate,{x,y}=p,b=dwe(p,owe),{x:v,y:E,width:w,height:A}=d.payload.sourceViewBox,N=ym(ym({},b),{},{x:o.x+(w?(x-v)/w:0)*o.width,y:o.y+(A?(y-E)/A:0)*o.height});n(ym(ym({},d),{},{payload:ym(ym({},d.payload),{},{coordinate:N})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var T={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},O=r(i,T);C=i[O]}else r==="value"&&(C=i.find(Z=>String(Z.value)===d.payload.label));var{coordinate:k}=d.payload;if(C==null||d.payload.active===!1||k==null||o==null){n(rj({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:R,y:z}=k,D=Math.min(R,o.x+o.width),K=Math.min(z,o.y+o.height),P={x:a==="horizontal"?C.coordinate:D,y:a==="horizontal"?K:C.coordinate},W=rj({active:d.payload.active,coordinate:P,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(W)}}};return ab.on(sj,c),()=>{ab.off(sj,c)}},[l,n,e,t,r,i,a,o])}function mwe(){var t=Rt(CD),e=Rt(kD),n=xr();S.useEffect(()=>{if(t==null)return Ub;var r=(i,a,o)=>{e!==o&&t===i&&n(awe(a))};return ab.on(W8,r),()=>{ab.off(W8,r)}},[n,e,t])}function pwe(){var t=xr();S.useEffect(()=>{t(nwe())},[t]),fwe(),mwe()}function gwe(t,e,n,r,i,a){var o=Rt(p=>S1e(p,t,e)),l=Rt(kD),c=Rt(CD),u=Rt(oX),d=Rt(rwe),f=d?.active,g=Gb();S.useEffect(()=>{if(!f&&c!=null&&l!=null){var p=rj({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:g,graphicalItemId:void 0});ab.emit(sj,c,p,l)}},[f,n,o,i,r,l,c,u,a,g])}function X8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Y8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X8(Object(n),!0).forEach(function(r){xwe(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 xwe(t,e,n){return(e=bwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bwe(t){var e=ywe(t,"string");return typeof e=="symbol"?e:e+""}function ywe(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 vwe(t){return t.dataKey}function _we(t,e){return S.isValidElement(t)?S.cloneElement(t,e):typeof t=="function"?S.createElement(t,e):S.createElement(axe,e)}var Z8=[],wwe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function A1(t){var e,n,r=Ir(t,wwe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:g,position:p,reverseDirection:x,useTranslate3d:y,wrapperStyle:b,cursor:v,shared:E,trigger:w,defaultIndex:A,portal:N,axisId:C}=r,T=xr(),O=typeof A=="number"?String(A):A;S.useEffect(()=>{T(b_e({shared:E,trigger:w,axisId:C,active:i,defaultIndex:O}))},[T,E,w,C,i,O]);var k=Gb(),R=Jq(),z=h_e(E),{activeIndex:D,isActive:K}=(e=Rt(ue=>N1e(ue,z,w,O)))!==null&&e!==void 0?e:{},P=Rt(ue=>E1e(ue,z,w,O)),W=Rt(ue=>lY(ue,z,w,O)),Z=Rt(ue=>M1e(ue,z,w,O)),G=P,Y=Y1e(),X=(n=i??K)!==null&&n!==void 0?n:!1,[q,F]=tq([G,X]),V=z==="axis"?W:void 0;gwe(z,w,Z,V,D,X);var te=N??Y;if(te==null||k==null||z==null)return null;var re=G??Z8;X||(re=Z8),u&&re.length&&(re=XW(re.filter(ue=>ue.value!=null&&(ue.hide!==!0||r.includeHidden)),g,vwe));var ae=re.length>0,he=S.createElement(hxe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:X,coordinate:Z,hasPayload:ae,offset:f,position:p,reverseDirection:x,useTranslate3d:y,viewBox:k,wrapperStyle:b,lastBoundingBox:q,innerRef:F,hasPortalFromProps:!!N},_we(c,Y8(Y8({},r),{},{payload:re,label:V,active:X,activeIndex:D,coordinate:Z,accessibilityLayer:R})));return S.createElement(S.Fragment,null,Tc.createPortal(he,te),X&&S.createElement(X1e,{cursor:v,tooltipEventType:z,coordinate:Z,payload:re,index:D}))}var cy=t=>null;cy.displayName="Cell";function Swe(t,e,n){return(e=Mwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mwe(t){var e=Ewe(t,"string");return typeof e=="symbol"?e:e+""}function Ewe(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 Nwe{constructor(e){Swe(this,"cache",new Map),this.maxSize=e}get(e){var n=this.cache.get(e);return n!==void 0&&(this.cache.delete(e),this.cache.set(e,n)),n}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(e,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function Q8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Awe(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){Twe(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 Twe(t,e,n){return(e=Cwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cwe(t){var e=kwe(t,"string");return typeof e=="symbol"?e:e+""}function kwe(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 jwe={cacheSize:2e3,enableCache:!0},fY=Awe({},jwe),J8=new Nwe(fY.cacheSize),Pwe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},e6="recharts_measurement_span";function Rwe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(o,"|").concat(l)}var t6=(t,e)=>{try{var n=document.getElementById(e6);n||(n=document.createElement("span"),n.setAttribute("id",e6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,Pwe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},p0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||pg.isSsr)return{width:0,height:0};if(!fY.enableCache)return t6(e,n);var r=Rwe(e,n),i=J8.get(r);if(i)return i;var a=t6(e,n);return J8.set(r,a),a},n6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,r6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Dwe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,Owe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,mY={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},Lwe=Object.keys(mY),dp="NaN";function Iwe(t,e){return t*mY[e]}class ts{static parse(e){var n,[,r,i]=(n=Owe.exec(e))!==null&&n!==void 0?n:[];return new ts(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,hs(e)&&(this.unit=""),n!==""&&!Dwe.test(n)&&(this.num=NaN,this.unit=""),Lwe.includes(n)&&(this.num=Iwe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new ts(NaN,""):new ts(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ts(NaN,""):new ts(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ts(NaN,""):new ts(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ts(NaN,""):new ts(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return hs(this.num)}}function pY(t){if(t.includes(dp))return dp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=n6.exec(e))!==null&&n!==void 0?n:[],o=ts.parse(r??""),l=ts.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return dp;e=e.replace(n6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,g]=(u=r6.exec(e))!==null&&u!==void 0?u:[],p=ts.parse(d??""),x=ts.parse(g??""),y=f==="+"?p.add(x):p.subtract(x);if(y.isNaN())return dp;e=e.replace(r6,y.toString())}return e}var i6=/\(([^()]*)\)/;function Fwe(t){for(var e=t,n;(n=i6.exec(e))!=null;){var[,r]=n;e=e.replace(i6,pY(r))}return e}function Uwe(t){var e=t.replace(/\s+/g,"");return e=Fwe(e),e=pY(e),e}function zwe(t){try{return Uwe(t)}catch{return dp}}function ET(t){var e=zwe(t.slice(5,-1));return e===dp?"":e}var Bwe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],Hwe=["dx","dy","angle","className","breakAll"];function oj(){return oj=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},oj.apply(null,arguments)}function a6(t,e){if(t==null)return{};var n,r,i=$we(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 $we(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 gY=/[ \f\n\r\t\v\u2028\u2029]+/,xY=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Nr(e)||(n?i=e.toString().split(""):i=e.toString().split(gY));var a=i.map(l=>({word:l,width:p0(l,r).width})),o=n?0:p0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function Vwe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var bY=(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},[]),yY=t=>t.reduce((e,n)=>e.width>n.width?e:n),Gwe="…",s6=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=xY({breakAll:n,style:r,children:c+Gwe});if(!u)return[!1,[]];var d=bY(u.wordsWithComputedWidth,a,o,l),f=d.length>i||yY(d).width>Number(a);return[f,d]},Wwe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Ot(a),d=String(o),f=bY(e,r,n,i);if(!u||i)return f;var g=f.length>a||yY(f).width>Number(r);if(!g)return f;for(var p=0,x=d.length-1,y=0,b;p<=x&&y<=d.length-1;){var v=Math.floor((p+x)/2),E=v-1,[w,A]=s6(d,E,c,l,a,r,n,i),[N]=s6(d,v,c,l,a,r,n,i);if(!w&&!N&&(p=v+1),w&&N&&(x=v-1),!w&&N){b=A;break}y++}return b||f},o6=t=>{var e=Nr(t)?[]:t.toString().split(gY);return[{words:e,width:void 0}]},qwe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!pg.isSsr){var l,c,u=xY({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return o6(r);return Wwe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return o6(r)},vY="#808080",Kwe={angle:0,breakAll:!1,capHeight:"0.71em",fill:vY,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},t2=S.forwardRef((t,e)=>{var n=Ir(t,Kwe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=a6(n,Bwe),g=S.useMemo(()=>qwe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:p,dy:x,angle:y,className:b,breakAll:v}=f,E=a6(f,Hwe);if(!bo(r)||!bo(i)||g.length===0)return null;var w=Number(r)+(Ot(p)?p:0),A=Number(i)+(Ot(x)?x:0);if(!er(w)||!er(A))return null;var N;switch(d){case"start":N=ET("calc(".concat(o,")"));break;case"middle":N=ET("calc(".concat((g.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:N=ET("calc(".concat(g.length-1," * -").concat(a,")"));break}var C=[];if(c){var T=g[0].width,{width:O}=f;C.push("scale(".concat(Ot(O)&&Ot(T)?O/T:1,")"))}return y&&C.push("rotate(".concat(y,", ").concat(w,", ").concat(A,")")),C.length&&(E.transform=C.join(" ")),S.createElement("text",oj({},fa(E),{ref:e,x:w,y:A,className:In("recharts-text",b),textAnchor:u,fill:l.includes("url")?vY:l}),g.map((k,R)=>{var z=k.words.join(v?"":" ");return S.createElement("tspan",{x:w,dy:R===0?N:a,key:"".concat(z,"-").concat(R)},z)}))});t2.displayName="Text";var Xwe=["labelRef"];function Ywe(t,e){if(t==null)return{};var n,r,i=Zwe(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 Zwe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function l6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ei(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?l6(Object(n),!0).forEach(function(r){Qwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Qwe(t,e,n){return(e=Jwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jwe(t){var e=eSe(t,"string");return typeof e=="symbol"?e:e+""}function eSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Mc(){return Mc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Mc.apply(null,arguments)}var _Y=S.createContext(null),wY=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=S.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return S.createElement(_Y.Provider,{value:c},l)},SY=()=>{var t=S.useContext(_Y),e=Gb();return t||Bq(e)},tSe=S.createContext(null),nSe=()=>{var t=S.useContext(tSe),e=Rt(hX);return t||e},rSe=t=>{var{value:e,formatter:n}=t,r=Nr(t.children)?e:t.children;return typeof n=="function"?n(r):r},dO=t=>t!=null&&typeof t=="function",iSe=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),360);return n*r},aSe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:g,clockWise:p}=i,x=(u+d)/2,y=iSe(f,g),b=y>=0?1:-1,v,E;switch(e){case"insideStart":v=f+b*a,E=p;break;case"insideEnd":v=g-b*a,E=!p;break;case"end":v=g+b*a,E=p;break;default:throw new Error("Unsupported position ".concat(e))}E=y<=0?E:!E;var w=fi(l,c,x,v),A=fi(l,c,x,v+(E?1:-1)*359),N="M".concat(w.x,",").concat(w.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(E?0:1,`,
- `).concat(A.x,",").concat(A.y),C=Nr(t.id)?G0("recharts-radial-line-"):t.id;return S.createElement("text",Mc({},r,{dominantBaseline:"central",className:In("recharts-radial-bar-label",o)}),S.createElement("defs",null,S.createElement("path",{id:C,d:N})),S.createElement("textPath",{xlinkHref:"#".concat(C)},n))},sSe=(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}=fi(r,i,o+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var g=(a+o)/2,{x:p,y:x}=fi(r,i,g,u);return{x:p,y:x,textAnchor:"middle",verticalAnchor:"middle"}},lj=t=>"cx"in t&&Ot(t.cx),oSe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!lj(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,g=o+(c-u)/2,p=(f+g)/2,x=(c+u)/2,y=f+c/2,b=d>=0?1:-1,v=b*r,E=b>0?"end":"start",w=b>0?"start":"end",A=c>=0?1:-1,N=A*r,C=A>0?"end":"start",T=A>0?"start":"end";if(i==="top"){var O={x:f+c/2,y:l-v,textAnchor:"middle",verticalAnchor:E};return ei(ei({},O),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var k={x:g+u/2,y:l+d+v,textAnchor:"middle",verticalAnchor:w};return ei(ei({},k),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var R={x:p-N,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return ei(ei({},R),a?{width:Math.max(R.x-a.x,0),height:d}:{})}if(i==="right"){var z={x:p+x+N,y:l+d/2,textAnchor:T,verticalAnchor:"middle"};return ei(ei({},z),a?{width:Math.max(a.x+a.width-z.x,0),height:d}:{})}var D=a?{width:x,height:d}:{};return i==="insideLeft"?ei({x:p+N,y:l+d/2,textAnchor:T,verticalAnchor:"middle"},D):i==="insideRight"?ei({x:p+x-N,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},D):i==="insideTop"?ei({x:f+c/2,y:l+v,textAnchor:"middle",verticalAnchor:w},D):i==="insideBottom"?ei({x:g+u/2,y:l+d-v,textAnchor:"middle",verticalAnchor:E},D):i==="insideTopLeft"?ei({x:f+N,y:l+v,textAnchor:T,verticalAnchor:w},D):i==="insideTopRight"?ei({x:f+c-N,y:l+v,textAnchor:C,verticalAnchor:w},D):i==="insideBottomLeft"?ei({x:g+N,y:l+d-v,textAnchor:T,verticalAnchor:E},D):i==="insideBottomRight"?ei({x:g+u-N,y:l+d-v,textAnchor:C,verticalAnchor:E},D):i&&typeof i=="object"&&(Ot(i.x)||qc(i.x))&&(Ot(i.y)||qc(i.y))?ei({x:o+Ea(i.x,x),y:l+Ea(i.y,d),textAnchor:"end",verticalAnchor:"end"},D):ei({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},D)},lSe={angle:0,offset:5,zIndex:Kr.label,position:"middle",textBreakAll:!1};function Ku(t){var e=Ir(t,lSe),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=nSe(),f=SY(),g=r==="center"?f:d??f,p,x,y;if(n==null?p=g:lj(n)?p=n:p=Bq(n),!p||Nr(i)&&Nr(a)&&!S.isValidElement(o)&&typeof o!="function")return null;var b=ei(ei({},e),{},{viewBox:p});if(S.isValidElement(o)){var{labelRef:v}=b,E=Ywe(b,Xwe);return S.cloneElement(o,E)}if(typeof o=="function"){if(x=S.createElement(o,b),S.isValidElement(x))return x}else x=rSe(e);var w=fa(e);if(lj(p)){if(r==="insideStart"||r==="insideEnd"||r==="end")return aSe(e,r,x,w,p);y=sSe(p,e.offset,e.position)}else y=oSe(e,p);return S.createElement(Ta,{zIndex:e.zIndex},S.createElement(t2,Mc({ref:u,className:In("recharts-label",l)},w,y,{textAnchor:Vwe(w.textAnchor)?w.textAnchor:y.textAnchor,breakAll:c}),x))}Ku.displayName="Label";var cSe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?S.createElement(Ku,Mc({key:"label-implicit"},r)):bo(t)?S.createElement(Ku,Mc({key:"label-implicit",value:t},r)):S.isValidElement(t)?t.type===Ku?S.cloneElement(t,ei({key:"label-implicit"},r)):S.createElement(Ku,Mc({key:"label-implicit",content:t},r)):dO(t)?S.createElement(Ku,Mc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?S.createElement(Ku,Mc({},t,{key:"label-implicit"},r)):null};function MY(t){var{label:e,labelRef:n}=t,r=SY();return cSe(e,r,n)||null}var NT={},AT={},c6;function uSe(){return c6||(c6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(AT)),AT}var TT={},u6;function dSe(){return u6||(u6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(TT)),TT}var d6;function hSe(){return d6||(d6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uSe(),n=dSe(),r=UR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(NT)),NT}var CT,h6;function fSe(){return h6||(h6=1,CT=hSe().last),CT}var mSe=fSe();const pSe=_o(mSe);var gSe=["valueAccessor"],xSe=["dataKey","clockWise","id","textBreakAll","zIndex"];function Uw(){return Uw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Uw.apply(null,arguments)}function f6(t,e){if(t==null)return{};var n,r,i=bSe(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 bSe(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 ySe=t=>Array.isArray(t.value)?pSe(t.value):t.value,EY=S.createContext(void 0),hO=EY.Provider,NY=S.createContext(void 0),vSe=NY.Provider;function _Se(){return S.useContext(EY)}function wSe(){return S.useContext(NY)}function T1(t){var{valueAccessor:e=ySe}=t,n=f6(t,gSe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=f6(n,xSe),u=_Se(),d=wSe(),f=u||d;return!f||!f.length?null:S.createElement(Ta,{zIndex:l??Kr.label},S.createElement(Lr,{className:"recharts-label-list"},f.map((g,p)=>{var x,y=Nr(r)?e(g,p):Jn(g&&g.payload,r),b=Nr(a)?{}:{id:"".concat(a,"-").concat(p)};return S.createElement(Ku,Uw({key:"label-".concat(p)},fa(g),c,b,{fill:(x=n.fill)!==null&&x!==void 0?x:g.fill,parentViewBox:g.parentViewBox,value:y,textBreakAll:o,viewBox:g.viewBox,index:p,zIndex:0}))})))}T1.displayName="LabelList";function n2(t){var{label:e}=t;return e?e===!0?S.createElement(T1,{key:"labelList-implicit"}):S.isValidElement(e)||dO(e)?S.createElement(T1,{key:"labelList-implicit",content:e}):typeof e=="object"?S.createElement(T1,Uw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function cj(){return cj=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},cj.apply(null,arguments)}var AY=t=>{var{cx:e,cy:n,r,className:i}=t,a=In("recharts-dot",i);return Ot(e)&&Ot(n)&&Ot(r)?S.createElement("circle",cj({},za(t),FR(t),{className:a,cx:e,cy:n,r})):null},TY=t=>t.graphicalItems.polarItems,SSe=Qe([Pr,Jb],OD),r2=Qe([TY,Fr,SSe],LD),MSe=Qe([r2],ID),i2=Qe([MSe,ED],FD),ESe=Qe([i2,Fr,r2],zD);Qe([i2,Fr,r2],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=Jn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var m6=()=>{},NSe=Qe([i2,Fr,r2,ZM,Pr],VD),ASe=Qe([Fr,HD,$D,m6,NSe,m6,kn,Pr],GD),CY=Qe([Fr,kn,i2,ESe,Qb,Pr,ASe],WD),TSe=Qe([CY,Fr,Sg],XD);Qe([Fr,CY,TSe,Pr],ZD);var CSe={radiusAxis:{},angleAxis:{}},kY=fs({name:"polarAxis",initialState:CSe,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:bqe,removeRadiusAxis:yqe,addAngleAxis:vqe,removeAngleAxis:_qe}=kY.actions,kSe=kY.reducer;function p6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function g6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p6(Object(n),!0).forEach(function(r){jSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jSe(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=RSe(t,"string");return typeof e=="symbol"?e:e+""}function RSe(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 DSe=(t,e)=>e,fO=Qe([TY,DSe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),OSe=[],mO=(t,e,n)=>n?.length===0?OSe:n,jY=Qe([ED,fO,mO],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>g6(g6({},e.presentationProps),a.props))),i!=null)return i}}),LSe=Qe([jY,fO,mO],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=Jn(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Bd(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),ISe=Qe([jY,fO,mO,ki],(t,e,n,r)=>{if(!(e==null||t==null))return FMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),kT={exports:{}},ir={};var x6;function FSe(){if(x6)return ir;x6=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function x(y){if(typeof y=="object"&&y!==null){var b=y.$$typeof;switch(b){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case g:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case f:case d:return y;case a:return y;default:return b}}case e:return b}}}return ir.ContextConsumer=a,ir.ContextProvider=o,ir.Element=t,ir.ForwardRef=l,ir.Fragment=n,ir.Lazy=f,ir.Memo=d,ir.Portal=e,ir.Profiler=i,ir.StrictMode=r,ir.Suspense=c,ir.SuspenseList=u,ir.isContextConsumer=function(y){return x(y)===a},ir.isContextProvider=function(y){return x(y)===o},ir.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},ir.isForwardRef=function(y){return x(y)===l},ir.isFragment=function(y){return x(y)===n},ir.isLazy=function(y){return x(y)===f},ir.isMemo=function(y){return x(y)===d},ir.isPortal=function(y){return x(y)===e},ir.isProfiler=function(y){return x(y)===i},ir.isStrictMode=function(y){return x(y)===r},ir.isSuspense=function(y){return x(y)===c},ir.isSuspenseList=function(y){return x(y)===u},ir.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)},ir.typeOf=x,ir}var b6;function USe(){return b6||(b6=1,kT.exports=FSe()),kT.exports}var zSe=USe(),y6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",v6=null,jT=null,PY=t=>{if(t===v6&&Array.isArray(jT))return jT;var e=[];return S.Children.forEach(t,n=>{Nr(n)||(zSe.isFragment(n)?e=e.concat(PY(n.props.children)):e.push(n))}),jT=e,v6=t,e};function pO(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>y6(i)):r=[y6(e)],PY(t).forEach(i=>{var a=mf(i,"type.displayName")||mf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var gO=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,PT={},_6;function BSe(){return _6||(_6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(PT)),PT}var RT,w6;function HSe(){return w6||(w6=1,RT=BSe().isPlainObject),RT}var $Se=HSe();const VSe=_o($Se);function S6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function M6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S6(Object(n),!0).forEach(function(r){GSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function GSe(t,e,n){return(e=WSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function WSe(t){var e=qSe(t,"string");return typeof e=="symbol"?e:e+""}function qSe(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 zw(){return zw=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},zw.apply(null,arguments)}var E6=(t,e,n,r,i)=>{var a=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-a/2,",").concat(e+i),o+="L ".concat(t+n-a/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},KSe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},XSe=t=>{var e=Ir(t,KSe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,g=S.useRef(null),[p,x]=S.useState(-1),y=S.useRef(i),b=S.useRef(a),v=S.useRef(o),E=S.useRef(n),w=S.useRef(r),A=xg(t,"trapezoid-");if(S.useEffect(()=>{if(g.current&&g.current.getTotalLength)try{var P=g.current.getTotalLength();P&&x(P)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var N=In("recharts-trapezoid",l);if(!f)return S.createElement("g",null,S.createElement("path",zw({},fa(e),{className:N,d:E6(n,r,i,a,o)})));var C=y.current,T=b.current,O=v.current,k=E.current,R=w.current,z="0px ".concat(p===-1?1:p,"px"),D="".concat(p,"px 0px"),K=eK(["strokeDasharray"],u,c);return S.createElement(gg,{animationId:A,key:A,canBegin:p>0,duration:u,easing:c,isActive:f,begin:d},P=>{var W=Wn(C,i,P),Z=Wn(T,a,P),G=Wn(O,o,P),Y=Wn(k,n,P),X=Wn(R,r,P);g.current&&(y.current=W,b.current=Z,v.current=G,E.current=Y,w.current=X);var q=P>0?{transition:K,strokeDasharray:D}:{strokeDasharray:z};return S.createElement("path",zw({},fa(e),{className:N,d:E6(Y,X,W,Z,G),ref:g,style:M6(M6({},q),e.style)}))})},YSe=["option","shapeType","propTransformer","activeClassName"];function ZSe(t,e){if(t==null)return{};var n,r,i=QSe(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 QSe(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 N6(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 Bw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?N6(Object(n),!0).forEach(function(r){JSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):N6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JSe(t,e,n){return(e=eMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eMe(t){var e=tMe(t,"string");return typeof e=="symbol"?e:e+""}function tMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function nMe(t,e){return Bw(Bw({},e),t)}function rMe(t,e){return t==="symbols"}function A6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return S.createElement(iK,n);case"trapezoid":return S.createElement(XSe,n);case"sector":return S.createElement(lK,n);case"symbols":if(rMe(e))return S.createElement(IR,n);break;case"curve":return S.createElement(yp,n);default:return null}}function iMe(t){return S.isValidElement(t)?t.props:t}function xO(t){var{option:e,shapeType:n,propTransformer:r=nMe,activeClassName:i="recharts-active-shape"}=t,a=ZSe(t,YSe),o;if(S.isValidElement(e))o=S.cloneElement(e,Bw(Bw({},a),iMe(e)));else if(typeof e=="function")o=e(a,a.index);else if(VSe(e)&&typeof e!="boolean"){var l=r(e,a);o=S.createElement(A6,{shapeType:n,elementProps:l})}else{var c=a;o=S.createElement(A6,{shapeType:n,elementProps:c})}return a.isActive?S.createElement(Lr,{className:i},o):o}var bO=(t,e,n)=>{var r=xr();return(i,a)=>o=>{t?.(i,a,o),r($X({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},yO=t=>{var e=xr();return(n,r)=>i=>{t?.(n,r,i),e(y_e())}},vO=(t,e,n)=>{var r=xr();return(i,a)=>o=>{t?.(i,a,o),r(v_e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function a2(t){var{tooltipEntrySettings:e}=t,n=xr(),r=ji(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(p_e(e)):i.current!==e&&n(g_e({prev:i.current,next:e})),i.current=e)},[e,n,r]),S.useLayoutEffect(()=>()=>{i.current&&(n(x_e(i.current)),i.current=null)},[n]),null}function _O(t){var{legendPayload:e}=t,n=xr(),r=ji(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(Yq(e)):i.current!==e&&n(Zq({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(Qq(i.current)),i.current=null)},[n]),null}function aMe(t){var{legendPayload:e}=t,n=xr(),r=Rt(kn),i=S.useRef(null);return S.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(Yq(e)):i.current!==e&&n(Zq({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(Qq(i.current)),i.current=null)},[n]),null}var DT,sMe=()=>{var[t]=S.useState(()=>G0("uid-"));return t},oMe=(DT=Eie.useId)!==null&&DT!==void 0?DT:sMe;function RY(t,e){var n=oMe();return e||(t?"".concat(t,"-").concat(n):n)}var lMe=S.createContext(void 0),s2=t=>{var{id:e,type:n,children:r}=t,i=RY("recharts-".concat(n),e);return S.createElement(lMe.Provider,{value:i},r(i))},cMe={cartesianItems:[],polarItems:[]},DY=fs({name:"graphicalItems",initialState:cMe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Tr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=$o(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Tr()},removeCartesianGraphicalItem:{reducer(t,e){var n=$o(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Tr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Tr()},removePolarGraphicalItem:{reducer(t,e){var n=$o(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Tr()}}}),{addCartesianGraphicalItem:uMe,replaceCartesianGraphicalItem:dMe,removeCartesianGraphicalItem:hMe,addPolarGraphicalItem:fMe,removePolarGraphicalItem:mMe}=DY.actions,pMe=DY.reducer,gMe=t=>{var e=xr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(uMe(t)):n.current!==t&&e(dMe({prev:n.current,next:t})),n.current=t},[e,t]),S.useLayoutEffect(()=>()=>{n.current&&(e(hMe(n.current)),n.current=null)},[e]),null},wO=S.memo(gMe);function xMe(t){var e=xr();return S.useLayoutEffect(()=>(e(fMe(t)),()=>{e(mMe(t))}),[e,t]),null}var bMe=["key"],yMe=["onMouseEnter","onClick","onMouseLeave"],vMe=["id"],_Me=["id"];function T6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Vr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T6(Object(n),!0).forEach(function(r){wMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wMe(t,e,n){return(e=SMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function SMe(t){var e=MMe(t,"string");return typeof e=="symbol"?e:e+""}function MMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Pd(){return Pd=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Pd.apply(null,arguments)}function o2(t,e){if(t==null)return{};var n,r,i=EMe(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 EMe(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 NMe(t){var e=S.useMemo(()=>pO(t.children,cy),[t.children]),n=Rt(r=>LSe(r,t.id,e));return n==null?null:S.createElement(aMe,{legendPayload:n})}var AMe=S.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:o,dataKey:e,nameKey:n,name:Bd(l,e),hide:c,type:u,color:o,unit:""}};return S.createElement(a2,{tooltipEntrySettings:d})}),TMe=(t,e)=>t>e?"start":t<e?"end":"middle",CMe=(t,e,n)=>Ea(typeof e=="function"?e(t):e,n,n*.8),kMe=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=aK(a,o),c=i+Ea(t.cx,a,a/2),u=r+Ea(t.cy,o,o/2),d=Ea(t.innerRadius,l,0),f=CMe(n,t.outerRadius,l),g=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:g}},jMe=(t,e)=>{var n=Wi(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function PMe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var RMe=(t,e)=>{if(S.isValidElement(t))return S.cloneElement(t,e);if(typeof t=="function")return t(e);var n=In("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=o2(e,bMe);return S.createElement(yp,Pd({},i,{type:"linear",className:n}))},DMe=(t,e,n)=>{if(S.isValidElement(t))return S.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),S.isValidElement(r)))return r;var i=In("recharts-pie-label-text",PMe(t));return S.createElement(t2,Pd({},e,{alignmentBaseline:"middle",className:i}),r)};function OMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=za(n),c=ff(i),u=ff(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((g,p)=>{var x=(g.startAngle+g.endAngle)/2,y=fi(g.cx,g.cy,g.outerRadius+d,x),b=Vr(Vr(Vr(Vr({},l),g),{},{stroke:"none"},c),{},{index:p,textAnchor:TMe(y.x,g.cx)},y),v=Vr(Vr(Vr(Vr({},l),g),{},{fill:"none",stroke:g.fill},u),{},{index:p,points:[fi(g.cx,g.cy,g.outerRadius,x),y],key:"line"});return S.createElement(Ta,{zIndex:Kr.label,key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(p)},S.createElement(Lr,null,a&&RMe(a,v),DMe(i,b,Jn(g,o))))});return S.createElement(Lr,{className:"recharts-pie-labels"},f)}function LMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?S.createElement(n2,{label:i}):S.createElement(OMe,{sectors:e,props:n,showLabels:r})}function IMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Rt(jd),c=Rt(sO),u=Rt(a1e),{onMouseEnter:d,onClick:f,onMouseLeave:g}=i,p=o2(i,yMe),x=bO(d,i.dataKey,o),y=yO(g),b=vO(f,i.dataKey,o);return e==null||e.length===0?null:S.createElement(S.Fragment,null,e.map((v,E)=>{if(v?.startAngle===0&&v?.endAngle===0&&e.length!==1)return null;var w=u==null||u===o,A=String(E)===l&&(c==null||i.dataKey===c)&&w,N=l?r:null,C=n&&A?n:N,T=Vr(Vr({},v),{},{stroke:v.stroke,tabIndex:-1,[Lq]:E,[Iq]:i.dataKey});return S.createElement(Lr,Pd({key:"sector-".concat(v?.startAngle,"-").concat(v?.endAngle,"-").concat(v.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},zb(p,v,E),{onMouseEnter:x(v,E),onMouseLeave:y(v,E),onClick:b(v,E)}),S.createElement(xO,Pd({option:a??C,index:E,shapeType:"sector",isActive:A},T)))}))}function FMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,g=Math.abs(n.minAngle),p=jMe(l,c),x=Math.abs(p),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,b=r.filter(C=>Jn(C,u,0)!==0).length,v=(x>=360?b:b-1)*y,E=x-b*g-v,w=r.reduce((C,T)=>{var O=Jn(T,u,0);return C+(Ot(O)?O:0)},0),A;if(w>0){var N;A=r.map((C,T)=>{var O=Jn(C,u,0),k=Jn(C,d,T),R=kMe(n,a,C),z=(Ot(O)?O:0)/w,D,K=Vr(Vr({},C),i&&i[T]&&i[T].props);T?D=N.endAngle+Wi(p)*y*(O!==0?1:0):D=l;var P=D+Wi(p)*((O!==0?g:0)+z*E),W=(D+P)/2,Z=(R.innerRadius+R.outerRadius)/2,G=[{name:k,value:O,payload:K,dataKey:u,type:f}],Y=fi(R.cx,R.cy,Z,W);return N=Vr(Vr(Vr(Vr({},n.presentationProps),{},{percent:z,cornerRadius:typeof o=="string"?parseFloat(o):o,name:k,tooltipPayload:G,midAngle:W,middleRadius:Z,tooltipPosition:Y},K),R),{},{value:O,dataKey:u,startAngle:D,endAngle:P,payload:K,paddingAngle:Wi(p)*y}),N})}return A}function UMe(t){var{showLabels:e,sectors:n,children:r}=t,i=S.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return S.createElement(vSe,{value:e?i:void 0},r)}function zMe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:g}=e,p=xg(e,"recharts-pie-"),x=n.current,[y,b]=S.useState(!1),v=S.useCallback(()=>{typeof g=="function"&&g(),b(!1)},[g]),E=S.useCallback(()=>{typeof f=="function"&&f(),b(!0)},[f]);return S.createElement(UMe,{showLabels:!y,sectors:i},S.createElement(gg,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:E,onAnimationEnd:v,key:p},w=>{var A=[],N=i&&i[0],C=N?.startAngle;return i?.forEach((T,O)=>{var k=x&&x[O],R=O>0?mf(T,"paddingAngle",0):0;if(k){var z=Wn(k.endAngle-k.startAngle,T.endAngle-T.startAngle,w),D=Vr(Vr({},T),{},{startAngle:C+R,endAngle:C+z+R});A.push(D),C=D.endAngle}else{var{endAngle:K,startAngle:P}=T,W=Wn(0,K-P,w),Z=Vr(Vr({},T),{},{startAngle:C+R,endAngle:C+W+R});A.push(Z),C=Z.endAngle}}),n.current=A,S.createElement(Lr,null,S.createElement(IMe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),S.createElement(LMe,{showLabels:!y,sectors:i,props:e}),e.children)}var BMe={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Kr.area};function HMe(t){var{id:e}=t,n=o2(t,vMe),{hide:r,className:i,rootTabIndex:a}=t,o=S.useMemo(()=>pO(t.children,cy),[t.children]),l=Rt(d=>ISe(d,e,o)),c=S.useRef(null),u=In("recharts-pie",i);return r||l==null?(c.current=null,S.createElement(Lr,{tabIndex:a,className:u})):S.createElement(Ta,{zIndex:t.zIndex},S.createElement(AMe,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:l,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),S.createElement(Lr,{tabIndex:a,className:u},S.createElement(zMe,{props:Vr(Vr({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function OY(t){var e=Ir(t,BMe),{id:n}=e,r=o2(e,_Me),i=za(r);return S.createElement(s2,{id:n,type:"pie"},a=>S.createElement(S.Fragment,null,S.createElement(xMe,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),S.createElement(NMe,Pd({},r,{id:a})),S.createElement(HMe,Pd({},r,{id:a}))))}OY.displayName="Pie";var $Me=["points"];function C6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function OT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C6(Object(n),!0).forEach(function(r){VMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VMe(t,e,n){return(e=GMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GMe(t){var e=WMe(t,"string");return typeof e=="symbol"?e:e+""}function WMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Hw(){return Hw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Hw.apply(null,arguments)}function qMe(t,e){if(t==null)return{};var n,r,i=KMe(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 KMe(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 XMe(t){var{option:e,dotProps:n,className:r}=t;if(S.isValidElement(e))return S.cloneElement(e,n);if(typeof e=="function")return e(n);var i=In(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=qMe(a,$Me);return S.createElement(AY,Hw({},l,{className:i}))}function YMe(t,e){return t==null?!1:e?!0:t.length===1}function LY(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=Kr.scatter}=t;if(!YMe(e,n))return null;var d=gO(n),f=Ahe(n),g=e.map((x,y)=>{var b,v,E=OT(OT(OT({r:3},o),f),{},{index:y,cx:(b=x.x)!==null&&b!==void 0?b:void 0,cy:(v=x.y)!==null&&v!==void 0?v:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return S.createElement(XMe,{key:"dot-".concat(y),option:n,dotProps:E,className:i})}),p={};return l&&c!=null&&(p.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),S.createElement(Ta,{zIndex:u},S.createElement(Lr,Hw({className:r},p),g))}function k6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k6(Object(n),!0).forEach(function(r){ZMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZMe(t,e,n){return(e=QMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QMe(t){var e=JMe(t,"string");return typeof e=="symbol"?e:e+""}function JMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var e2e={xAxis:{},yAxis:{},zAxis:{}},IY=fs({name:"cartesianAxis",initialState:e2e,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Tr()},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:Tr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Tr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Tr()},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:Tr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Tr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Tr()},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:Tr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Tr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var o=[...a,r].slice(-3);t.yAxis[n]=j6(j6({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:t2e,replaceXAxis:n2e,removeXAxis:r2e,addYAxis:i2e,replaceYAxis:a2e,removeYAxis:s2e,addZAxis:wqe,replaceZAxis:Sqe,removeZAxis:Mqe,updateYAxisWidth:o2e}=IY.actions,l2e=IY.reducer,c2e=Qe([ki],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),u2e=Qe([c2e,nu,ru],(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)}}),l2=()=>Rt(u2e),d2e=()=>Rt(u1e);function P6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function LT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P6(Object(n),!0).forEach(function(r){h2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function h2e(t,e,n){return(e=f2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f2e(t){var e=m2e(t,"string");return typeof e=="symbol"?e:e+""}function m2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var p2e=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=LT(LT(LT({},l),ff(i)),FR(i)),u;return S.isValidElement(i)?u=S.cloneElement(i,c):typeof i=="function"?u=i(c):u=S.createElement(AY,c),S.createElement(Lr,{className:"recharts-active-dot",clipPath:o},u)};function uj(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=Kr.activeDot}=t,l=Rt(jd),c=d2e();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Nr(u)?null:S.createElement(Ta,{zIndex:o},S.createElement(p2e,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var g2e="Invariant failed";function x2e(t,e){throw new Error(g2e)}var b2e=["x","y"];function dj(){return dj=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},dj.apply(null,arguments)}function R6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Dx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R6(Object(n),!0).forEach(function(r){y2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function y2e(t,e,n){return(e=v2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function v2e(t){var e=_2e(t,"string");return typeof e=="symbol"?e:e+""}function _2e(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 w2e(t,e){if(t==null)return{};var n,r,i=S2e(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 S2e(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 M2e(t,e){var{x:n,y:r}=t,i=w2e(t,b2e),a="".concat(n),o=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),g=parseInt(f,10);return Dx(Dx(Dx(Dx(Dx({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:g,name:e.name,radius:e.radius})}function $w(t){return S.createElement(xO,dj({shapeType:"rectangle",propTransformer:M2e,activeClassName:"recharts-active-bar"},t))}var E2e=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ot(e))return e;var a=Ot(r)||Nr(r);return a?e(r,i):(a||x2e(),n)}},N2e={},FY=fs({name:"errorBars",initialState:N2e,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:Eqe,replaceErrorBar:Nqe,removeErrorBar:Aqe}=FY.actions,A2e=FY.reducer,T2e=["children"];function C2e(t,e){if(t==null)return{};var n,r,i=k2e(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 k2e(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 j2e={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},P2e=S.createContext(j2e);function UY(t){var{children:e}=t,n=C2e(t,T2e);return S.createElement(P2e.Provider,{value:n},e)}function c2(t,e){var n,r,i=Rt(u=>Il(u,t)),a=Rt(u=>Fl(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Bi.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Hi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function SO(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=l2(),{needClipX:a,needClipY:o,needClip:l}=c2(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return S.createElement("clipPath",{id:"clipPath-".concat(r)},S.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}function R2e(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&er(t.zIndex)?t.zIndex:e}var IT={exports:{}},FT={};var D6;function D2e(){if(D6)return FT;D6=1;var t=lg();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 FT.useSyncExternalStoreWithSelector=function(c,u,d,f,g){var p=i(null);if(p.current===null){var x={hasValue:!1,value:null};p.current=x}else x=p.current;p=o(function(){function b(N){if(!v){if(v=!0,E=N,N=f(N),g!==void 0&&x.hasValue){var C=x.value;if(g(C,N))return w=C}return w=N}if(C=w,n(E,N))return C;var T=f(N);return g!==void 0&&g(C,T)?(E=N,C):(E=N,w=T)}var v=!1,E,w,A=d===void 0?null:d;return[function(){return b(u())},A===null?void 0:function(){return b(A())}]},[u,d,f,g]);var y=r(c,p[0],p[1]);return a(function(){x.hasValue=!0,x.value=y},[y]),l(y),y},FT}var O6;function O2e(){return O6||(O6=1,IT.exports=D2e()),IT.exports}O2e();function L2e(t){t()}function I2e(){let t=null,e=null;return{clear(){t=null,e=null},notify(){L2e(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=e={callback:n,next:null,prev:e};return i.prev?i.prev.next=i:t=i,function(){!r||t===null||(r=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var L6={notify(){},get:()=>[]};function F2e(t,e){let n,r=L6,i=0,a=!1;function o(y){d();const b=r.subscribe(y);let v=!1;return()=>{v||(v=!0,b(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=I2e())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=L6)}function g(){a||(a=!0,d())}function p(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:g,tryUnsubscribe:p,getListeners:()=>r};return x}var U2e=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",z2e=U2e(),B2e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",H2e=B2e(),$2e=()=>z2e||H2e?S.useLayoutEffect:S.useEffect,V2e=$2e();function I6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function G2e(t,e){if(I6(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(!Object.prototype.hasOwnProperty.call(e,n[i])||!I6(t[n[i]],e[n[i]]))return!1;return!0}var W2e=Symbol.for("react-redux-context"),q2e=typeof globalThis<"u"?globalThis:{};function K2e(){if(!S.createContext)return{};const t=q2e[W2e]??=new Map;let e=t.get(S.createContext);return e||(e=S.createContext(null),t.set(S.createContext,e)),e}var X2e=K2e();function Y2e(t){const{children:e,context:n,serverState:r,store:i}=t,a=S.useMemo(()=>{const c=F2e(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=S.useMemo(()=>i.getState(),[i]);V2e(()=>{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||X2e;return S.createElement(l.Provider,{value:a},e)}var Z2e=Y2e,Q2e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function J2e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function uy(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(Q2e.has(r)){if(t[r]==null&&e[r]==null)continue;if(!G2e(t[r],e[r]))return!1}else if(!J2e(t[r],e[r]))return!1;return!0}var eEe=["onMouseEnter","onMouseLeave","onClick"],tEe=["value","background","tooltipPosition"],nEe=["id"],rEe=["onMouseEnter","onClick","onMouseLeave"];function Jc(){return Jc=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},Jc.apply(null,arguments)}function F6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function La(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F6(Object(n),!0).forEach(function(r){iEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iEe(t,e,n){return(e=aEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aEe(t){var e=sEe(t,"string");return typeof e=="symbol"?e:e+""}function sEe(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 Vw(t,e){if(t==null)return{};var n,r,i=oEe(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 oEe(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 lEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Bd(n,e),payload:t}]},cEe=S.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Bd(a,e),hide:o,type:c,color:i,unit:l}};return S.createElement(a2,{tooltipEntrySettings:u})});function uEe(t){var e=Rt(jd),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=Vw(a,eEe),d=bO(o,r),f=yO(l),g=vO(c,r);if(!i||n==null)return null;var p=ff(i);return S.createElement(Ta,{zIndex:R2e(i,Kr.barBackground)},n.map((x,y)=>{var{value:b,background:v,tooltipPosition:E}=x,w=Vw(x,tEe);if(!v)return null;var A=d(x,y),N=f(x,y),C=g(x,y),T=La(La(La(La(La({option:i,isActive:String(y)===e},w),{},{fill:"#eee"},v),p),zb(u,x,y)),{},{onMouseEnter:A,onMouseLeave:N,onClick:C,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return S.createElement($w,Jc({key:"background-bar-".concat(y)},T))}))}function dEe(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 La(La({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return S.createElement(hO,{value:e?i:void 0},n)}function hEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Rt(jd),c=Rt(sO),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?S.createElement(Ta,{zIndex:Kr.activeBar},S.createElement($w,Jc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):S.createElement($w,Jc({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function fEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return S.createElement($w,Jc({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function mEe(t){var e,{data:n,props:r}=t,i=(e=za(r))!==null&&e!==void 0?e:{},{id:a}=i,o=Vw(i,nEe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:g}=r,p=Vw(r,rEe),x=bO(d,c),y=yO(g),b=vO(f,c);return n?S.createElement(S.Fragment,null,n.map((v,E)=>S.createElement(Lr,Jc({key:"rectangle-".concat(v?.x,"-").concat(v?.y,"-").concat(v?.value,"-").concat(E),className:"recharts-bar-rectangle"},zb(p,v,E),{onMouseEnter:x(v,E),onMouseLeave:y(v,E),onClick:b(v,E)}),u?S.createElement(hEe,{shape:l,activeBar:u,baseProps:o,entry:v,index:E,dataKey:c}):S.createElement(fEe,{shape:l,baseProps:o,entry:v,index:E,dataKey:c})))):null}function pEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,g=xg(e,"recharts-bar-"),[p,x]=S.useState(!1),y=!p,b=S.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),v=S.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return S.createElement(dEe,{showLabels:y,rects:r},S.createElement(gg,{animationId:g,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:b,onAnimationStart:v,key:g},E=>{var w=E===1?r:r?.map((A,N)=>{var C=f&&f[N];if(C)return La(La({},A),{},{x:Wn(C.x,A.x,E),y:Wn(C.y,A.y,E),width:Wn(C.width,A.width,E),height:Wn(C.height,A.height,E)});if(i==="horizontal"){var T=Wn(0,A.height,E),O=Wn(A.stackedBarStart,A.y,E);return La(La({},A),{},{y:O,height:T})}var k=Wn(0,A.width,E),R=Wn(A.stackedBarStart,A.x,E);return La(La({},A),{},{width:k,x:R})});return E>0&&(n.current=w??null),w==null?null:S.createElement(Lr,null,S.createElement(mEe,{props:e,data:w}))}),S.createElement(n2,{label:e.label}),e.children)}function gEe(t){var e=S.useRef(null);return S.createElement(pEe,{previousRectanglesRef:e,props:t})}var zY=0,xEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Jn(t,e)}};class bEe extends S.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=In("recharts-bar",i),f=u;return S.createElement(Lr,{className:d,id:u},l&&S.createElement("defs",null,S.createElement(SO,{clipPathId:f,xAxisId:a,yAxisId:o})),S.createElement(Lr,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},S.createElement(uEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),S.createElement(gEe,this.props)))}}var yEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:zY,xAxisId:0,yAxisId:0,zIndex:Kr.bar};function vEe(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}=c2(e,n),g=jf(),p=ji(),x=pO(t.children,cy),y=Rt(E=>KEe(E,e,n,p,t.id,x));if(g!=="vertical"&&g!=="horizontal")return null;var b,v=y?.[0];return v==null||v.height==null||v.width==null?b=0:b=g==="vertical"?v.height/2:v.width/2,S.createElement(UY,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:xEe,errorBarOffset:b},S.createElement(bEe,Jc({},t,{layout:g,needClip:f,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function _Ee(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:g,cells:p,parentViewBox:x,dataStartIndex:y}=t,b=e==="horizontal"?l:o,v=d?b.scale.domain():null,E=Vpe({numericAxis:b}),w=b.scale(E);return f.map((A,N)=>{var C,T,O,k,R,z;d?C=Upe(d[N+y],v):(C=Jn(A,n),Array.isArray(C)||(C=[E,C]));var D=E2e(r,zY)(C[1],N);if(e==="horizontal"){var K,[P,W]=[l.scale(C[0]),l.scale(C[1])];T=tB({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:A,index:N}),O=(K=W??P)!==null&&K!==void 0?K:void 0,k=i.size;var Z=P-W;if(R=hs(Z)?0:Z,z={x:T,y:g.top,width:k,height:g.height},Math.abs(D)>0&&Math.abs(R)<Math.abs(D)){var G=Wi(R||D)*(Math.abs(D)-Math.abs(R));O-=G,R+=G}}else{var[Y,X]=[o.scale(C[0]),o.scale(C[1])];if(T=Y,O=tB({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:N}),k=X-Y,R=i.size,z={x:g.left,y:O,width:g.width,height:R},Math.abs(D)>0&&Math.abs(k)<Math.abs(D)){var q=Wi(k||D)*(Math.abs(D)-Math.abs(k));k+=q}}if(T==null||O==null||k==null||R==null)return null;var F=La(La({},A),{},{stackedBarStart:w,x:T,y:O,width:k,height:R,value:d?C:C[1],payload:A,background:z,tooltipPosition:{x:T+k/2,y:O+R/2},parentViewBox:x},p&&p[N]&&p[N].props);return F}).filter(Boolean)}function wEe(t){var e=Ir(t,yEe),n=ji();return S.createElement(s2,{id:e.id,type:"bar"},r=>S.createElement(S.Fragment,null,S.createElement(_O,{legendPayload:lEe(e)}),S.createElement(cEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),S.createElement(wO,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:Dq(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),S.createElement(Ta,{zIndex:e.zIndex},S.createElement(vEe,Jc({},e,{id:r})))))}var BY=S.memo(wEe,uy);BY.displayName="Bar";function U6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Qv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U6(Object(n),!0).forEach(function(r){SEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SEe(t,e,n){return(e=MEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MEe(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)}var NEe=(t,e)=>e,AEe=(t,e,n)=>n,TEe=(t,e,n,r)=>r,CEe=(t,e,n,r,i)=>i,dy=Qe([ty,CEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),kEe=Qe([dy],t=>t?.maxBarSize),jEe=(t,e,n,r,i,a)=>a,z6=(t,e,n)=>{var r=n??t;if(!Nr(r))return Ea(r,e,0)},PEe=Qe([kn,ty,NEe,AEe,TEe],(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")),REe=(t,e,n,r)=>{var i=kn(t);return i==="horizontal"?ib(t,"yAxis",n,r):ib(t,"xAxis",e,r)},DEe=(t,e,n)=>{var r=kn(t);return r==="horizontal"?D8(t,"xAxis",e):D8(t,"yAxis",n)},OEe=(t,e,n)=>{var r={},i=t.filter(qM),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,g=f.map(x=>x.dataKey),p=z6(e,n,f[0].barSize);return{stackId:d,dataKeys:g,barSize:p}}),c=a.map(u=>{var d=[u.dataKey].filter(g=>g!=null),f=z6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},LEe=Qe([PEe,ove,DEe],OEe),IEe=(t,e,n,r,i)=>{var a,o,l=dy(t,e,n,r,i);if(l!=null){var c=kn(t),u=iX(t),{maxBarSize:d}=l,f=Nr(d)?u:d,g,p;return c==="horizontal"?(g=Tl(t,"xAxis",e,r),p=Al(t,"xAxis",e,r)):(g=Tl(t,"yAxis",n,r),p=Al(t,"yAxis",n,r)),(a=(o=Td(g,p,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},HY=(t,e,n,r)=>{var i=kn(t),a,o;return i==="horizontal"?(a=Tl(t,"xAxis",e,r),o=Al(t,"xAxis",e,r)):(a=Tl(t,"yAxis",n,r),o=Al(t,"yAxis",n,r)),Td(a,o)};function FEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=Ea(t,n,0,!0),l,c=[];if(er(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((v,E)=>v+(E.barSize||0),0);f+=(a-1)*o,f>=n&&(f-=(a-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var g=(n-f)/2>>0,p={offset:g-o,size:0};l=r.reduce((v,E)=>{var w,A={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:p.offset+p.size+o,size:u?d:(w=E.barSize)!==null&&w!==void 0?w:0}},N=[...v,A];return p=N[N.length-1].position,N},c)}else{var x=Ea(e,n,0,!0);n-2*x-(a-1)*o<=0&&(o=0);var y=(n-2*x-(a-1)*o)/a;y>1&&(y>>=0);var b=er(i)?Math.min(y,i):y;l=r.reduce((v,E,w)=>[...v,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:x+(y+o)*w+(y-b)/2,size:b}}],c)}return l}}var UEe=(t,e,n,r,i,a,o)=>{var l=Nr(o)?e:o,c=FEe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>Qv(Qv({},u),{},{position:Qv(Qv({},u.position),{},{offset:u.position.offset-i/2})}))),c},zEe=Qe([LEe,iX,sve,aX,IEe,HY,kEe],UEe),BEe=(t,e,n,r)=>Tl(t,"xAxis",e,r),HEe=(t,e,n,r)=>Tl(t,"yAxis",n,r),$Ee=(t,e,n,r)=>Al(t,"xAxis",e,r),VEe=(t,e,n,r)=>Al(t,"yAxis",n,r),GEe=Qe([zEe,dy],(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}}),WEe=(t,e)=>{var n=WM(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)}}}},qEe=Qe([REe,dy],WEe),KEe=Qe([ki,XR,BEe,HEe,$Ee,VEe,GEe,kn,Zb,HY,qEe,dy,jEe],(t,e,n,r,i,a,o,l,c,u,d,f,g)=>{var{chartData:p,dataStartIndex:x,dataEndIndex:y}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:b}=f,v;if(b!=null&&b.length>0?v=b:v=p?.slice(x,y+1),v!=null)return _Ee({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:v,offset:t,cells:g,dataStartIndex:x})}}),$Y=t=>{var{chartData:e}=t,n=xr(),r=ji();return S.useEffect(()=>r?()=>{}:(n(q8(e)),()=>{n(q8(void 0))}),[e,n,r]),null},B6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},VY=fs({name:"brush",initialState:B6,reducers:{setBrushSettings(t,e){return e.payload==null?B6:e.payload}}}),{setBrushSettings:Tqe}=VY.actions,XEe=VY.reducer;function H6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jv(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){GY(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 GY(t,e,n){return(e=YEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YEe(t){var e=ZEe(t,"string");return typeof e=="symbol"?e:e+""}function ZEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var QEe=(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)}},JEe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return QEe({x:e,y:n},{x:r,y:i})};class u2{static create(e){return new u2(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}GY(u2,"EPS",1e-4);var eNe=t=>{var e=Object.keys(t).reduce((n,r)=>Jv(Jv({},n),{},{[r]:u2.create(t[r])}),{});return Jv(Jv({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[o,l]=a;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function tNe(t){return(t%180+180)%180}var nNe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=tNe(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)},rNe={dots:[],areas:[],lines:[]},WY=fs({name:"referenceElements",initialState:rNe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=$o(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=$o(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=$o(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:Cqe,removeDot:kqe,addArea:jqe,removeArea:Pqe,addLine:iNe,removeLine:aNe}=WY.actions,sNe=WY.reducer,qY=S.createContext(void 0),oNe=t=>{var{children:e}=t,[n]=S.useState("".concat(G0("recharts"),"-clip")),r=l2();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return S.createElement(qY.Provider,{value:n},S.createElement("defs",null,S.createElement("clipPath",{id:n},S.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},lNe=()=>S.useContext(qY);function $6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function V6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$6(Object(n),!0).forEach(function(r){cNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cNe(t,e,n){return(e=uNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uNe(t){var e=dNe(t,"string");return typeof e=="symbol"?e:e+""}function dNe(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 Gw(){return Gw=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},Gw.apply(null,arguments)}var hNe=(t,e)=>{var n;if(S.isValidElement(t))n=S.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!er(e.x1)||!er(e.y1)||!er(e.x2)||!er(e.y2))return null;n=S.createElement("line",Gw({},e,{className:"recharts-reference-line-line"}))}return n},fNe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(hs(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},mNe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(hs(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},pNe=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},gNe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=bo(o),f=bo(l);return f?fNe(l,u,n,i,t,e):d?mNe(o,u,n,r,t,e):c!=null&&c.length===2?pNe(c,u,n,t):null};function xNe(t){var e=xr();return S.useEffect(()=>(e(iNe(t)),()=>{e(aNe(t))})),null}function bNe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=ji(),l=lNe(),c=Rt(C=>Il(C,e)),u=Rt(C=>Fl(C,n)),d=Rt(C=>kd(C,"xAxis",e,o)),f=Rt(C=>kd(C,"yAxis",n,o)),g=Gb();if(!l||!g||c==null||u==null||d==null||f==null)return null;var p=eNe({x:d,y:f}),x=gNe(p,g,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:b},{x:v,y:E}]=x,w=a==="hidden"?"url(#".concat(l,")"):void 0,A=V6(V6({clipPath:w},fa(t)),{},{x1:y,y1:b,x2:v,y2:E}),N=JEe({x1:y,y1:b,x2:v,y2:E});return S.createElement(Ta,{zIndex:t.zIndex},S.createElement(Lr,{className:In("recharts-reference-line",i)},hNe(r,A),S.createElement(wY,Gw({},N,{lowerWidth:N.width,upperWidth:N.width}),S.createElement(MY,{label:t.label}),t.children)))}var yNe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Kr.line};function t0(t){var e=Ir(t,yNe);return S.createElement(S.Fragment,null,S.createElement(xNe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),S.createElement(bNe,e))}t0.displayName="ReferenceLine";function KY(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e)n.push(t[r]);return n}function vNe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return nNe(r,n)}function _Ne(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 Ww(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 wNe(t,e){return KY(t,e+1)}function SNe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var x=r?.[c];if(x===void 0)return{v:KY(r,u)};var y=c,b,v=()=>(b===void 0&&(b=n(x,y)),b),E=x.coordinate,w=c===0||Ww(t,E,v,d,l);w||(c=0,d=o,u+=1),w&&(d=E+t*(v()/2+i),c+=u)},g;u<=a.length;)if(g=f(),g)return g.v;return[]}function G6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function va(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G6(Object(n),!0).forEach(function(r){MNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MNe(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=NNe(t,"string");return typeof e=="symbol"?e:e+""}function NNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ANe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(g){var p=a[g],x,y=()=>(x===void 0&&(x=n(p,g)),x);if(g===o-1){var b=t*(p.coordinate+t*y()/2-c);a[g]=p=va(va({},p),{},{tickCoord:b>0?p.coordinate-b*t:p.coordinate})}else a[g]=p=va(va({},p),{},{tickCoord:p.coordinate});if(p.tickCoord!=null){var v=Ww(t,p.tickCoord,y,l,c);v&&(c=p.tickCoord-t*(y()/2+i),a[g]=va(va({},p),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function TNe(t,e,n,r,i,a){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),g=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=va(va({},d),{},{tickCoord:g>0?d.coordinate-g*t:d.coordinate}),d.tickCoord!=null){var p=Ww(t,d.tickCoord,()=>f,c,u);p&&(u=d.tickCoord-t*(f/2+i),o[l-1]=va(va({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,y=function(E){var w=o[E],A,N=()=>(A===void 0&&(A=n(w,E)),A);if(E===0){var C=t*(w.coordinate-t*N()/2-c);o[E]=w=va(va({},w),{},{tickCoord:C<0?w.coordinate-C*t:w.coordinate})}else o[E]=w=va(va({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var T=Ww(t,w.tickCoord,N,c,u);T&&(c=w.tickCoord+t*(N()/2+i),o[E]=va(va({},w),{},{isShow:!0}))}},b=0;b<x;b++)y(b);return o}function MO(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Ot(c)||pg.isSsr){var g;return(g=wNe(i,Ot(c)?c:0))!==null&&g!==void 0?g:[]}var p=[],x=l==="top"||l==="bottom"?"width":"height",y=d&&x==="width"?p0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},b=(w,A)=>{var N=typeof u=="function"?u(w.value,A):w.value;return x==="width"?vNe(p0(N,{fontSize:e,letterSpacing:n}),y,f):p0(N,{fontSize:e,letterSpacing:n})[x]},v=i.length>=2?Wi(i[1].coordinate-i[0].coordinate):1,E=_Ne(a,v,x);return c==="equidistantPreserveStart"?SNe(v,E,b,i,o):(c==="preserveStart"||c==="preserveStartEnd"?p=TNe(v,E,b,i,o,c==="preserveStartEnd"):p=ANe(v,E,b,i,o),p.filter(w=>w.isShow))}var CNe=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},kNe=["axisLine","width","height","className","hide","ticks","axisType"];function jNe(t,e){if(t==null)return{};var n,r,i=PNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function bf(){return bf=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},bf.apply(null,arguments)}function W6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ui(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W6(Object(n),!0).forEach(function(r){RNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RNe(t,e,n){return(e=DNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DNe(t){var e=ONe(t,"string");return typeof e=="symbol"?e:e+""}function ONe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ic={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:Kr.axis};function LNe(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=ui(ui(ui({},c),za(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=ui(ui({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=ui(ui({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return S.createElement("line",bf({},u,{className:In("recharts-cartesian-axis-line",mf(l,"className"))}))}function INe(t,e,n,r,i,a,o,l,c){var u,d,f,g,p,x,y=l?-1:1,b=t.tickSize||o,v=Ot(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,g=n+ +!l*i,f=g-y*b,x=f-y*c,p=v;break;case"left":f=g=t.coordinate,d=e+ +!l*r,u=d-y*b,p=u-y*c,x=v;break;case"right":f=g=t.coordinate,d=e+ +l*r,u=d+y*b,p=u+y*c,x=v;break;default:u=d=t.coordinate,g=n+ +l*i,f=g+y*b,x=f+y*c,p=v;break}return{line:{x1:u,y1:f,x2:d,y2:g},tick:{x:p,y:x}}}function FNe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function UNe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function zNe(t){var{option:e,tickProps:n,value:r}=t,i,a=In(n.className,"recharts-cartesian-axis-tick-value");if(S.isValidElement(e))i=S.cloneElement(e,ui(ui({},n),{},{className:a}));else if(typeof e=="function")i=e(ui(ui({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=In(o,e?.className)),i=S.createElement(t2,bf({},n,{className:o}),r)}return i}var BNe=S.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:g,y:p,width:x,height:y,tickSize:b,tickMargin:v,fontSize:E,letterSpacing:w,getTicksConfig:A,events:N,axisType:C}=t,T=MO(ui(ui({},A),{},{ticks:n}),E,w),O=FNe(d,f),k=UNe(d,f),R=za(A),z=ff(r),D={};typeof i=="object"&&(D=i);var K=ui(ui({},R),{},{fill:"none"},D),P=T.map(G=>ui({entry:G},INe(G,g,p,x,y,d,b,f,v))),W=P.map(G=>{var{entry:Y,line:X}=G;return S.createElement(Lr,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},i&&S.createElement("line",bf({},K,X,{className:In("recharts-cartesian-axis-tick-line",mf(i,"className"))})))}),Z=P.map((G,Y)=>{var{entry:X,tick:q}=G,F=ui(ui(ui(ui({textAnchor:O,verticalAnchor:k},R),{},{stroke:"none",fill:a},z),q),{},{index:Y,payload:X,visibleTicksCount:T.length,tickFormatter:o,padding:c},u);return S.createElement(Lr,bf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(X.value,"-").concat(X.coordinate,"-").concat(X.tickCoord)},zb(N,X,Y)),r&&S.createElement(zNe,{option:r,tickProps:F,value:"".concat(typeof o=="function"?o(X.value,Y):X.value).concat(l||"")}))});return S.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},Z.length>0&&S.createElement(Ta,{zIndex:Kr.label},S.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},Z)),W.length>0&&S.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},W))}),HNe=S.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=jNe(t,kNe),[d,f]=S.useState(""),[g,p]=S.useState(""),x=S.useRef(null);S.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var b;return CNe({ticks:x.current,label:(b=t.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=S.useCallback(b=>{if(b){var v=b.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=v;var E=v[0];if(E){var w=window.getComputedStyle(E),A=w.fontSize,N=w.letterSpacing;(A!==d||N!==g)&&(f(A),p(N))}}},[d,g]);return o||r!=null&&r<=0||i!=null&&i<=0?null:S.createElement(Ta,{zIndex:t.zIndex},S.createElement(Lr,{className:In("recharts-cartesian-axis",a)},S.createElement(LNe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:za(t)}),S.createElement(BNe,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:g,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),S.createElement(wY,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},S.createElement(MY,{label:t.label,labelRef:t.labelRef}),t.children)))}),EO=S.forwardRef((t,e)=>{var n=Ir(t,Ic);return S.createElement(HNe,bf({},n,{ref:e}))});EO.displayName="CartesianAxis";var $Ne=["x1","y1","x2","y2","key"],VNe=["offset"],GNe=["xAxisId","yAxisId"],WNe=["xAxisId","yAxisId"];function q6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function wa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q6(Object(n),!0).forEach(function(r){qNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qNe(t,e,n){return(e=KNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KNe(t){var e=XNe(t,"string");return typeof e=="symbol"?e:e+""}function XNe(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 Ih(){return Ih=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},Ih.apply(null,arguments)}function qw(t,e){if(t==null)return{};var n,r,i=YNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function YNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var ZNe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:l}=t;return S.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function XY(t){var{option:e,lineItemProps:n}=t,r;if(S.isValidElement(e))r=S.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:o,x2:l,y2:c,key:u}=n,d=qw(n,$Ne),f=(i=za(d))!==null&&i!==void 0?i:{},{offset:g}=f,p=qw(f,VNe);r=S.createElement("line",Ih({},p,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function QNe(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=qw(t,GNe),c=i.map((u,d)=>{var f=wa(wa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return S.createElement(XY,{key:"line-".concat(d),option:r,lineItemProps:f})});return S.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function JNe(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=qw(t,WNe),c=i.map((u,d)=>{var f=wa(wa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return S.createElement(XY,{option:r,lineItemProps:f,key:"line-".concat(d)})});return S.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function eAe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+o-f:u[g+1]-f;if(x<=0)return null;var y=g%e.length;return S.createElement("rect",{key:"react-".concat(g),y:f,x:r,height:x,width:a,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function tAe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,g)=>f-g);i!==u[0]&&u.unshift(0);var d=u.map((f,g)=>{var p=!u[g+1],x=p?i+o-f:u[g+1]-f;if(x<=0)return null;var y=g%n.length;return S.createElement("rect",{key:"react-".concat(g),x:f,y:a,width:x,height:l,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var nAe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return Pq(MO(wa(wa(wa({},Ic),n),{},{ticks:Rq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},rAe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return Pq(MO(wa(wa(wa({},Ic),n),{},{ticks:Rq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},iAe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Kr.grid};function Kw(t){var e=ZR(),n=QR(),r=Hq(),i=wa(wa({},Ir(t,iAe)),{},{x:Ot(t.x)?t.x:r.left,y:Ot(t.y)?t.y:r.top,width:Ot(t.width)?t.width:r.width,height:Ot(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:g,verticalValues:p}=i,x=ji(),y=Rt(k=>O8(k,"xAxis",a,x)),b=Rt(k=>O8(k,"yAxis",o,x));if(!El(u)||!El(d)||!Ot(l)||!Ot(c))return null;var v=i.verticalCoordinatesGenerator||nAe,E=i.horizontalCoordinatesGenerator||rAe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof E=="function"){var N=g&&g.length,C=E({yAxis:b?wa(wa({},b),{},{ticks:N?g:b.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);xw(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}if((!A||!A.length)&&typeof v=="function"){var T=p&&p.length,O=v({xAxis:y?wa(wa({},y),{},{ticks:T?p:y.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);xw(Array.isArray(O),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof O,"]")),Array.isArray(O)&&(A=O)}return S.createElement(Ta,{zIndex:i.zIndex},S.createElement("g",{className:"recharts-cartesian-grid"},S.createElement(ZNe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(eAe,Ih({},i,{horizontalPoints:w})),S.createElement(tAe,Ih({},i,{verticalPoints:A})),S.createElement(QNe,Ih({},i,{offset:r,horizontalPoints:w,xAxis:y,yAxis:b})),S.createElement(JNe,Ih({},i,{offset:r,verticalPoints:A,xAxis:y,yAxis:b}))))}Kw.displayName="CartesianGrid";var YY=(t,e,n,r)=>Tl(t,"xAxis",e,r),ZY=(t,e,n,r)=>Al(t,"xAxis",e,r),QY=(t,e,n,r)=>Tl(t,"yAxis",n,r),JY=(t,e,n,r)=>Al(t,"yAxis",n,r),aAe=Qe([kn,YY,QY,ZY,JY],(t,e,n,r,i)=>Ll(t,"xAxis")?Td(e,r,!1):Td(n,i,!1)),sAe=(t,e,n,r,i)=>i;function oAe(t){return t.type==="line"}var lAe=Qe([ty,sAe],(t,e)=>t.filter(oAe).find(n=>n.id===e)),cAe=Qe([kn,YY,QY,ZY,JY,lAe,aAe,Zb],(t,e,n,r,i,a,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:g}=a,p;if(g!=null&&g.length>0?p=g:p=c?.slice(u,d+1),p!=null)return CAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:p})}});function eZ(t){var e=ff(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 uAe=["id"],dAe=["type","layout","connectNulls","needClip","shape"],hAe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function sb(){return sb=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},sb.apply(null,arguments)}function K6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K6(Object(n),!0).forEach(function(r){fAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fAe(t,e,n){return(e=mAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mAe(t){var e=pAe(t,"string");return typeof e=="symbol"?e:e+""}function pAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function NO(t,e){if(t==null)return{};var n,r,i=gAe(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 gAe(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 xAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Bd(n,e),payload:t}]},bAe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Bd(o,e),hide:l,type:u,color:r,unit:c}};return S.createElement(a2,{tooltipEntrySettings:d})}),tZ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function yAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var vAe=(t,e,n)=>{var r=n.reduce((f,g)=>f+g);if(!r)return tZ(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,o]:[o];return[...yAe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function _Ae(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=NO(r,uAe),u=za(c);return S.createElement(LY,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function wAe(t){var{showLabels:e,children:n,points:r}=t,i=S.useMemo(()=>r?.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return hl(hl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return S.createElement(hO,{value:e?i:void 0},n)}function X6(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=NO(a,dAe),g=hl(hl({},fa(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return S.createElement(S.Fragment,null,r?.length>1&&S.createElement(xO,sb({shapeType:"curve",option:d},g,{pathRef:n})),S.createElement(_Ae,{points:r,clipPathId:e,props:a}))}function SAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function MAe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:g,width:p,height:x,onAnimationEnd:y,onAnimationStart:b}=n,v=i.current,E=xg(o,"recharts-line-"),w=S.useRef(E),[A,N]=S.useState(!1),C=!A,T=S.useCallback(()=>{typeof y=="function"&&y(),N(!1)},[y]),O=S.useCallback(()=>{typeof b=="function"&&b(),N(!0)},[b]),k=SAe(r.current),R=S.useRef(0);w.current!==E&&(R.current=a.current,w.current=E);var z=R.current;return S.createElement(wAe,{points:o,showLabels:C},n.children,S.createElement(gg,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:O,key:E},D=>{var K=Wn(z,k+z,D),P=Math.min(K,k),W;if(c)if(l){var Z="".concat(l).split(/[,\s]+/gim).map(X=>parseFloat(X));W=vAe(P,k,Z)}else W=tZ(k,P);else W=l==null?void 0:String(l);if(D>0&&k>0&&(i.current=o,a.current=Math.max(a.current,P)),v){var G=v.length/o.length,Y=D===1?o:o.map((X,q)=>{var F=Math.floor(q*G);if(v[F]){var V=v[F];return hl(hl({},X),{},{x:Wn(V.x,X.x,D),y:Wn(V.y,X.y,D)})}return g?hl(hl({},X),{},{x:Wn(p*2,X.x,D),y:Wn(x/2,X.y,D)}):hl(hl({},X),{},{x:X.x,y:X.y})});return i.current=Y,S.createElement(X6,{props:n,points:Y,clipPathId:e,pathRef:r,strokeDasharray:W})}return S.createElement(X6,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:W})}),S.createElement(n2,{label:n.label}))}function EAe(t){var{clipPathId:e,props:n}=t,r=S.useRef(null),i=S.useRef(0),a=S.useRef(null);return S.createElement(MAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var NAe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:Jn(t.payload,e)}};class AAe extends S.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:g,zIndex:p}=this.props;if(e)return null;var x=In("recharts-line",i),y=f,{r:b,strokeWidth:v}=eZ(n),E=gO(n),w=b*2+v,A=g?"url(#clipPath-".concat(E?"":"dots-").concat(y,")"):void 0;return S.createElement(Ta,{zIndex:p},S.createElement(Lr,{className:x},g&&S.createElement("defs",null,S.createElement(SO,{clipPathId:y,xAxisId:a,yAxisId:o}),!E&&S.createElement("clipPath",{id:"clipPath-dots-".concat(y)},S.createElement("rect",{x:c-w/2,y:l-w/2,width:u+w,height:d+w}))),S.createElement(UY,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:NAe,errorBarOffset:0},S.createElement(EAe,{props:this.props,clipPathId:y}))),S.createElement(uj,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var nZ={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Kr.line,type:"linear"};function TAe(t){var e=Ir(t,nZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:g,xAxisId:p,yAxisId:x,id:y}=e,b=NO(e,hAe),{needClip:v}=c2(p,x),E=l2(),w=jf(),A=ji(),N=Rt(R=>cAe(R,p,x,A,y));if(w!=="horizontal"&&w!=="vertical"||N==null||E==null)return null;var{height:C,width:T,x:O,y:k}=E;return S.createElement(AAe,sb({},b,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:g,xAxisId:p,yAxisId:x,points:N,layout:w,height:C,width:T,left:O,top:k,needClip:v}))}function CAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=Jn(u,o);if(e==="horizontal"){var g=gw({axis:n,ticks:i,bandSize:l,entry:u,index:d}),p=Nr(f)?null:r.scale(f);return{x:g,y:p,value:f,payload:u}}var x=Nr(f)?null:n.scale(f),y=gw({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||y==null?null:{x,y,value:f,payload:u}}).filter(Boolean)}function kAe(t){var e=Ir(t,nZ),n=ji();return S.createElement(s2,{id:e.id,type:"line"},r=>S.createElement(S.Fragment,null,S.createElement(_O,{legendPayload:xAe(e)}),S.createElement(bAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),S.createElement(wO,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),S.createElement(TAe,sb({},e,{id:r}))))}var rZ=S.memo(kAe,uy);rZ.displayName="Line";var iZ=(t,e,n,r)=>Tl(t,"xAxis",e,r),aZ=(t,e,n,r)=>Al(t,"xAxis",e,r),sZ=(t,e,n,r)=>Tl(t,"yAxis",n,r),oZ=(t,e,n,r)=>Al(t,"yAxis",n,r),jAe=Qe([kn,iZ,sZ,aZ,oZ],(t,e,n,r,i)=>Ll(t,"xAxis")?Td(e,r,!1):Td(n,i,!1)),PAe=(t,e,n,r,i)=>i,lZ=Qe([ty,PAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),RAe=(t,e,n,r,i)=>{var a,o=lZ(t,e,n,r,i);if(o!=null){var l=kn(t),c=Ll(l,"xAxis"),u;if(c?u=ib(t,"yAxis",n,r):u=ib(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=WM(o);if(!(d==null||f==null)){var g=(a=u[d])===null||a===void 0?void 0:a.stackedData;return g?.find(p=>p.key===f)}}}},DAe=Qe([kn,iZ,sZ,aZ,oZ,RAe,Zb,jAe,lZ,lve],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:g}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:p}=c,x;if(p&&p.length>0?x=p:x=d?.slice(f,g+1),x!=null)return JAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),OAe=["id"],LAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Kh(){return Kh=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},Kh.apply(null,arguments)}function cZ(t,e){if(t==null)return{};var n,r,i=IAe(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 IAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Y6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y6(Object(n),!0).forEach(function(r){FAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function 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 Xw(t,e){return t&&t!=="none"?t:e}var BAe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:Xw(r,i),value:Bd(n,e),payload:t}]},HAe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Bd(o,e),hide:l,type:u,color:Xw(r,a),unit:c}};return S.createElement(a2,{tooltipEntrySettings:d})});function $Ae(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=za(r);return S.createElement(LY,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function VAe(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 hp(hp({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return S.createElement(hO,{value:e?i:void 0},n)}function Z6(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,g=cZ(a,OAe),p=za(g),x=fa(g);return S.createElement(S.Fragment,null,e?.length>1&&S.createElement(Lr,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},S.createElement(yp,Kh({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&S.createElement(yp,Kh({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&S.createElement(yp,Kh({},p,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),S.createElement($Ae,{points:e,props:g,clipPathId:i}))}function GAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!er(a)||!er(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return Ot(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Ot(c)?S.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function WAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!er(a)||!er(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return Ot(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Ot(c)?S.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function qAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?S.createElement(GAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):S.createElement(WAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function KAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:g,onAnimationEnd:p}=r,x=S.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=xg(x,"recharts-area-"),b=Nge(),[v,E]=S.useState(!1),w=!v,A=S.useCallback(()=>{typeof p=="function"&&p(),E(!1)},[p]),N=S.useCallback(()=>{typeof g=="function"&&g(),E(!0)},[g]);if(b==null)return null;var C=i.current,T=a.current;return S.createElement(VAe,{showLabels:w,points:o},r.children,S.createElement(gg,{animationId:y,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:N,key:y},O=>{if(C){var k=C.length/o.length,R=O===1?o:o.map((D,K)=>{var P=Math.floor(K*k);if(C[P]){var W=C[P];return hp(hp({},D),{},{x:Wn(W.x,D.x,O),y:Wn(W.y,D.y,O)})}return D}),z;return Ot(l)?z=Wn(T,l,O):Nr(l)||hs(l)?z=Wn(T,0,O):z=l.map((D,K)=>{var P=Math.floor(K*k);if(Array.isArray(T)&&T[P]){var W=T[P];return hp(hp({},D),{},{x:Wn(W.x,D.x,O),y:Wn(W.y,D.y,O)})}return D}),O>0&&(i.current=R,a.current=z),S.createElement(Z6,{points:R,baseLine:z,needClip:e,clipPathId:n,props:r})}return O>0&&(i.current=o,a.current=l),S.createElement(Lr,null,c&&S.createElement("defs",null,S.createElement("clipPath",{id:"animationClipPath-".concat(n)},S.createElement(qAe,{alpha:O,points:o,baseLine:l,layout:b,strokeWidth:r.strokeWidth}))),S.createElement(Lr,{clipPath:"url(#animationClipPath-".concat(n,")")},S.createElement(Z6,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),S.createElement(n2,{label:r.label}))}function XAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=S.useRef(null),a=S.useRef();return S.createElement(KAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class YAe extends S.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:g,baseLine:p,zIndex:x}=this.props;if(e)return null;var y=In("recharts-area",i),b=g,{r:v,strokeWidth:E}=eZ(n),w=gO(n),A=v*2+E,N=l?"url(#clipPath-".concat(w?"":"dots-").concat(b,")"):void 0;return S.createElement(Ta,{zIndex:x},S.createElement(Lr,{className:y},l&&S.createElement("defs",null,S.createElement(SO,{clipPathId:b,xAxisId:c,yAxisId:u}),!w&&S.createElement("clipPath",{id:"clipPath-dots-".concat(b)},S.createElement("rect",{x:o-A/2,y:a-A/2,width:d+A,height:f+A}))),S.createElement(XAe,{needClip:l,clipPathId:b,props:this.props})),S.createElement(uj,{points:r,mainColor:Xw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:N}),this.props.isRange&&Array.isArray(p)&&S.createElement(uj,{points:p,mainColor:Xw(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:N}))}}var uZ={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:Kr.area};function ZAe(t){var e,n=Ir(t,uZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:g,legendType:p,stroke:x,xAxisId:y,yAxisId:b}=n,v=cZ(n,LAe),E=jf(),w=aY(),{needClip:A}=c2(y,b),N=ji(),{points:C,isRange:T,baseLine:O}=(e=Rt(P=>DAe(P,y,b,N,t.id)))!==null&&e!==void 0?e:{},k=l2();if(E!=="horizontal"&&E!=="vertical"||k==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:R,width:z,x:D,y:K}=k;return!C||!C.length?null:S.createElement(YAe,Kh({},v,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:O,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:R,hide:f,layout:E,isAnimationActive:g==="auto"?!pg.isSsr:g,isRange:T,legendType:p,needClip:A,points:C,stroke:x,width:z,left:D,top:K,xAxisId:y,yAxisId:b}))}var QAe=(t,e,n,r,i)=>{var a=n??e;if(Ot(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 JAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:g,bandSize:p}=t,x=i&&i.length,y=QAe(a,o,n,l,c),b=a==="horizontal",v=!1,E=u.map((A,N)=>{var C;x?C=i[d+N]:(C=Jn(A,r),Array.isArray(C)?v=!0:C=[y,C]);var T=C[1]==null||x&&!e&&Jn(A,r)==null;return b?{x:gw({axis:l,ticks:f,bandSize:p,entry:A,index:N}),y:T?null:c.scale(C[1]),value:C,payload:A}:{x:T?null:l.scale(C[1]),y:gw({axis:c,ticks:g,bandSize:p,entry:A,index:N}),value:C,payload:A}}),w;return x||v?w=E.map(A=>{var N=Array.isArray(A.value)?A.value[0]:null;return b?{x:A.x,y:N!=null&&A.y!=null?c.scale(N):null,payload:A.payload}:{x:N!=null?l.scale(N):null,y:A.y,payload:A.payload}}):w=b?c.scale(y):l.scale(y),{points:E,baseLine:w,isRange:v}}function eTe(t){var e=Ir(t,uZ),n=ji();return S.createElement(s2,{id:e.id,type:"area"},r=>S.createElement(S.Fragment,null,S.createElement(_O,{legendPayload:BAe(e)}),S.createElement(HAe,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),S.createElement(wO,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:Dq(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),S.createElement(ZAe,Kh({},e,{id:r}))))}var dZ=S.memo(eTe,uy);dZ.displayName="Area";var tTe=["domain","range"],nTe=["domain","range"];function Q6(t,e){if(t==null)return{};var n,r,i=rTe(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 rTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function J6(t,e){return t===e?!0:Array.isArray(t)&&t.length===2&&Array.isArray(e)&&e.length===2?t[0]===e[0]&&t[1]===e[1]:!1}function hZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=Q6(t,tTe),{domain:a,range:o}=e,l=Q6(e,nTe);return!J6(n,a)||!J6(r,o)?!1:uy(i,l)}var iTe=["dangerouslySetInnerHTML","ticks"],aTe=["id"];function hj(){return hj=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},hj.apply(null,arguments)}function eH(t,e){if(t==null)return{};var n,r,i=sTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function sTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function oTe(t){var e=xr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(t2e(t)):n.current!==t&&e(n2e({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(r2e(n.current)),n.current=null)},[e]),null}var lTe=t=>{var{xAxisId:e,className:n}=t,r=Rt(XR),i=ji(),a="xAxis",o=Rt(b=>kd(b,a,e,i)),l=Rt(b=>IX(b,a,e,i)),c=Rt(b=>RX(b,e)),u=Rt(b=>a_e(b,e)),d=Rt(b=>mX(b,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:g}=t,p=eH(t,iTe),{id:x}=d,y=eH(d,aTe);return S.createElement(EO,hj({},p,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:In("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},cTe={allowDataOverflow:Bi.allowDataOverflow,allowDecimals:Bi.allowDecimals,allowDuplicatedCategory:Bi.allowDuplicatedCategory,angle:Bi.angle,axisLine:Ic.axisLine,height:Bi.height,hide:!1,includeHidden:Bi.includeHidden,interval:Bi.interval,minTickGap:Bi.minTickGap,mirror:Bi.mirror,orientation:Bi.orientation,padding:Bi.padding,reversed:Bi.reversed,scale:Bi.scale,tick:Bi.tick,tickCount:Bi.tickCount,tickLine:Ic.tickLine,tickSize:Ic.tickSize,type:Bi.type,xAxisId:0},uTe=t=>{var e=Ir(t,cTe);return S.createElement(S.Fragment,null,S.createElement(oTe,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),S.createElement(lTe,e))},Yw=S.memo(uTe,hZ);Yw.displayName="XAxis";var dTe=["dangerouslySetInnerHTML","ticks"],hTe=["id"];function fj(){return fj=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},fj.apply(null,arguments)}function tH(t,e){if(t==null)return{};var n,r,i=fTe(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 fTe(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 mTe(t){var e=xr(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(i2e(t)):n.current!==t&&e(a2e({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(s2e(n.current)),n.current=null)},[e]),null}var pTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=S.useRef(null),o=S.useRef(null),l=Rt(XR),c=ji(),u=xr(),d="yAxis",f=Rt(N=>kd(N,d,e,c)),g=Rt(N=>DX(N,e)),p=Rt(N=>o_e(N,e)),x=Rt(N=>IX(N,d,e,c)),y=Rt(N=>pX(N,e));if(S.useLayoutEffect(()=>{if(!(r!=="auto"||!g||dO(i)||S.isValidElement(i)||y==null)){var N=a.current;if(N){var C=N.getCalculatedWidth();Math.round(g.width)!==Math.round(C)&&u(o2e({id:e,width:C}))}}},[x,g,u,i,e,r,y]),g==null||p==null||y==null)return null;var{dangerouslySetInnerHTML:b,ticks:v}=t,E=tH(t,dTe),{id:w}=y,A=tH(y,hTe);return S.createElement(EO,fj({},E,A,{ref:a,labelRef:o,scale:f,x:p.x,y:p.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:g.width,height:g.height,className:In("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},gTe={allowDataOverflow:Hi.allowDataOverflow,allowDecimals:Hi.allowDecimals,allowDuplicatedCategory:Hi.allowDuplicatedCategory,angle:Hi.angle,axisLine:Ic.axisLine,hide:!1,includeHidden:Hi.includeHidden,interval:Hi.interval,minTickGap:Hi.minTickGap,mirror:Hi.mirror,orientation:Hi.orientation,padding:Hi.padding,reversed:Hi.reversed,scale:Hi.scale,tick:Hi.tick,tickCount:Hi.tickCount,tickLine:Ic.tickLine,tickSize:Ic.tickSize,type:Hi.type,width:Hi.width,yAxisId:0},xTe=t=>{var e=Ir(t,gTe);return S.createElement(S.Fragment,null,S.createElement(mTe,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),S.createElement(pTe,e))},Zw=S.memo(xTe,hZ);Zw.displayName="YAxis";var bTe=(t,e)=>e,AO=Qe([bTe,kn,hX,Ri,JX,au,w1e,ki],C1e),TO=t=>{var e=t.currentTarget.getBoundingClientRect(),n=e.width/t.currentTarget.offsetWidth,r=e.height/t.currentTarget.offsetHeight;return{chartX:Math.round((t.clientX-e.left)/n),chartY:Math.round((t.clientY-e.top)/r)}},fZ=yo("mouseClick"),mZ=$b();mZ.startListening({actionCreator:fZ,effect:(t,e)=>{var n=t.payload,r=AO(e.getState(),TO(n));r?.activeIndex!=null&&e.dispatch(__e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var mj=yo("mouseMove"),pZ=$b(),e_=null;pZ.startListening({actionCreator:mj,effect:(t,e)=>{var n=t.payload;e_!==null&&cancelAnimationFrame(e_);var r=TO(n);e_=requestAnimationFrame(()=>{var i=e.getState(),a=eO(i,i.tooltip.settings.shared);if(a==="axis"){var o=AO(i,r);o?.activeIndex!=null?e.dispatch(GX({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(VX())}e_=null})}});var nH={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},gZ=fs({name:"rootProps",initialState:nH,reducers:{updateOptions:(t,e)=>{var n;t.accessibilityLayer=e.payload.accessibilityLayer,t.barCategoryGap=e.payload.barCategoryGap,t.barGap=(n=e.payload.barGap)!==null&&n!==void 0?n:nH.barGap,t.barSize=e.payload.barSize,t.maxBarSize=e.payload.maxBarSize,t.stackOffset=e.payload.stackOffset,t.syncId=e.payload.syncId,t.syncMethod=e.payload.syncMethod,t.className=e.payload.className,t.baseValue=e.payload.baseValue,t.reverseStackOrder=e.payload.reverseStackOrder}}}),yTe=gZ.reducer,{updateOptions:vTe}=gZ.actions,xZ=fs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:_Te}=xZ.actions,wTe=xZ.reducer,bZ=yo("keyDown"),yZ=yo("focus"),CO=$b();CO.startListening({actionCreator:bZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=tO(i,Eg(n),ry(n),oy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=au(n);if(a==="Enter"){var u=Fw(n,"axis","hover",String(i.index));e.dispatch(ij({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=d_e(n),f=d==="left-to-right"?1:-1,g=a==="ArrowRight"?1:-1,p=l+g*f;if(!(c==null||p>=c.length||p<0)){var x=Fw(n,"axis","hover",String(p));e.dispatch(ij({active:!0,activeIndex:p.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});CO.startListening({actionCreator:yZ,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=Fw(n,"axis","hover",String(a));e.dispatch(ij({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var Qs=yo("externalEvent"),vZ=$b(),UT=new Map;vZ.startListening({actionCreator:Qs,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=UT.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:o1e(l),activeDataKey:sO(l),activeIndex:jd(l),activeLabel:nY(l),activeTooltipIndex:jd(l),isTooltipActive:l1e(l)};n(c,r)}finally{UT.delete(i)}});UT.set(i,o)}}});var STe=Qe([Mg],t=>t.tooltipItemPayloads),MTe=Qe([STe,ay,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var o=e(a,n);return o}}}),_Z=yo("touchMove"),wZ=$b();wZ.startListening({actionCreator:_Z,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=eO(r,r.tooltip.settings.shared);if(i==="axis"){var a=AO(r,TO({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(GX({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var o,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(Lq),d=(o=c.getAttribute(Iq))!==null&&o!==void 0?o:void 0,f=MTe(e.getState(),u,d);e.dispatch($X({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var ETe=rq({brush:XEe,cartesianAxis:l2e,chartData:swe,errorBars:A2e,graphicalItems:pMe,layout:Rpe,legend:Bge,options:twe,polarAxis:kSe,polarOptions:wTe,referenceElements:sNe,rootProps:yTe,tooltip:w_e,zIndex:$1e}),NTe=function(e){return ipe({reducer:ETe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([mZ.middleware,pZ.middleware,CO.middleware,vZ.middleware,wZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(bq({type:"raf"}))},devTools:pg.devToolsEnabled})};function SZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ji(),a=S.useRef(null);if(i)return n;a.current==null&&(a.current=NTe(e));var o=zR;return S.createElement(Z2e,{context:o,store:a.current},n)}function ATe(t){var{layout:e,margin:n}=t,r=xr(),i=ji();return S.useEffect(()=>{i||(r(kpe(e)),r(Cpe(n)))},[r,i,e,n]),null}var MZ=S.memo(ATe,uy);function EZ(t){var e=xr();return S.useEffect(()=>{e(vTe(t))},[e,t]),null}function rH(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=RY("".concat(r).concat(e)),a=xr();return S.useLayoutEffect(()=>(a(B1e({zIndex:e,elementId:i,isPanorama:n})),()=>{a(H1e({zIndex:e,isPanorama:n}))}),[a,e,i,n]),S.createElement("g",{tabIndex:-1,id:i})}function iH(t){var{children:e,isPanorama:n}=t,r=Rt(j1e);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return S.createElement(S.Fragment,null,i.map(o=>S.createElement(rH,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>S.createElement(rH,{key:o,zIndex:o,isPanorama:n})))}var TTe=["children"];function CTe(t,e){if(t==null)return{};var n,r,i=kTe(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 kTe(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 Qw(){return Qw=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},Qw.apply(null,arguments)}var jTe={width:"100%",height:"100%",display:"block"},PTe=S.forwardRef((t,e)=>{var n=ZR(),r=QR(),i=Jq();if(!El(n)||!El(r))return null;var{children:a,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),S.createElement(kR,Qw({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:jTe,ref:e}),a)}),RTe=t=>{var{children:e}=t,n=Rt(RM);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return S.createElement(kR,{width:r,height:i,x:o,y:a},e)},aH=S.forwardRef((t,e)=>{var{children:n}=t,r=CTe(t,TTe),i=ji();return i?S.createElement(RTe,null,S.createElement(iH,{isPanorama:!0},n)):S.createElement(PTe,Qw({ref:e},r),S.createElement(iH,{isPanorama:!1},n))});function DTe(){var t=xr(),[e,n]=S.useState(null),r=Rt(Ype);return S.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;er(a)&&a!==r&&t(Ppe(a))}},[e,t,r]),n}function sH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function OTe(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){LTe(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 LTe(t,e,n){return(e=ITe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ITe(t){var e=FTe(t,"string");return typeof e=="symbol"?e:e+""}function FTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yf(){return yf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},yf.apply(null,arguments)}var UTe=()=>(pwe(),null);function Jw(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var zTe=S.forwardRef((t,e)=>{var n,r,i=S.useRef(null),[a,o]=S.useState({containerWidth:Jw((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:Jw((r=t.style)===null||r===void 0?void 0:r.height)}),l=S.useCallback((u,d)=>{o(f=>{var g=Math.round(u),p=Math.round(d);return f.containerWidth===g&&f.containerHeight===p?f:{containerWidth:g,containerHeight:p}})},[]),c=S.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var g=x=>{var{width:y,height:b}=x[0].contentRect;l(y,b)},p=new ResizeObserver(g);p.observe(u),i.current=p}},[e,l]);return S.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),S.createElement(S.Fragment,null,S.createElement(DM,{width:a.containerWidth,height:a.containerHeight}),S.createElement("div",yf({ref:c},t)))}),BTe=S.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=S.useState({containerWidth:Jw(n),containerHeight:Jw(r)}),o=S.useCallback((c,u)=>{a(d=>{var f=Math.round(c),g=Math.round(u);return d.containerWidth===f&&d.containerHeight===g?d:{containerWidth:f,containerHeight:g}})},[]),l=S.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return S.createElement(S.Fragment,null,S.createElement(DM,{width:i.containerWidth,height:i.containerHeight}),S.createElement("div",yf({ref:l},t)))}),HTe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return S.createElement(S.Fragment,null,S.createElement(DM,{width:n,height:r}),S.createElement("div",yf({ref:e},t)))}),$Te=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return qc(n)||qc(r)?S.createElement(BTe,yf({},t,{ref:e})):S.createElement(HTe,yf({},t,{ref:e}))});function VTe(t){return t===!0?zTe:$Te}var GTe=S.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:g,onTouchEnd:p,onTouchMove:x,onTouchStart:y,style:b,width:v,responsive:E,dispatchTouchEvents:w=!0}=t,A=S.useRef(null),N=xr(),[C,T]=S.useState(null),[O,k]=S.useState(null),R=DTe(),z=YR(),D=z?.width>0?z.width:v,K=z?.height>0?z.height:i,P=S.useCallback(fe=>{R(fe),typeof e=="function"&&e(fe),T(fe),k(fe),fe!=null&&(A.current=fe)},[R,e,T,k]),W=S.useCallback(fe=>{N(fZ(fe)),N(Qs({handler:a,reactEvent:fe}))},[N,a]),Z=S.useCallback(fe=>{N(mj(fe)),N(Qs({handler:u,reactEvent:fe}))},[N,u]),G=S.useCallback(fe=>{N(VX()),N(Qs({handler:d,reactEvent:fe}))},[N,d]),Y=S.useCallback(fe=>{N(mj(fe)),N(Qs({handler:f,reactEvent:fe}))},[N,f]),X=S.useCallback(()=>{N(yZ())},[N]),q=S.useCallback(fe=>{N(bZ(fe.key))},[N]),F=S.useCallback(fe=>{N(Qs({handler:o,reactEvent:fe}))},[N,o]),V=S.useCallback(fe=>{N(Qs({handler:l,reactEvent:fe}))},[N,l]),te=S.useCallback(fe=>{N(Qs({handler:c,reactEvent:fe}))},[N,c]),re=S.useCallback(fe=>{N(Qs({handler:g,reactEvent:fe}))},[N,g]),ae=S.useCallback(fe=>{N(Qs({handler:y,reactEvent:fe}))},[N,y]),he=S.useCallback(fe=>{w&&N(_Z(fe)),N(Qs({handler:x,reactEvent:fe}))},[N,w,x]),ue=S.useCallback(fe=>{N(Qs({handler:p,reactEvent:fe}))},[N,p]),ce=VTe(E);return S.createElement(uY.Provider,{value:C},S.createElement(bW.Provider,{value:O},S.createElement(ce,{width:D??b?.width,height:K??b?.height,className:In("recharts-wrapper",r),style:OTe({position:"relative",cursor:"default",width:D,height:K},b),onClick:W,onContextMenu:F,onDoubleClick:V,onFocus:X,onKeyDown:q,onMouseDown:te,onMouseEnter:Z,onMouseLeave:G,onMouseMove:Y,onMouseUp:re,onTouchEnd:ue,onTouchMove:he,onTouchStart:ae,ref:P},S.createElement(UTe,null),n)))}),WTe=["width","height","responsive","children","className","style","compact","title","desc"];function qTe(t,e){if(t==null)return{};var n,r,i=KTe(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 KTe(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 NZ=S.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=qTe(t,WTe),g=za(f);return c?S.createElement(S.Fragment,null,S.createElement(DM,{width:n,height:r}),S.createElement(aH,{otherAttributes:g,title:u,desc:d},a)):S.createElement(GTe,{className:o,style:l,width:n,height:r,responsive:i??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},S.createElement(aH,{otherAttributes:g,title:u,desc:d,ref:e},S.createElement(oNe,null,a)))});function pj(){return pj=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},pj.apply(null,arguments)}var XTe={top:5,right:5,bottom:5,left:5},YTe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:XTe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},kO=S.forwardRef(function(e,n){var r,i=Ir(e.categoricalChartProps,YTe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return S.createElement(SZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},S.createElement($Y,{chartData:u.data}),S.createElement(MZ,{layout:i.layout,margin:i.margin}),S.createElement(EZ,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),S.createElement(NZ,pj({},i,{ref:n})))}),ZTe=["axis"],QTe=S.forwardRef((t,e)=>S.createElement(kO,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:ZTe,tooltipPayloadSearcher:e2,categoricalChartProps:t,ref:e})),JTe=["axis","item"],eCe=S.forwardRef((t,e)=>S.createElement(kO,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:JTe,tooltipPayloadSearcher:e2,categoricalChartProps:t,ref:e}));function tCe(t){var e=xr();return S.useEffect(()=>{e(_Te(t))},[e,t]),null}var nCe=["layout"];function gj(){return gj=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},gj.apply(null,arguments)}function rCe(t,e){if(t==null)return{};var n,r,i=iCe(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 iCe(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 aCe={top:5,right:5,bottom:5,left:5},AZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:aCe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},sCe=S.forwardRef(function(e,n){var r,i=Ir(e.categoricalChartProps,AZ),{layout:a}=i,o=rCe(i,nCe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return S.createElement(SZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},S.createElement($Y,{chartData:i.data}),S.createElement(MZ,{layout:a,margin:i.margin}),S.createElement(EZ,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),S.createElement(tCe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),S.createElement(NZ,gj({},o,{ref:n})))});function oH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oH(Object(n),!0).forEach(function(r){oCe(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 oCe(t,e,n){return(e=lCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lCe(t){var e=cCe(t,"string");return typeof e=="symbol"?e:e+""}function cCe(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 uCe=["item"],dCe=lH(lH({},AZ),{},{layout:"centric",startAngle:0,endAngle:360}),hCe=S.forwardRef((t,e)=>{var n=Ir(t,dCe);return S.createElement(sCe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:uCe,tooltipPayloadSearcher:e2,categoricalChartProps:n,ref:e})}),fCe=["axis"],mCe=S.forwardRef((t,e)=>S.createElement(kO,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:fCe,tooltipPayloadSearcher:e2,categoricalChartProps:t,ref:e}));const cH=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function pCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=cg(),{mode:u}=mg(),[d,f]=S.useState("24h"),[g,p]=S.useState(o),x=u==="dark",{data:y}=ht({queryKey:["settings"],queryFn:be.getSettings}),b=y?.time_format||"system";S.useEffect(()=>{if(!t)return;const re=ae=>{ae.key==="Escape"&&e()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[t,e]);const v=cH.find(re=>re.value===d)?.hours||24,{data:E,isLoading:w,error:A}=ht({queryKey:["ams-history",n,i,v],queryFn:()=>be.getAMSHistory(n,i,v),enabled:t,refetchInterval:6e4});if(!t)return null;const N=E?.data.map(re=>{const ae=di(re.recorded_at)||new Date,he={hour:"2-digit",minute:"2-digit",...v>24?{day:"numeric",month:"short"}:{}};return{time:ae.getTime(),humidity:re.humidity,temperature:re.temperature,timeLabel:ae.toLocaleTimeString([],m0(he,b))}})||[],C=l?.humidityGood||40,T=l?.humidityFair||60,O=l?.tempGood||30,k=l?.tempFair||35,R=N[N.length-1],z=R?.humidity,D=R?.temperature,K=re=>{const ae=re.filter(_e=>_e!=null);if(ae.length<4)return"stable";const he=ae.slice(0,Math.floor(ae.length/4)),ue=ae.slice(-Math.floor(ae.length/4)),ce=he.reduce((_e,ne)=>_e+ne,0)/he.length,pe=ue.reduce((_e,ne)=>_e+ne,0)/ue.length-ce;return Math.abs(pe)<2?"stable":pe>0?"up":"down"},P=K(N.map(re=>re.humidity)),W=K(N.map(re=>re.temperature)),Z=({trend:re})=>re==="up"?s.jsx(sW,{className:"w-4 h-4 text-red-400"}):re==="down"?s.jsx(aW,{className:"w-4 h-4 text-green-400"}):s.jsx(d3,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),G=re=>re==null?"#9ca3af":re<=C?"#22a352":re<=T?"#d4a017":"#c62828",Y=re=>re==null?"#9ca3af":re<=O?"#22a352":re<=k?"#d4a017":"#c62828",X=x?"#2d2d2d":"#ffffff",q=x?"#1d1d1d":"#f3f4f6",F=x?"#3d3d3d":"#e5e7eb",V=x?"#ffffff":"#111827",te=x?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:X},onClick:re=>re.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:F},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:V},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:te},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:te},children:s.jsx(zt,{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:q},children:[s.jsxs("button",{onClick:()=>p("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="humidity"?"bg-blue-600 text-white":""}`,style:g!=="humidity"?{color:te}:void 0,children:[s.jsx(bR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>p("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${g==="temperature"?"bg-orange-600 text-white":""}`,style:g!=="temperature"?{color:te}:void 0,children:[s.jsx(gM,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:q},children:cH.map(re=>s.jsx("button",{onClick:()=>f(re.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===re.value?"bg-bambu-green text-white":""}`,style:d!==re.value?{color:te}:void 0,children:re.label},re.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:g==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},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(z)},children:z!=null?`${z}%`:"—"}),s.jsx(Z,{trend:P})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:V},children:E?.avg_humidity!=null?`${E.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:E?.min_humidity!=null?`${E.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:E?.max_humidity!=null?`${E.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},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:Y(D)},children:D!=null?`${D}°C`:"—"}),s.jsx(Z,{trend:W})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:V},children:E?.avg_temperature!=null?`${E.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:E?.min_temperature!=null?`${E.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:[s.jsx("p",{className:"text-xs",style:{color:te},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:E?.max_temperature!=null?`${E.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:q},children:w?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:te},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")}):N.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:te},children:c("common.noData","No data available for this time range")}):s.jsx(E1,{width:"100%",height:300,children:s.jsxs(QTe,{data:N,children:[s.jsx(Kw,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx(Yw,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:re=>{const ae=new Date(re);return v>24?ae.toLocaleDateString([],{day:"numeric",month:"short"}):ae.toLocaleTimeString([],m0({hour:"2-digit",minute:"2-digit"},b))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(Zw,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:g==="humidity"?[0,100]:["auto","auto"],tickFormatter:re=>g==="humidity"?`${re}%`:`${re}°C`}),s.jsx(A1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:re=>new Date(re).toLocaleString(void 0,m0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},b)),formatter:re=>[g==="humidity"?`${re}%`:`${re}°C`,g==="humidity"?"Humidity":"Temperature"]}),s.jsx(tD,{}),g==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(t0,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(t0,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(t0,{y:O,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(t0,{y:k,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(rZ,{type:"monotone",dataKey:g,name:g==="humidity"?"Humidity":"Temperature",stroke:g==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:te},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function zT({data:t,children:e,disabled:n,className:r="",spoolman:i}){const[a,o]=S.useState(!1),[l,c]=S.useState("top"),[u,d]=S.useState(!1),f=S.useRef(null),g=S.useRef(null),p=S.useRef(null),x=()=>{const N=t.trayUuid;N&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(N).then(()=>{d(!0),setTimeout(()=>d(!1),2e3)}).catch(()=>{y(N)}):y(N))},y=N=>{const C=document.createElement("textarea");C.value=N,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),d(!0),setTimeout(()=>d(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(C)};S.useEffect(()=>{if(a&&f.current&&g.current){const N=f.current.getBoundingClientRect(),C=g.current.offsetHeight,T=N.top,O=window.innerHeight-N.bottom;T<C+12&&O>T?c("bottom"):c("top")}},[a]);const b=()=>{n||(p.current&&clearTimeout(p.current),p.current=setTimeout(()=>o(!0),80))},v=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>o(!1),100)};S.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const E=N=>N<=15?"#ef4444":N<=30?"#f97316":N<=50?"#eab308":"#22c55e",w=N=>{if(!N)return!1;const C=N.replace("#",""),T=parseInt(C.slice(0,2),16),O=parseInt(C.slice(2,4),16),k=parseInt(C.slice(4,6),16);return(.299*T+.587*O+.114*k)/255>.6},A=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:f,className:`relative ${r}`,onMouseEnter:b,onMouseLeave:v,children:[e,a&&s.jsxs("div",{ref:g,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${l==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:A||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${w(A)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),s.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),s.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),s.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[s.jsx(bR,{className:"w-3 h-3"}),"Fill"]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:E(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),s.jsxs("button",{onClick:N=>{N.stopPropagation(),x()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),u?s.jsx(ds,{className:"w-3 h-3 text-bambu-green"}):s.jsx(Wo,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:N=>{N.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(Rp,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]})]})]}),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
- ${l==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function uH({children:t,className:e=""}){const[n,r]=S.useState(!1),i=S.useRef(null),a=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!0),80)},o=()=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>r(!1),100)};return S.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:a,onMouseLeave:o,children:[t,n&&s.jsxs("div",{className:`
- 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.jsx("div",{className:`
- px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg text-xs text-bambu-gray whitespace-nowrap
- `,children:"Empty slot"}),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 gCe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=ln(),[a,o]=S.useState(null),{data:l,isLoading:c}=ht({queryKey:["unlinked-spools"],queryFn:be.getUnlinkedSpools,enabled:t}),u=xt({mutationFn:f=>be.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(Rp,{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(zt,{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(gt,{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(ds,{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(Te,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Te,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rp,{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 xCe({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return s.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsxs("g",{stroke:r,opacity:i,children:[s.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),s.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),s.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),s.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),s.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),s.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),s.jsx("path",{d:"M12 24h8",stroke:r}),s.jsx("path",{d:"M12 27h8",stroke:r}),s.jsx("path",{d:"M13 30h6",stroke:r})]})}const dH=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),hH={"A00-W1":"Jade White","A00-P0":"Beige","A00-D2":"Light Gray","A00-Y0":"Yellow","A00-Y2":"Sunflower Yellow","A00-A1":"Pumpkin Orange","A00-A0":"Orange","A00-Y4":"Gold","A00-G3":"Bright Green","A00-G1":"Bambu Green","A00-G2":"Mistletoe Green","A00-R3":"Hot Pink","A00-P6":"Magenta","A00-R0":"Red","A00-R2":"Maroon Red","A00-P5":"Purple","A00-P2":"Indigo Purple","A00-B5":"Turquoise","A00-B8":"Cyan","A00-B3":"Cobalt Blue","A00-N0":"Brown","A00-N1":"Cocoa Brown","A00-Y3":"Bronze","A00-D0":"Gray","A00-D1":"Silver","A00-B1":"Blue Grey","A00-D3":"Dark Gray","A00-K0":"Black","A00-M3":"Pink Citrus","A00-M6":"Dusk Glare","A00-M0":"Arctic Whisper","A00-M1":"Solar Breeze","A00-M5":"Blueberry Bubblegum","A00-M4":"Mint Lime","A00-M2":"Ocean to Meadow","A00-M7":"Cotton Candy Cloud","A18-K0":"Black","A18-D0":"Gray","A18-W0":"White","A18-R0":"Red","A18-Y0":"Yellow","A18-B0":"Cyan","A18-B1":"Blue","A18-P0":"Matte Beige","A01-W2":"Ivory White","A01-W3":"Bone White","A01-Y2":"Lemon Yellow","A01-A2":"Mandarin Orange","A01-P3":"Sakura Pink","A01-P4":"Lilac Purple","A01-R3":"Plum","A01-R1":"Scarlet Red","A01-R4":"Dark Red","A01-G0":"Apple Green","A01-G1":"Grass Green","A01-G7":"Dark Green","A01-B4":"Ice Blue","A01-B0":"Sky Blue","A01-B3":"Marine Blue","A01-B6":"Dark Blue","A01-Y3":"Desert Tan","A01-N1":"Latte Brown","A01-N3":"Caramel","A01-R2":"Terracotta","A01-N2":"Dark Brown","A01-N0":"Dark Chocolate","A01-D3":"Ash Gray","A01-D0":"Nardo Gray","A01-K1":"Charcoal","A12-G0":"Green","A12-R0":"Pink","A12-A0":"Orange","A12-Y0":"Yellow","A12-B0":"Blue","A07-R5":"Red Granite","A07-D4":"White Marble","A11-W0":"White","A11-K0":"Black","A08-G3":"Alpine Green Sparkle","A08-D5":"Slate Gray Sparkle","A08-B7":"Royal Purple Sparkle","A08-R2":"Crimson Red Sparkle","A08-K2":"Onyx Black Sparkle","A08-Y1":"Classic Gold Sparkle","A02-B2":"Cobalt Blue Metallic","A02-G2":"Oxide Green Metallic","A02-Y1":"Iridium Gold Metallic","A02-D2":"Iron Gray Metallic","A17-B1":"Blue","A17-A0":"Orange","A17-P0":"Purple","A06-Y1":"Gold","A06-D0":"Titan Gray","A06-D1":"Silver","A06-W0":"White","A06-R0":"Candy Red","A06-G0":"Candy Green","A06-G1":"Mint","A06-B1":"Blue","A06-B0":"Baby Blue","A06-P0":"Purple","A06-R1":"Rose Gold","A06-R2":"Pink","A06-Y0":"Champagne","A05-M8":"Dawn Radiance","A05-M4":"Aurora Purple","A05-M1":"South Beach","A05-T3":"Neon City","A05-T2":"Midnight Blaze","A05-T1":"Gilded Rose","A05-T4":"Blue Hawaii","A05-T5":"Velvet Eclipse","A15-B0":"Purple","A15-G0":"Green","A15-G1":"Nebulae","A15-R0":"Brown","A16-K0":"Black Walnut","A16-R0":"Rosewood","A16-N0":"Clay Brown","A16-G0":"Classic Birch","A16-W0":"White Oak","A16-Y0":"Ochre Yellow","A50-D6":"Lava Gray","A50-K0":"Black","A50-B6":"Royal Blue","A10-W0":"White","A10-D0":"Gray","A09-B5":"Lavender Blue","A09-B4":"Light Blue","A09-A0":"Orange","A09-D1":"Silver","A09-R3":"Vermilion Red","A09-Y0":"Yellow","G02-K0":"Black","G02-W0":"White","G02-R0":"Red","G02-D0":"Gray","G02-D1":"Dark Gray","G02-Y1":"Cream","G02-Y0":"Yellow","G02-A0":"Orange","G02-N1":"Peanut Brown","G02-G1":"Lime Green","G02-G0":"Green","G02-G2":"Forest Green","G02-B1":"Lake Blue","G02-B0":"Blue","G01-G1":"Translucent Teal","G01-B0":"Translucent Light Blue","G01-C0":"Clear","G01-D0":"Translucent Gray","G01-G0":"Translucent Olive","G01-N0":"Translucent Brown","G01-A0":"Translucent Orange","G01-P1":"Translucent Pink","G01-P0":"Translucent Purple","G50-P7":"Violet Purple","G50-K0":"Black","B00-D1":"Silver","B00-K0":"Black","B00-W0":"White","B00-G6":"Bambu Green","B00-G7":"Olive","B00-Y1":"Tangerine Yellow","B00-A0":"Orange","B00-R0":"Red","B00-B4":"Azure","B00-B0":"Blue","B00-B6":"Navy Blue","B50-A0":"Orange","B50-K0":"Black","B01-W0":"White","B01-K0":"Black","B01-D0":"Gray","B02-W0":"White","C00-C1":"Transparent","C00-C0":"Clear Black","C00-K0":"Black","C00-W0":"White","C01-K0":"Black","U02-B0":"Blue","U02-D0":"Gray","U02-K0":"Black","N04-K0":"Black","N08-K0":"Black","S02-W0":"Nature","S02-W1":"White","S05-C0":"Black","S06-W0":"White","S03-G1":"Green","S04-Y0":"Clear"},bCe={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 BT(t){if(!t)return null;if(hH[t])return hH[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return bCe[n]||null}function HT(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,g=r/255;i===d?l=((f-g)/u+(f<g?6:0))/6:i===f?l=((g-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function $T(t){return(t??.02).toFixed(3)}function fH({side:t}){const{mode:e}=mg(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function mH({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function yCe({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 vCe({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 _Ce({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 wCe({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 SCe({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 VT({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:i,strokeWidth:"1",fill:"none"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function pH({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=mH:a<=l?d=yCe:d=vCe,s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[s.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function gH({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=_Ce):t<=o?(l="#d4a017",c="Fair",u=wCe):(l="#c62828",c="Bad",u=SCe),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 ku(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function xH(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function MCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function ECe(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 NCe(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 ACe(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 TCe({url:t,printName:e}){const[n,r]=S.useState(!1),[i,a]=S.useState(!1),[o,l]=S.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&l(!0),children:t&&!i?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&s.jsx(vl,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(vl,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function CCe({printers:t}){const e=ln(),n=S.useMemo(()=>{let i=0,a=0,o=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:a++:o++}),{printing:i,idle:a,offline:o,loading:l,total:t?.length||0}},[t,e]),[,r]=S.useState(0);return S.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(o=>o+1),i=!1}))});return()=>a()},[e]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function bH(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function yH({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system"}){const u=ln(),d=Rb(),{showToast:f}=dr(),[g,p]=S.useState(!1),[x,y]=S.useState(!1),[b,v]=S.useState(!0),[E,w]=S.useState(!1),[A,N]=S.useState(!1),[C,T]=S.useState(!1),[O,k]=S.useState(!1),[R,z]=S.useState(!1),[D,K]=S.useState(!1),[P,W]=S.useState(!1),[Z,G]=S.useState(!1),[Y,X]=S.useState(!1),[q,F]=S.useState(!1),[V,te]=S.useState(null),[re,ae]=S.useState(null),[he,ue]=S.useState(!1),{data:ce}=ht({queryKey:["printerStatus",t.id],queryFn:()=>be.getPrinterStatus(t.id),refetchInterval:3e4}),{data:fe}=ht({queryKey:["firmwareUpdate",t.id],queryFn:()=>v1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),pe=S.useMemo(()=>{const ft=new Set;if(ce?.ams)for(const Ht of ce.ams)for(const Qt of Ht.tray||[])Qt.tray_info_idx&&ft.add(Qt.tray_info_idx);return ce?.vt_tray?.tray_info_idx&&ft.add(ce.vt_tray.tray_info_idx),Array.from(ft)},[ce?.ams,ce?.vt_tray]),{data:_e}=ht({queryKey:["filamentInfo",pe],queryFn:()=>be.getFilamentInfo(pe),enabled:pe.length>0,staleTime:300*1e3}),[ne,He]=S.useState(null);S.useEffect(()=>{ce?.wifi_signal!=null&&He(ce.wifi_signal)},[ce?.wifi_signal]);const B=ce?.wifi_signal??ne,H=S.useRef(void 0);S.useEffect(()=>{ce?.connected!==void 0&&(H.current=ce.connected)},[ce?.connected]);const le=ce?.connected??H.current,$=S.useRef({});S.useEffect(()=>{ce?.ams_extruder_map&&Object.keys(ce.ams_extruder_map).length>0&&($.current=ce.ams_extruder_map)},[ce?.ams_extruder_map]);const ee=ce?.ams_extruder_map&&Object.keys(ce.ams_extruder_map).length>0?ce.ams_extruder_map:$.current,de=S.useRef([]);S.useEffect(()=>{ce?.ams&&ce.ams.length>0&&(de.current=ce.ams)},[ce?.ams]);const ke=ce?.ams&&ce.ams.length>0?ce.ams:de.current,we=S.useRef(255),Ee=ce?.tray_now;Ee!==void 0&&Ee!==255&&(we.current=Ee);const U=Ee===void 0||Ee===255?we.current:Ee,{data:I}=ht({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>be.getSmartPlugByPrinter(t.id)}),{data:se}=ht({queryKey:["smartPlugStatus",I?.id],queryFn:()=>I?be.getSmartPlugStatus(I.id):null,enabled:!!I,refetchInterval:1e4}),{data:ye}=ht({queryKey:["queue",t.id,"pending"],queryFn:()=>be.getQueue(t.id,"pending")}),Se=ye?.length||0,{data:ve}=ht({queryKey:["archives",t.id,"last"],queryFn:()=>be.getArchives(t.id,1,0),enabled:ce?.connected&&ce?.state!=="RUNNING"}),Be=ve?.[0],Ge=e&&le===!1,Ke=xt({mutationFn:ft=>be.deletePrinter(t.id,ft.deleteArchives),onSuccess:()=>{u.invalidateQueries({queryKey:["printers"]}),u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["maintenanceOverview"]})}}),ct=xt({mutationFn:()=>be.connectPrinter(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["printerStatus",t.id]})}}),$e=xt({mutationFn:ft=>I?be.controlSmartPlug(I.id,ft):Promise.reject("No plug"),onSuccess:()=>{u.invalidateQueries({queryKey:["smartPlugStatus",I?.id]})}}),ge=xt({mutationFn:ft=>I?be.updateSmartPlug(I.id,{auto_off:ft}):Promise.reject("No plug"),onSuccess:()=>{u.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),u.invalidateQueries({queryKey:["smart-plugs"]})}}),Je=xt({mutationFn:()=>be.stopPrint(t.id),onSuccess:()=>{f("Print stopped"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:ft=>f(ft.message||"Failed to stop print","error")}),qe=xt({mutationFn:()=>be.pausePrint(t.id),onSuccess:()=>{f("Print paused"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:ft=>f(ft.message||"Failed to pause print","error")}),Ze=xt({mutationFn:()=>be.resumePrint(t.id),onSuccess:()=>{f("Print resumed"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:ft=>f(ft.message||"Failed to resume print","error")}),lt=xt({mutationFn:ft=>be.setChamberLight(t.id,ft),onMutate:async ft=>{await u.cancelQueries({queryKey:["printerStatus",t.id]});const Ht=u.getQueryData(["printerStatus",t.id]);return u.setQueryData(["printerStatus",t.id],Qt=>({...Qt,chamber_light:ft})),{previousStatus:Ht}},onSuccess:(ft,Ht)=>{f(`Chamber light ${Ht?"on":"off"}`)},onError:(ft,Ht,Qt)=>{Qt?.previousStatus&&u.setQueryData(["printerStatus",t.id],Qt.previousStatus),f(ft.message||"Failed to control chamber light","error")}}),ie=(ce?.state==="RUNNING"||ce?.state==="PAUSE"||ce?.state==="PAUSED")&&(ce?.printable_objects_count??0)>=2,{data:Ie,refetch:xe}=ht({queryKey:["printableObjects",t.id],queryFn:()=>be.getPrintableObjects(t.id),enabled:q||ie,refetchInterval:q?5e3:ie?3e4:!1}),Ue=xt({mutationFn:ft=>be.skipObjects(t.id,ft),onSuccess:ft=>{f(ft.message||"Objects skipped"),xe()},onError:ft=>f(ft.message||"Failed to skip objects","error")}),[Pe,Me]=S.useState(null),Xe=S.useRef(!1),ut=S.useRef(null),At=S.useRef(!1),St=xt({mutationFn:({amsId:ft,slotId:Ht})=>be.refreshAmsSlot(t.id,ft,Ht),onMutate:({amsId:ft,slotId:Ht})=>{ut.current&&clearTimeout(ut.current),Xe.current=!1,At.current=!1,Me({amsId:ft,slotId:Ht}),setTimeout(()=>{At.current=!0},2e3),ut.current=setTimeout(()=>{Me(null)},3e4)},onSuccess:ft=>{f(ft.message||"RFID re-read initiated")},onError:ft=>{f(ft.message||"Failed to re-read RFID","error"),ut.current&&clearTimeout(ut.current),Me(null)}}),Yt=S.useRef(null);S.useEffect(()=>{if(!Pe)return;const ft=ce?.ams_status_main??0;return ft!==0&&(Xe.current=!0,Yt.current&&(clearTimeout(Yt.current),Yt.current=null)),Xe.current&&ft===0&&(At.current?(ut.current&&clearTimeout(ut.current),Me(null)):Yt.current||(Yt.current=setTimeout(()=>{ut.current&&clearTimeout(ut.current),Me(null)},2e3))),()=>{Yt.current&&clearTimeout(Yt.current)}},[ce?.ams_status_main,Pe]);const[Pt,Jt]=S.useState(null);if(Ge)return null;const Fn=()=>{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"}},Sn=()=>{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"}},vr=()=>{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(vt,{className:"relative",children:[s.jsxs(Mt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:vr(),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:NCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Fn()}`}),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 ${Sn()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ce?.connected?"bg-bambu-green":"bg-red-500"}`,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(ur,{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(Te,{variant:"ghost",size:"sm",onClick:()=>p(!g),children:s.jsx(gp,{className:"w-4 h-4"})}),g&&s.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{w(!0),p(!1)},children:[s.jsx(qo,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{ct.mutate(),p(!1)},children:[s.jsx(Dr,{className:"w-4 h-4"}),"Reconnect"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{T(!0),p(!1)},children:[s.jsx(iW,{className:"w-4 h-4"}),"MQTT Debug"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{y(!0),p(!1)},children:[s.jsx(vn,{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-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[ce?.connected?s.jsx(Lb,{className:"w-3 h-3"}):s.jsx(oW,{className:"w-3 h-3"}),ce?.connected?"Connected":"Offline"]}),ce?.connected&&B!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${B>=-50||B>=-60?"bg-bambu-green/20 text-bambu-green":B>=-70?"bg-amber-500/20 text-amber-600":B>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${B} dBm - ${ACe(B).label}`,children:[s.jsx(ode,{className:"w-3 h-3"}),B,"dBm"]}),ce?.connected&&(()=>{const ft=ce.hms_errors?yhe(ce.hms_errors):[];return s.jsxs("button",{onClick:()=>K(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${ft.length>0?ft.some(Ht=>Ht.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[s.jsx(Cn,{className:"w-3 h-3"}),ft.length>0?ft.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>d("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[s.jsx(Ad,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Se>0&&s.jsxs("button",{onClick:()=>d("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${Se} print${Se>1?"s":""} in queue`,children:[s.jsx(Md,{className:"w-3 h-3"}),Se]}),fe?.update_available&&s.jsxs("button",{onClick:()=>ue(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:`Firmware update available: ${fe.current_version} → ${fe.latest_version}`,children:[s.jsx(Mi,{className:"w-3 h-3"}),"Update"]})]})]}),x&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(vt,{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(Cn,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:b,onChange:ft=>v(ft.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:b?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{y(!1),v(!0)},children:"Cancel"}),s.jsx(Te,{variant:"danger",onClick:()=>{Ke.mutate({deleteArchives:b}),y(!1),v(!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:bH(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:()=>F(!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(dH,{className:"w-4 h-4"}),Ie&&Ie.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:Ie.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(TCe,{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(ur,{className:"w-3 h-3"}),MCe(ce.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",ECe(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(Md,{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:bH(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:"—"})]}),Be?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Be.print_name||Be.filename,children:["Last: ",Be.print_name||Be.filename,Be.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Op(Be.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(She,{printerId:t.id})]}),ce.temperatures&&r==="expanded"&&(()=>{const ft=ce.temperatures.nozzle_heating||ce.temperatures.nozzle_2_heating||!1,Ht=ce.temperatures.bed_heating||!1,Qt=ce.temperatures.chamber_heating||!1;return s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[s.jsx(VT,{className:"w-4 h-4 mx-auto mb-1",color:"text-orange-400",isHeating:ft}),ce.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(ce.temperatures.nozzle||0),"° / ",Math.round(ce.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Nozzle"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(ce.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[s.jsx(VT,{className:"w-4 h-4 mx-auto mb-1",color:"text-blue-400",isHeating:Ht}),s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(ce.temperatures.bed||0),"°C"]})]}),ce.temperatures.chamber!==void 0?s.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[s.jsx(VT,{className:"w-4 h-4 mx-auto mb-1",color:"text-green-400",isHeating:Qt}),s.jsx("p",{className:"text-[10px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-xs text-white",children:[Math.round(ce.temperatures.chamber||0),"°C"]})]}):s.jsx("div",{})]})})(),r==="expanded"&&(()=>{const ft=ce.state==="RUNNING",Ht=ce.state==="PAUSED"||ce.state==="PAUSE",Qt=ft||Ht,mt=Je.isPending||qe.isPending||Ze.isPending,$t=ce.cooling_fan_speed,cn=ce.big_fan1_speed,Mn=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 ${$t&&$t>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(XG,{className:`w-3.5 h-3.5 ${$t&&$t>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${$t&&$t>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[$t??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${cn&&cn>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(cW,{className:`w-3.5 h-3.5 ${cn&&cn>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${cn&&cn>0?"text-blue-400":"text-bambu-gray/50"}`,children:[cn??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Mn&&Mn>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(qoe,{className:`w-3.5 h-3.5 ${Mn&&Mn>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Mn&&Mn>0?"text-green-400":"text-bambu-gray/50"}`,children:[Mn??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>W(!0),disabled:!Qt||mt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Qt?"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(Nd,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>Ht?X(!0):G(!0),disabled:!Qt||mt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${Qt?Ht?"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:Ht?"Resume print":"Pause print",children:[Ht?s.jsx(Wc,{className:"w-3 h-3"}):s.jsx(NR,{className:"w-3 h-3"}),Ht?"Resume":"Pause"]})]})]})]})})(),ke&&ke.length>0&&r==="expanded"&&(()=>{const ft=ke.filter(mt=>mt.tray.length>1),Ht=ke.filter(mt=>mt.tray.length===1),Qt=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:[ft.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:ft.map(mt=>{const $t=ee[String(mt.id)],cn=mt.id>=128?mt.id-128:mt.id,Mn=$t!==void 0?$t:cn,qt=Mn===1,J=Mn===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:ku(mt.id,mt.tray.length)}),Qt&&(qt||J)&&s.jsx(fH,{side:qt?"L":"R"})]}),(mt.humidity!=null||mt.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[mt.humidity!=null&&s.jsx(pH,{humidity:mt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>te({amsId:mt.id,amsLabel:ku(mt.id,mt.tray.length),mode:"humidity"}),compact:!0}),mt.temp!=null&&s.jsx(gH,{temp:mt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>te({amsId:mt.id,amsLabel:ku(mt.id,mt.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(Ne=>{const ze=mt.tray[Ne]||mt.tray.find(at=>at.id===Ne),Ye=ze?.tray_type&&ze.remain>=0,nt=!ze?.tray_type,Et=mt.id*4+Ne,oe=U===Et,Ae=ze?.tray_info_idx?_e?.[ze.tray_info_idx]:null,Re=ze?.tray_type?{vendor:ze.tray_uuid?"Bambu Lab":"Generic",profile:Ae?.name||ze.tray_sub_brands||ze.tray_type,colorName:BT(ze.tray_id_name)||HT(ze.tray_color),colorHex:ze.tray_color||null,kFactor:$T(ze.k),fillLevel:Ye?ze.remain:null,trayUuid:ze.tray_uuid||null}:null,De=Pe?.amsId===mt.id&&Pe?.slotId===Ne,je=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${nt?"opacity-50":""} ${oe?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:ze?.tray_color?`#${ze.tray_color}`:ze?.tray_type?"#333":"transparent",borderColor:nt?"#666":"rgba(255,255,255,0.1)",borderStyle:nt?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ze?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Ye&&ze?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ze.remain}%`,backgroundColor:xH(ze.remain)}}):ze?.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:[De&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ce?.state!=="RUNNING"&&s.jsx("button",{onClick:at=>{at.stopPropagation(),Jt(Pt?.amsId===mt.id&&Pt?.slotId===Ne?null:{amsId:mt.id,slotId:Ne})},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(gp,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ce?.state!=="RUNNING"&&Pt?.amsId===mt.id&&Pt?.slotId===Ne&&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:at=>{at.stopPropagation(),St.mutate({amsId:mt.id,slotId:Ne}),Jt(null)},disabled:De,children:[s.jsx(Dr,{className:`w-3 h-3 ${De?"animate-spin":""}`}),"Re-read RFID"]})}),Re?s.jsx(zT,{data:Re,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Re.trayUuid?at=>{ae({trayUuid:at,trayInfo:{type:Re.profile,color:Re.colorHex||"",location:`${ku(mt.id,mt.tray.length)} Slot ${Ne+1}`}})}:void 0},children:je}):s.jsx(uH,{children:je})]},Ne)})})]},mt.id)})}),(Ht.length>0||ce.vt_tray&&ce.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Ht.map(mt=>{const $t=ee[String(mt.id)],cn=mt.id>=128?mt.id-128:mt.id,Mn=$t!==void 0?$t:cn,qt=Mn===1,J=Mn===0,Ne=mt.tray[0],ze=Ne?.tray_type&&Ne.remain>=0,Ye=!Ne?.tray_type,nt=mt.id*4+(Ne?.id??0),Et=U===nt,oe=Ne?.tray_info_idx?_e?.[Ne.tray_info_idx]:null,Ae=Ne?.tray_type?{vendor:Ne.tray_uuid?"Bambu Lab":"Generic",profile:oe?.name||Ne.tray_sub_brands||Ne.tray_type,colorName:BT(Ne.tray_id_name)||HT(Ne.tray_color),colorHex:Ne.tray_color||null,kFactor:$T(Ne.k),fillLevel:ze?Ne.remain:null,trayUuid:Ne.tray_uuid||null}:null,Re=Ne?.id??0,De=Pe?.amsId===mt.id&&Pe?.slotId===Re,je=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ye?"opacity-50":""} ${Et?"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:Ne?.tray_color?`#${Ne.tray_color}`:Ne?.tray_type?"#333":"transparent",borderColor:Ye?"#666":"rgba(255,255,255,0.1)",borderStyle:Ye?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:Ne?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:ze?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Ne.remain}%`,backgroundColor:xH(Ne.remain)}}):Ne?.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:ku(mt.id,mt.tray.length)}),Qt&&(qt||J)&&s.jsx(fH,{side:qt?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[De&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ce?.state!=="RUNNING"&&s.jsx("button",{onClick:at=>{at.stopPropagation(),Jt(Pt?.amsId===mt.id&&Pt?.slotId===Re?null:{amsId:mt.id,slotId:Re})},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(gp,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ce?.state!=="RUNNING"&&Pt?.amsId===mt.id&&Pt?.slotId===Re&&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:at=>{at.stopPropagation(),St.mutate({amsId:mt.id,slotId:Re}),Jt(null)},disabled:De,children:[s.jsx(Dr,{className:`w-3 h-3 ${De?"animate-spin":""}`}),"Re-read RFID"]})}),Ae?s.jsx(zT,{data:Ae,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Ae.trayUuid?at=>{ae({trayUuid:at,trayInfo:{type:Ae.profile,color:Ae.colorHex||"",location:ku(mt.id,mt.tray.length)}})}:void 0},children:je}):s.jsx(uH,{children:je})]}),(mt.humidity!=null||mt.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[mt.temp!=null&&s.jsx(gH,{temp:mt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>te({amsId:mt.id,amsLabel:ku(mt.id,mt.tray.length),mode:"temperature"}),compact:!0}),mt.humidity!=null&&s.jsx(pH,{humidity:mt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>te({amsId:mt.id,amsLabel:ku(mt.id,mt.tray.length),mode:"humidity"}),compact:!0})]})]})]},mt.id)}),ce.vt_tray&&ce.vt_tray.tray_type&&(()=>{const mt=ce.vt_tray,$t=U===254,cn=mt.tray_info_idx?_e?.[mt.tray_info_idx]:null,Mn={vendor:mt.tray_uuid?"Bambu Lab":"Generic",profile:cn?.name||mt.tray_sub_brands||mt.tray_type||"Unknown",colorName:BT(mt.tray_id_name)||HT(mt.tray_color),colorHex:mt.tray_color||null,kFactor:$T(mt.k),fillLevel:null,trayUuid:mt.tray_uuid||null},qt=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${$t?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:mt.tray_color?`#${mt.tray_color}`:"#333",borderColor:$t?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:mt.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),s.jsx(zT,{data:Mn,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Mn.trayUuid?J=>{ae({trayUuid:J,trayInfo:{type:Mn.profile,color:Mn.colorHex||"",location:"External Spool"}})}:void 0},children:qt})]})})()]})]})]})})()]}),I&&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(hf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:I.name}),se&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${se.state==="ON"?"bg-bambu-green/20 text-bambu-green":se.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[se.state||"?",se.state==="ON"&&se.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",se.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>k(!0),disabled:$e.isPending||se?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${se?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(Ol,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>z(!0),disabled:$e.isPending||se?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${se?.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(fM,{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 ${I.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:I.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>ge.mutate(!I.auto_off),disabled:ge.isPending||I.auto_off_executed,title:I.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 ${I.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":I.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 ${I.auto_off||I.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(Te,{variant:"secondary",size:"sm",onClick:()=>lt.mutate(!ce?.chamber_light),disabled:!ce?.connected||lt.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(xCe,{on:ce?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{const ft=localStorage.getItem("cameraWindowState"),Ht=ft?JSON.parse(ft):{width:640,height:400},Qt=[`width=${Ht.width}`,`height=${Ht.height}`,Ht.left!==void 0?`left=${Ht.left}`:"",Ht.top!==void 0?`top=${Ht.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,Qt)},disabled:!ce?.connected,title:"Open camera in new window",children:s.jsx(lW,{className:"w-4 h-4"})}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>N(!0),title:"Browse printer files",children:[s.jsx(wR,{className:"w-4 h-4"}),"Files"]})]})]})]}),A&&s.jsx(ghe,{printerId:t.id,printerName:t.name,onClose:()=>N(!1)}),C&&s.jsx(xhe,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),O&&I&&s.jsx(Qn,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{$e.mutate("on"),k(!1)},onCancel:()=>k(!1)}),R&&I&&s.jsx(Qn,{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:()=>{$e.mutate("off"),z(!1)},onCancel:()=>z(!1)}),P&&s.jsx(Qn,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{Je.mutate(),W(!1)},onCancel:()=>W(!1)}),Z&&s.jsx(Qn,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{qe.mutate(),G(!1)},onCancel:()=>G(!1)}),Y&&s.jsx(Qn,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{Ze.mutate(),X(!1)},onCancel:()=>X(!1)}),q&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>F(!1),onKeyDown:ft=>ft.key==="Escape"&&F(!1),tabIndex:-1,ref:ft=>ft?.focus(),children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),s.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] overflow-hidden",onClick:ft=>ft.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dH,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),s.jsx("button",{onClick:()=>F(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(zt,{className:"w-4 h-4"})})]}),Ie?Ie.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:"No objects found"}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:s.jsx(Mue,{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:[Ie.skipped_count,"/",Ie.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(Na,{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",children:[s.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary",children:s.jsxs("div",{className:"relative",children:[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(vl,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Ie.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Ie.objects.map((ft,Ht)=>{let Qt,mt;if(ft.x!=null&&ft.y!=null&&Ie.bbox_all){const[$t,cn,Mn,qt]=Ie.bbox_all,J=Mn-$t,Ne=qt-cn,ze=8,Ye=100-ze*2;Qt=ze+(ft.x-$t)/J*Ye,mt=ze+(qt-ft.y)/Ne*Ye,Qt=Math.max(5,Math.min(95,Qt)),mt=Math.max(5,Math.min(95,mt))}else if(ft.x!=null&&ft.y!=null)Qt=ft.x/256*100,mt=100-ft.y/256*100,Qt=Math.max(5,Math.min(95,Qt)),mt=Math.max(5,Math.min(95,mt));else{const $t=Math.ceil(Math.sqrt(Ie.objects.length)),cn=Math.floor(Ht/$t),Mn=Ht%$t,qt=Math.ceil(Ie.objects.length/$t);Qt=15+Mn*(70/$t)+35/$t,mt=15+cn*(70/qt)+35/qt}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${ft.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${Qt}%`,top:`${mt}%`,transform:"translate(-50%, -50%)"},title:ft.name,children:ft.id},ft.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:[Ie.objects.filter(ft=>!ft.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0",children:Ie.objects.map(ft=>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
- ${ft.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
- ${ft.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 ${ft.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:ft.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${ft.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 ${ft.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:ft.name}),ft.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),ft.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:()=>Ue.mutate([ft.id]),disabled:Ue.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"})]},ft.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(gt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),D&&s.jsx(_he,{printerName:t.name,errors:ce?.hms_errors||[],onClose:()=>K(!1)}),V&&s.jsx(pCe,{isOpen:!!V,onClose:()=>te(null),printerId:t.id,printerName:t.name,amsId:V.amsId,amsLabel:V.amsLabel,initialMode:V.mode,thresholds:a}),re&&s.jsx(gCe,{isOpen:!!re,onClose:()=>ae(null),trayUuid:re.trayUuid,trayInfo:re.trayInfo}),E&&s.jsx(PCe,{printer:t,onClose:()=>w(!1)}),he&&fe&&s.jsx(jCe,{printer:t,firmwareInfo:fe,onClose:()=>ue(!1)}),Pt&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Jt(null)})]})}function kCe({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=S.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,o]=S.useState(!1),[l,c]=S.useState([]),[u,d]=S.useState(""),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState("192.168.1.0/24"),[v,E]=S.useState({scanned:0,total:0});S.useEffect(()=>{al.getInfo().then(T=>{x(T.is_docker)}).catch(()=>{})},[]);const w=l.filter(T=>!n.includes(T.serial)),A=async()=>{d(""),c([]),o(!0),g(!1),E({scanned:0,total:0});try{if(p){await al.startSubnetScan(y);const T=setInterval(async()=>{try{const O=await al.getScanStatus();E({scanned:O.scanned,total:O.total});const k=await al.getDiscoveredPrinters();c(k),O.running||(clearInterval(T),o(!1),g(!0))}catch(O){console.error("Failed to get scan status:",O)}},500)}else{await al.startDiscovery(10);const T=setInterval(async()=>{try{const O=await al.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get discovered printers:",O)}},1e3);setTimeout(async()=>{clearInterval(T);try{await al.stopDiscovery()}catch{}o(!1),g(!0);try{const O=await al.getDiscoveredPrinters();c(O)}catch(O){console.error("Failed to get final discovered printers:",O)}},1e4)}}catch(T){console.error("Failed to start discovery:",T),d(T instanceof Error?T.message:"Failed to start discovery"),o(!1),g(!0)}},N=T=>T?{O1D:"H2D",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D",H2C:"H2C",H2S:"H2S"}[T]||T:"",C=T=>{i({...r,name:T.name||"",serial_number:T.serial,ip_address:T.ip_address,model:N(T.model)}),c([])};return S.useEffect(()=>()=>{al.stopDiscovery().catch(()=>{}),al.stopSubnetScan().catch(()=>{})},[]),S.useEffect(()=>{const T=O=>{O.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(vt,{className:"w-full max-w-md",onClick:T=>T.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:T=>b(T.target.value),placeholder:"192.168.1.0/24",disabled:a}),s.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",s.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),s.jsx(Te,{type:"button",variant:"secondary",onClick:A,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 animate-spin"}),p&&v.total>0?`Scanning... ${v.scanned}/${v.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ml,{className:"w-4 h-4"}),p?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),w.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:w.map(T=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>C(T),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:T.name||T.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[N(T.model)||"Unknown"," • ",T.ip_address]})]}),s.jsx(Aa,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},T.serial))}),a&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:p?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!a&&l.length===0&&s.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",p?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&w.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),s.jsxs("form",{onSubmit:T=>{T.preventDefault(),e(r)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.name,onChange:T=>i({...r,name:T.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.ip_address,onChange:T=>i({...r,ip_address:T.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.serial_number,onChange:T=>i({...r,serial_number:T.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.access_code,onChange:T=>i({...r,access_code:T.target.value}),placeholder:"From printer settings"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r.model||"",onChange:T=>i({...r,model:T.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:T=>i({...r,auto_archive:T.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Te,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function jCe({printer:t,firmwareInfo:e,onClose:n}){const r=ln(),{showToast:i}=dr(),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),{data:f,isLoading:g}=ht({queryKey:["firmwarePrepare",t.id],queryFn:()=>v1.prepareUpload(t.id),staleTime:3e4}),p=xt({mutationFn:()=>v1.startUpload(t.id),onSuccess:()=>{c(!0);const y=setInterval(async()=>{try{const b=await v1.getUploadStatus(t.id);o(b),(b.status==="complete"||b.status==="error")&&(clearInterval(y),d(null),c(!1),b.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(y)},onError:y=>{i(`Failed to start upload: ${y.message}`,"error"),c(!1)}});S.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const x=()=>{o(null),p.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(vt,{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(Mi,{className:"w-5 h-5 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Firmware Update"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[s.jsxs("div",{className:"flex justify-between items-center text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Current:"}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),s.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&s.jsxs("details",{className:"mt-3 text-sm",children:[s.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:"Release Notes"}),s.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),g?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(gt,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!a?s.jsx("div",{className:"mb-4",children:f.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(vl,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((y,b)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Na,{className:"w-4 h-4 flex-shrink-0"}),y]},b))})}):null,(l||a)&&a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:a.status}),s.jsxs("span",{className:"text-white",children:[a.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:`h-2 rounded-full transition-all ${a.status==="error"?"bg-red-500":a.status==="complete"?"bg-bambu-green":"bg-orange-500"} ${a.status==="uploading"?"animate-pulse":""}`,style:{width:`${a.progress}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.message}),a.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:a.error})]}),a?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["On the printer's touchscreen, go to ",s.jsx("strong",{className:"text-white",children:"Settings"})]}),s.jsxs("li",{children:["Navigate to ",s.jsx("strong",{className:"text-white",children:"Firmware"})]}),s.jsxs("li",{children:["Select ",s.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),s.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Te,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Te,{onClick:x,disabled:p.isPending,children:p.isPending?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Mi,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function PCe({printer:t,onClose:e}){const n=ln(),[r,i]=S.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=xt({mutationFn:l=>be.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});S.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const o=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(vt,{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(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Te,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function RCe(t){const{data:e}=ht({queryKey:["printerStatus",t],queryFn:()=>be.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function DCe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=RCe(t.id),{data:a}=ht({queryKey:["smartPlugStatus",e.id],queryFn:()=>be.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),s.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[s.jsx(Ol,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function OCe(){const[t,e]=S.useState(!1),[n,r]=S.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=S.useState(!1),[o,l]=S.useState(null),[c,u]=S.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=S.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[g,p]=S.useState(()=>{const q=localStorage.getItem("printerCardSize");return q?parseInt(q,10):2}),x=g===1?"compact":"expanded",y=ln(),{data:b,isLoading:v}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:E}=ht({queryKey:["settings"],queryFn:be.getSettings}),{data:w}=ht({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs}),{data:A}=ht({queryKey:["maintenanceOverview"],queryFn:be.getMaintenanceOverview,staleTime:60*1e3}),{data:N}=ht({queryKey:["spoolman-status"],queryFn:be.getSpoolmanStatus,staleTime:60*1e3}),C=N?.enabled&&N?.connected,{data:T}=ht({queryKey:["unlinked-spools"],queryFn:be.getUnlinkedSpools,enabled:!!C,staleTime:30*1e3}),O=T&&T.length>0,k=A?.reduce((q,F)=>(q[F.printer_id]={due_count:F.due_count,warning_count:F.warning_count,total_print_hours:F.total_print_hours},q),{})||{},R=w?.reduce((q,F)=>(F.printer_id&&(q[F.printer_id]=F),q),{})||{},z=xt({mutationFn:be.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),D=xt({mutationFn:q=>be.controlSmartPlug(q,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),K=()=>{const q=!n;r(q),localStorage.setItem("hideDisconnectedPrinters",String(q))},P=q=>{u(q),localStorage.setItem("printerSortBy",q)},W=()=>{const q=!d;f(q),localStorage.setItem("printerSortAsc",String(q))},Z=()=>{switch(g){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},G=["S","M","L","XL"],Y=S.useMemo(()=>{if(!b)return[];const q=[...b];switch(c){case"name":q.sort((F,V)=>F.name.localeCompare(V.name));break;case"model":q.sort((F,V)=>(F.model||"").localeCompare(V.model||""));break;case"location":q.sort((F,V)=>{const te=F.location||"",re=V.location||"";return!te&&re?1:te&&!re?-1:te.localeCompare(re)||F.name.localeCompare(V.name)});break;case"status":q.sort((F,V)=>{const te=y.getQueryData(["printerStatus",F.id]),re=y.getQueryData(["printerStatus",V.id]),ae=he=>he?.connected?he.state==="RUNNING"?0:1:2;return ae(te)-ae(re)});break}return d||q.reverse(),q},[b,c,d,y]),X=S.useMemo(()=>{if(c!=="location")return null;const q={};return Y.forEach(F=>{const V=F.location||"Ungrouped";q[V]||(q[V]=[]),q[V].push(F)}),q},[c,Y]);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(CCe,{printers:b})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:c,onChange:q=>P(q.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:W,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(kp,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(U0,{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:G.map((q,F)=>{const V=F+1,te=g===V;return s.jsx("button",{onClick:()=>{p(V),localStorage.setItem("printerCardSize",String(V))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${F===0?"rounded-l-lg":""} ${F===G.length-1?"rounded-r-lg":""} ${te?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${q==="S"?"Small":q==="M"?"Medium":q==="L"?"Large":"Extra large"} cards`,children:q},q)})}),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:K,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(R).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[s.jsx(Ol,{className:"w-4 h-4"}),"Power On",s.jsx(Aa,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[s.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),b?.filter(q=>R[q.id]).map(q=>s.jsx(DCe,{printer:q,plug:R[q.id],onPowerOn:F=>{l(F),D.mutate(F)},isPowering:o===R[q.id]?.id},q.id)),b?.filter(q=>R[q.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Te,{onClick:()=>e(!0),children:[s.jsx(mr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):b?.length===0?s.jsx(vt,{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(Te,{onClick:()=>e(!0),children:[s.jsx(mr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):X?s.jsx("div",{className:"space-y-6",children:Object.entries(X).map(([q,F])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),q,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",F.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${g>=3?"gap-6":""} ${Z()}`,children:F.map(V=>s.jsx(yH,{printer:V,hideIfDisconnected:n,maintenanceInfo:k[V.id],viewMode:x,cardSize:g,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,spoolmanEnabled:C,hasUnlinkedSpools:O,timeFormat:E?.time_format||"system"},V.id))})]},q))}):s.jsx("div",{className:`grid gap-4 ${g>=3?"gap-6":""} ${Z()}`,children:Y.map(q=>s.jsx(yH,{printer:q,hideIfDisconnected:n,maintenanceInfo:k[q.id],viewMode:x,cardSize:g,spoolmanEnabled:C,hasUnlinkedSpools:O,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,timeFormat:E?.time_format||"system"},q.id))}),t&&s.jsx(kCe,{onClose:()=>e(!1),onAdd:q=>z.mutate(q),existingSerials:b?.map(q=>q.serial_number)||[]})]})}function LCe(){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 ICe(){switch(LCe()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function Ec(t){const e=ICe();window.location.href=`${e}${encodeURIComponent(t)}`}const jO="181",_p={ROTATE:0,DOLLY:1,PAN:2},fp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},FCe=0,vH=1,UCe=2,TZ=1,zCe=2,bc=3,Rd=0,ss=1,ml=2,Fc=0,wp=1,_H=2,wH=3,SH=4,BCe=5,Ah=100,HCe=101,$Ce=102,VCe=103,GCe=104,WCe=200,qCe=201,KCe=202,XCe=203,xj=204,bj=205,YCe=206,ZCe=207,QCe=208,JCe=209,eke=210,tke=211,nke=212,rke=213,ike=214,yj=0,vj=1,_j=2,Gp=3,wj=4,Sj=5,Mj=6,Ej=7,PO=0,ake=1,ske=2,pd=0,oke=1,lke=2,cke=3,uke=4,dke=5,hke=6,fke=7,CZ=300,Wp=301,qp=302,Nj=303,Aj=304,d2=306,Tj=1e3,jc=1001,Cj=1002,Ds=1003,mke=1004,t_=1005,ho=1006,GT=1007,Fh=1008,Cl=1009,kZ=1010,jZ=1011,ob=1012,RO=1013,vf=1014,Pc=1015,Ng=1016,DO=1017,OO=1018,lb=1020,PZ=35902,RZ=35899,DZ=1021,OZ=1022,Uo=1023,cb=1026,ub=1027,LZ=1028,LO=1029,IO=1030,FO=1031,UO=1033,C1=33776,k1=33777,j1=33778,P1=33779,kj=35840,jj=35841,Pj=35842,Rj=35843,Dj=36196,Oj=37492,Lj=37496,Ij=37808,Fj=37809,Uj=37810,zj=37811,Bj=37812,Hj=37813,$j=37814,Vj=37815,Gj=37816,Wj=37817,qj=37818,Kj=37819,Xj=37820,Yj=37821,Zj=36492,Qj=36494,Jj=36495,eP=36283,tP=36284,nP=36285,rP=36286,pke=3200,gke=3201,IZ=0,xke=1,nd="",no="srgb",Kp="srgb-linear",eS="linear",ar="srgb",vm=7680,MH=519,bke=512,yke=513,vke=514,FZ=515,_ke=516,wke=517,Ske=518,Mke=519,EH=35044,NH="300 es",bl=2e3,tS=2001;function UZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function nS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Eke(){const t=nS("canvas");return t.style.display="block",t}const AH={};function TH(...t){const e="THREE."+t.shift();console.log(e,...t)}function rn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function ti(...t){const e="THREE."+t.shift();console.error(e,...t)}function db(...t){const e=t.join(" ");e in AH||(AH[e]=!0,rn(...t))}function Nke(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 Df=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}};const pa=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],R1=Math.PI/180,iP=180/Math.PI;function hy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(pa[t&255]+pa[t>>8&255]+pa[t>>16&255]+pa[t>>24&255]+"-"+pa[e&255]+pa[e>>8&255]+"-"+pa[e>>16&15|64]+pa[e>>24&255]+"-"+pa[n&63|128]+pa[n>>8&255]+"-"+pa[n>>16&255]+pa[n>>24&255]+pa[r&255]+pa[r>>8&255]+pa[r>>16&255]+pa[r>>24&255]).toLowerCase()}function An(t,e,n){return Math.max(e,Math.min(n,t))}function Ake(t,e){return(t%e+e)%e}function WT(t,e,n){return(1-n)*t+n*e}function Ox(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Qa(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const Tke={DEG2RAD:R1};let xn=class zZ{constructor(e=0,n=0){zZ.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(An(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},_f=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],g=a[o+0],p=a[o+1],x=a[o+2],y=a[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==g||u!==p||d!==x){let b=c*g+u*p+d*x+f*y;b<0&&(g=-g,p=-p,x=-x,y=-y,b=-b);let v=1-l;if(b<.9995){const E=Math.acos(b),w=Math.sin(E);v=Math.sin(v*E)/w,l=Math.sin(l*E)/w,c=c*v+g*l,u=u*v+p*l,d=d*v+x*l,f=f*v+y*l}else{c=c*v+g*l,u=u*v+p*l,d=d*v+x*l,f=f*v+y*l;const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],g=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:rn("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+l+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(An(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},it=class BZ{constructor(e=0,n=0,r=0){BZ.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(CH.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(CH.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this.z=An(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this.z=An(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return qT.copy(this).projectOnVector(e),this.sub(qT)}reflect(e){return this.sub(qT.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(An(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const qT=new it,CH=new _f;let yn=class HZ{constructor(e,n,r,i,a,o,l,c,u){HZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],y=i[0],b=i[3],v=i[6],E=i[1],w=i[4],A=i[7],N=i[2],C=i[5],T=i[8];return a[0]=o*y+l*E+c*N,a[3]=o*b+l*w+c*C,a[6]=o*v+l*A+c*T,a[1]=u*y+d*E+f*N,a[4]=u*b+d*w+f*C,a[7]=u*v+d*A+f*T,a[2]=g*y+p*E+x*N,a[5]=g*b+p*w+x*C,a[8]=g*v+p*A+x*T,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,g=l*c-d*a,p=u*a-o*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=g*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(KT.makeScale(e,n)),this}rotate(e){return this.premultiply(KT.makeRotation(-e)),this}translate(e,n){return this.premultiply(KT.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 KT=new yn,kH=new yn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),jH=new yn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Cke(){const t={enabled:!0,workingColorSpace:Kp,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===ar&&(i.r=Uc(i.r),i.g=Uc(i.g),i.b=Uc(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===ar&&(i.r=Sp(i.r),i.g=Sp(i.g),i.b=Sp(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===nd?eS: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 db("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return db("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({[Kp]:{primaries:e,whitePoint:r,transfer:eS,toXYZ:kH,fromXYZ:jH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:no},outputColorSpaceConfig:{drawingBufferColorSpace:no}},[no]:{primaries:e,whitePoint:r,transfer:ar,toXYZ:kH,fromXYZ:jH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:no}}}),t}const Bn=Cke();function Uc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Sp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let _m,kke=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{_m===void 0&&(_m=nS("canvas")),_m.width=e.width,_m.height=e.height;const i=_m.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=_m}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=nS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Uc(a[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Uc(n[r]/255)*255):n[r]=Uc(n[r]);return{data:n,width:e.width,height:e.height}}else return rn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},jke=0,zO=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:jke++}),this.uuid=hy(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):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(XT(i[o].image)):a.push(XT(i[o]))}else a=XT(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function XT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?kke.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(rn("Texture: Unable to serialize Texture."),{})}let Pke=0;const YT=new it;let Jo=class D1 extends Df{constructor(e=D1.DEFAULT_IMAGE,n=D1.DEFAULT_MAPPING,r=jc,i=jc,a=ho,o=Fh,l=Uo,c=Cl,u=D1.DEFAULT_ANISOTROPY,d=nd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Pke++}),this.uuid=hy(),this.name="",this.source=new zO(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new xn(0,0),this.repeat=new xn(1,1),this.center=new xn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yn,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(YT).x}get height(){return this.source.getSize(YT).y}get depth(){return this.source.getSize(YT).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){rn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){rn(`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!==CZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Tj:e.x=e.x-Math.floor(e.x);break;case jc:e.x=e.x<0?0:1;break;case Cj: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 Tj:e.y=e.y-Math.floor(e.y);break;case jc:e.y=e.y<0?0:1;break;case Cj:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Jo.DEFAULT_IMAGE=null;Jo.DEFAULT_MAPPING=CZ;Jo.DEFAULT_ANISOTROPY=1;let hi=class $Z{constructor(e=0,n=0,r=0,i=1){$Z.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,N=(v+1)/2,C=(d+g)/4,T=(f+y)/4,O=(x+b)/4;return w>A&&w>N?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=T/r):A>N?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=O/i):N<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(N),r=T/a,i=O/a),this.set(r,i,a,n),this}let E=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(b-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+v-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=An(this.x,e.x,n.x),this.y=An(this.y,e.y,n.y),this.z=An(this.z,e.z,n.z),this.w=An(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=An(this.x,e,n),this.y=An(this.y,e,n),this.z=An(this.z,e,n),this.w=An(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(An(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Rke=class extends Df{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ho,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new hi(0,0,e,n),this.scissorTest=!1,this.viewport=new hi(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new Jo(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:ho,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new zO(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},wf=class extends Rke{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},VZ=class extends Jo{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Ds,this.minFilter=Ds,this.wrapR=jc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Dke=class extends Jo{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Ds,this.minFilter=Ds,this.wrapR=jc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Sf=class{constructor(e=new it(1/0,1/0,1/0),n=new it(-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(Ao.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Ao.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=Ao.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,Ao):Ao.fromBufferAttribute(a,o),Ao.applyMatrix4(e.matrixWorld),this.expandByPoint(Ao);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),n_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),n_.copy(r.boundingBox)),n_.applyMatrix4(e.matrixWorld),this.union(n_)}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,Ao),Ao.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(Lx),r_.subVectors(this.max,Lx),wm.subVectors(e.a,Lx),Sm.subVectors(e.b,Lx),Mm.subVectors(e.c,Lx),ju.subVectors(Sm,wm),Pu.subVectors(Mm,Sm),uh.subVectors(wm,Mm);let n=[0,-ju.z,ju.y,0,-Pu.z,Pu.y,0,-uh.z,uh.y,ju.z,0,-ju.x,Pu.z,0,-Pu.x,uh.z,0,-uh.x,-ju.y,ju.x,0,-Pu.y,Pu.x,0,-uh.y,uh.x,0];return!ZT(n,wm,Sm,Mm,r_)||(n=[1,0,0,0,1,0,0,0,1],!ZT(n,wm,Sm,Mm,r_))?!1:(i_.crossVectors(ju,Pu),n=[i_.x,i_.y,i_.z],ZT(n,wm,Sm,Mm,r_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ao).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ao).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ic[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ic[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ic[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ic[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ic[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ic[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ic[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ic[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ic),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const ic=[new it,new it,new it,new it,new it,new it,new it,new it],Ao=new it,n_=new Sf,wm=new it,Sm=new it,Mm=new it,ju=new it,Pu=new it,uh=new it,Lx=new it,r_=new it,i_=new it,dh=new it;function ZT(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){dh.fromArray(t,a);const l=i.x*Math.abs(dh.x)+i.y*Math.abs(dh.y)+i.z*Math.abs(dh.z),c=e.dot(dh),u=n.dot(dh),d=r.dot(dh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Oke=new Sf,Ix=new it,QT=new it;let h2=class{constructor(e=new it,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):Oke.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;Ix.subVectors(e,this.center);const n=Ix.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Ix,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):(QT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ix.copy(e.center).add(QT)),this.expandByPoint(Ix.copy(e.center).sub(QT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const ac=new it,JT=new it,a_=new it,Ru=new it,eC=new it,s_=new it,tC=new it;let BO=class{constructor(e=new it,n=new it(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ac)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=ac.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(ac.copy(this.origin).addScaledVector(this.direction,n),ac.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){JT.copy(e).add(n).multiplyScalar(.5),a_.copy(n).sub(e).normalize(),Ru.copy(this.origin).sub(JT);const a=e.distanceTo(n)*.5,o=-this.direction.dot(a_),l=Ru.dot(this.direction),c=-Ru.dot(a_),u=Ru.lengthSq(),d=Math.abs(1-o*o);let f,g,p,x;if(d>0)if(f=o*c-l,g=o*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,p=f*(f+o*g+2*l)+g*(o*f+g+2*c)+u}else g=a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-o*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(o*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=o>0?-a:a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(JT).addScaledVector(a_,g),p}intersectSphere(e,n){ac.subVectors(e.center,this.origin);const r=ac.dot(this.direction),i=ac.dot(ac)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,o=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,o=(e.min.y-g.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(l=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,ac)!==null}intersectTriangle(e,n,r,i,a){eC.subVectors(n,e),s_.subVectors(r,e),tC.crossVectors(eC,s_);let o=this.direction.dot(tC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Ru.subVectors(this.origin,e);const c=l*this.direction.dot(s_.crossVectors(Ru,s_));if(c<0)return null;const u=l*this.direction.dot(eC.cross(Ru));if(u<0||c+u>o)return null;const d=-l*Ru.dot(tC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},gi=class aP{constructor(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){aP.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=g,v[3]=p,v[7]=x,v[11]=y,v[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new aP().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/Em.setFromMatrixColumn(e,0).length(),a=1/Em.setFromMatrixColumn(e,1).length(),o=1/Em.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-y*u,n[9]=-l*c,n[2]=y-g*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g+y*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=y+g*l,n[10]=o*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g-y*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=y-g*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const g=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-g*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Lke,e,Ike)}lookAt(e,n,r){const i=this.elements;return Ss.subVectors(e,n),Ss.lengthSq()===0&&(Ss.z=1),Ss.normalize(),Du.crossVectors(r,Ss),Du.lengthSq()===0&&(Math.abs(r.z)===1?Ss.x+=1e-4:Ss.z+=1e-4,Ss.normalize(),Du.crossVectors(r,Ss)),Du.normalize(),o_.crossVectors(Ss,Du),i[0]=Du.x,i[4]=o_.x,i[8]=Ss.x,i[1]=Du.y,i[5]=o_.y,i[9]=Ss.y,i[2]=Du.z,i[6]=o_.z,i[10]=Ss.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],y=r[6],b=r[10],v=r[14],E=r[3],w=r[7],A=r[11],N=r[15],C=i[0],T=i[4],O=i[8],k=i[12],R=i[1],z=i[5],D=i[9],K=i[13],P=i[2],W=i[6],Z=i[10],G=i[14],Y=i[3],X=i[7],q=i[11],F=i[15];return a[0]=o*C+l*R+c*P+u*Y,a[4]=o*T+l*z+c*W+u*X,a[8]=o*O+l*D+c*Z+u*q,a[12]=o*k+l*K+c*G+u*F,a[1]=d*C+f*R+g*P+p*Y,a[5]=d*T+f*z+g*W+p*X,a[9]=d*O+f*D+g*Z+p*q,a[13]=d*k+f*K+g*G+p*F,a[2]=x*C+y*R+b*P+v*Y,a[6]=x*T+y*z+b*W+v*X,a[10]=x*O+y*D+b*Z+v*q,a[14]=x*k+y*K+b*G+v*F,a[3]=E*C+w*R+A*P+N*Y,a[7]=E*T+w*z+A*W+N*X,a[11]=E*O+w*D+A*Z+N*q,a[15]=E*k+w*K+A*G+N*F,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+y*(+n*c*p-n*u*g+a*o*g-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*g+i*o*f-r*o*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],y=e[13],b=e[14],v=e[15],E=f*b*u-y*g*u+y*c*p-l*b*p-f*c*v+l*g*v,w=x*g*u-d*b*u-x*c*p+o*b*p+d*c*v-o*g*v,A=d*y*u-x*f*u+x*l*p-o*y*p-d*l*v+o*f*v,N=x*f*c-d*y*c-x*l*g+o*y*g+d*l*b-o*f*b,C=n*E+r*w+i*A+a*N;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/C;return e[0]=E*T,e[1]=(y*g*a-f*b*a-y*i*p+r*b*p+f*i*v-r*g*v)*T,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*T,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*T,e[4]=w*T,e[5]=(d*b*a-x*g*a+x*i*p-n*b*p-d*i*v+n*g*v)*T,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*T,e[7]=(o*g*a-d*c*a+d*i*u-n*g*u-o*i*p+n*c*p)*T,e[8]=A*T,e[9]=(x*f*a-d*y*a-x*r*p+n*y*p+d*r*v-n*f*v)*T,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*T,e[12]=N*T,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*b+n*f*b)*T,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*g+n*l*g)*T,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,g=a*u,p=a*d,x=a*f,y=o*d,b=o*f,v=l*f,E=c*u,w=c*d,A=c*f,N=r.x,C=r.y,T=r.z;return i[0]=(1-(y+v))*N,i[1]=(p+A)*N,i[2]=(x-w)*N,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+v))*C,i[6]=(b+E)*C,i[7]=0,i[8]=(x+w)*T,i[9]=(b-E)*T,i[10]=(1-(g+y))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Em.set(i[0],i[1],i[2]).length();const o=Em.set(i[4],i[5],i[6]).length(),l=Em.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],To.copy(this);const u=1/a,d=1/o,f=1/l;return To.elements[0]*=u,To.elements[1]*=u,To.elements[2]*=u,To.elements[4]*=d,To.elements[5]*=d,To.elements[6]*=d,To.elements[8]*=f,To.elements[9]*=f,To.elements[10]*=f,n.setFromRotationMatrix(To),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=bl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),g=(n+e)/(n-e),p=(r+i)/(r-i);let x,y;if(c)x=a/(o-a),y=o*a/(o-a);else if(l===bl)x=-(o+a)/(o-a),y=-2*o*a/(o-a);else if(l===tS)x=-o/(o-a),y=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=g,u[12]=0,u[1]=0,u[5]=f,u[9]=p,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=bl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),g=-(n+e)/(n-e),p=-(r+i)/(r-i);let x,y;if(c)x=1/(o-a),y=o/(o-a);else if(l===bl)x=-2/(o-a),y=-(o+a)/(o-a);else if(l===tS)x=-1/(o-a),y=-a/(o-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=g,u[1]=0,u[5]=f,u[9]=0,u[13]=p,u[2]=0,u[6]=0,u[10]=x,u[14]=y,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const Em=new it,To=new gi,Lke=new it(0,0,0),Ike=new it(1,1,1),Du=new it,o_=new it,Ss=new it,PH=new gi,RH=new _f;let Dd=class GZ{constructor(e=0,n=0,r=0,i=GZ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(An(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-An(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(An(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-An(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(An(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-An(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:rn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return PH.makeRotationFromQuaternion(e),this.setFromRotationMatrix(PH,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return RH.setFromEuler(this),this.setFromQuaternion(RH,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Dd.DEFAULT_ORDER="XYZ";let WZ=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}},Fke=0;const DH=new it,Nm=new _f,sc=new gi,l_=new it,Fx=new it,Uke=new it,zke=new _f,OH=new it(1,0,0),LH=new it(0,1,0),IH=new it(0,0,1),FH={type:"added"},Bke={type:"removed"},Am={type:"childadded",child:null},nC={type:"childremoved",child:null};let Fs=class O1 extends Df{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Fke++}),this.uuid=hy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=O1.DEFAULT_UP.clone();const e=new it,n=new Dd,r=new _f,i=new it(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new gi},normalMatrix:{value:new yn}}),this.matrix=new gi,this.matrixWorld=new gi,this.matrixAutoUpdate=O1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=O1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new WZ,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 Nm.setFromAxisAngle(e,n),this.quaternion.multiply(Nm),this}rotateOnWorldAxis(e,n){return Nm.setFromAxisAngle(e,n),this.quaternion.premultiply(Nm),this}rotateX(e){return this.rotateOnAxis(OH,e)}rotateY(e){return this.rotateOnAxis(LH,e)}rotateZ(e){return this.rotateOnAxis(IH,e)}translateOnAxis(e,n){return DH.copy(e).applyQuaternion(this.quaternion),this.position.add(DH.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(OH,e)}translateY(e){return this.translateOnAxis(LH,e)}translateZ(e){return this.translateOnAxis(IH,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(sc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?l_.copy(e):l_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Fx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?sc.lookAt(Fx,l_,this.up):sc.lookAt(l_,Fx,this.up),this.quaternion.setFromRotationMatrix(sc),i&&(sc.extractRotation(i.matrixWorld),Nm.setFromRotationMatrix(sc),this.quaternion.premultiply(Nm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(ti("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(FH),Am.child=e,this.dispatchEvent(Am),Am.child=null):ti("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(Bke),nC.child=e,this.dispatchEvent(nC),nC.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),sc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),sc.multiply(e.parent.matrixWorld)),e.applyMatrix4(sc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(FH),Am.child=e,this.dispatchEvent(Am),Am.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(Fx,e,Uke),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fx,zke,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),g=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Fs.DEFAULT_UP=new it(0,1,0);Fs.DEFAULT_MATRIX_AUTO_UPDATE=!0;Fs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Co=new it,oc=new it,rC=new it,lc=new it,Tm=new it,Cm=new it,UH=new it,iC=new it,aC=new it,sC=new it,oC=new hi,lC=new hi,cC=new hi;let Ux=class ap{constructor(e=new it,n=new it,r=new it){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Co.subVectors(e,n),i.cross(Co);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){Co.subVectors(i,n),oc.subVectors(r,n),rC.subVectors(e,n);const o=Co.dot(Co),l=Co.dot(oc),c=Co.dot(rC),u=oc.dot(oc),d=oc.dot(rC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const g=1/f,p=(u*c-l*d)*g,x=(o*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,lc)===null?!1:lc.x>=0&&lc.y>=0&&lc.x+lc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,lc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,lc.x),c.addScaledVector(o,lc.y),c.addScaledVector(l,lc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return oC.setScalar(0),lC.setScalar(0),cC.setScalar(0),oC.fromBufferAttribute(e,n),lC.fromBufferAttribute(e,r),cC.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(oC,a.x),o.addScaledVector(lC,a.y),o.addScaledVector(cC,a.z),o}static isFrontFacing(e,n,r,i){return Co.subVectors(r,n),oc.subVectors(e,n),Co.cross(oc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Co.subVectors(this.c,this.b),oc.subVectors(this.a,this.b),Co.cross(oc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ap.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return ap.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return ap.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return ap.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ap.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;Tm.subVectors(i,r),Cm.subVectors(a,r),iC.subVectors(e,r);const c=Tm.dot(iC),u=Cm.dot(iC);if(c<=0&&u<=0)return n.copy(r);aC.subVectors(e,i);const d=Tm.dot(aC),f=Cm.dot(aC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Tm,o);sC.subVectors(e,a);const p=Tm.dot(sC),x=Cm.dot(sC);if(x>=0&&p<=x)return n.copy(a);const y=p*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Cm,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return UH.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(UH,l);const v=1/(b+y+g);return o=y*v,l=g*v,n.copy(r).addScaledVector(Tm,o).addScaledVector(Cm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const qZ={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},Ou={h:0,s:0,l:0},c_={h:0,s:0,l:0};function uC(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 Tn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=no){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Bn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Bn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Bn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Bn.workingColorSpace){if(e=Ake(e,1),n=An(n,0,1),r=An(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=uC(o,a,e+1/3),this.g=uC(o,a,e),this.b=uC(o,a,e-1/3)}return Bn.colorSpaceToWorking(this,i),this}setStyle(e,n=no){function r(a){a!==void 0&&parseFloat(a)<1&&rn("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:rn("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);rn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=no){const r=qZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):rn("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Uc(e.r),this.g=Uc(e.g),this.b=Uc(e.b),this}copyLinearToSRGB(e){return this.r=Sp(e.r),this.g=Sp(e.g),this.b=Sp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=no){return Bn.workingToColorSpace(ga.copy(this),e),Math.round(An(ga.r*255,0,255))*65536+Math.round(An(ga.g*255,0,255))*256+Math.round(An(ga.b*255,0,255))}getHexString(e=no){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Bn.workingColorSpace){Bn.workingToColorSpace(ga.copy(this),n);const r=ga.r,i=ga.g,a=ga.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Bn.workingColorSpace){return Bn.workingToColorSpace(ga.copy(this),n),e.r=ga.r,e.g=ga.g,e.b=ga.b,e}getStyle(e=no){Bn.workingToColorSpace(ga.copy(this),e);const n=ga.r,r=ga.g,i=ga.b;return e!==no?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(Ou),this.setHSL(Ou.h+e,Ou.s+n,Ou.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(Ou),e.getHSL(c_);const r=WT(Ou.h,c_.h,n),i=WT(Ou.s,c_.s,n),a=WT(Ou.l,c_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const ga=new Tn;Tn.NAMES=qZ;let Hke=0,Ag=class extends Df{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Hke++}),this.uuid=hy(),this.name="",this.type="Material",this.blending=wp,this.side=Rd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=xj,this.blendDst=bj,this.blendEquation=Ah,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Tn(0,0,0),this.blendAlpha=0,this.depthFunc=Gp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=MH,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=vm,this.stencilZFail=vm,this.stencilZPass=vm,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){rn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){rn(`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!==wp&&(r.blending=this.blending),this.side!==Rd&&(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!==xj&&(r.blendSrc=this.blendSrc),this.blendDst!==bj&&(r.blendDst=this.blendDst),this.blendEquation!==Ah&&(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!==Gp&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==MH&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==vm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==vm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==vm&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},HO=class extends Ag{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Tn(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 Dd,this.combine=PO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const oi=new it,u_=new xn;let $ke=0,mo=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:$ke++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=EH,this.updateRanges=[],this.gpuType=Pc,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++)u_.fromBufferAttribute(this,n),u_.applyMatrix3(e),this.setXY(n,u_.x,u_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.applyMatrix3(e),this.setXYZ(n,oi.x,oi.y,oi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.applyMatrix4(e),this.setXYZ(n,oi.x,oi.y,oi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.applyNormalMatrix(e),this.setXYZ(n,oi.x,oi.y,oi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)oi.fromBufferAttribute(this,n),oi.transformDirection(e),this.setXYZ(n,oi.x,oi.y,oi.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=Ox(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Qa(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Ox(n,this.array)),n}setX(e,n){return this.normalized&&(n=Qa(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Ox(n,this.array)),n}setY(e,n){return this.normalized&&(n=Qa(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=Ox(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Qa(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=Ox(n,this.array)),n}setW(e,n){return this.normalized&&(n=Qa(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Qa(n,this.array),r=Qa(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=Qa(n,this.array),r=Qa(r,this.array),i=Qa(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Qa(n,this.array),r=Qa(r,this.array),i=Qa(i,this.array),a=Qa(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==EH&&(e.usage=this.usage),e}},KZ=class extends mo{constructor(e,n,r){super(new Uint16Array(e),n,r)}},XZ=class extends mo{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Vo=class extends mo{constructor(e,n,r){super(new Float32Array(e),n,r)}},Vke=0;const Xs=new gi,dC=new Fs,km=new it,Ms=new Sf,zx=new Sf,Ui=new it;let Ul=class YZ extends Df{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Vke++}),this.uuid=hy(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(UZ(e)?XZ:KZ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new yn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Xs.makeRotationFromQuaternion(e),this.applyMatrix4(Xs),this}rotateX(e){return Xs.makeRotationX(e),this.applyMatrix4(Xs),this}rotateY(e){return Xs.makeRotationY(e),this.applyMatrix4(Xs),this}rotateZ(e){return Xs.makeRotationZ(e),this.applyMatrix4(Xs),this}translate(e,n,r){return Xs.makeTranslation(e,n,r),this.applyMatrix4(Xs),this}scale(e,n,r){return Xs.makeScale(e,n,r),this.applyMatrix4(Xs),this}lookAt(e){return dC.lookAt(e),dC.updateMatrix(),this.applyMatrix4(dC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(km).negate(),this.translate(km.x,km.y,km.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Vo(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&rn("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 Sf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ti("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new it(-1/0,-1/0,-1/0),new it(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];Ms.setFromBufferAttribute(a),this.morphTargetsRelative?(Ui.addVectors(this.boundingBox.min,Ms.min),this.boundingBox.expandByPoint(Ui),Ui.addVectors(this.boundingBox.max,Ms.max),this.boundingBox.expandByPoint(Ui)):(this.boundingBox.expandByPoint(Ms.min),this.boundingBox.expandByPoint(Ms.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ti('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new h2);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ti("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new it,1/0);return}if(e){const r=this.boundingSphere.center;if(Ms.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];zx.setFromBufferAttribute(l),this.morphTargetsRelative?(Ui.addVectors(Ms.min,zx.min),Ms.expandByPoint(Ui),Ui.addVectors(Ms.max,zx.max),Ms.expandByPoint(Ui)):(Ms.expandByPoint(zx.min),Ms.expandByPoint(zx.max))}Ms.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Ui.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Ui));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Ui.fromBufferAttribute(l,u),c&&(km.fromBufferAttribute(e,u),Ui.add(km)),i=Math.max(i,r.distanceToSquared(Ui))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ti('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){ti("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new mo(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let O=0;O<r.count;O++)l[O]=new it,c[O]=new it;const u=new it,d=new it,f=new it,g=new xn,p=new xn,x=new xn,y=new it,b=new it;function v(O,k,R){u.fromBufferAttribute(r,O),d.fromBufferAttribute(r,k),f.fromBufferAttribute(r,R),g.fromBufferAttribute(a,O),p.fromBufferAttribute(a,k),x.fromBufferAttribute(a,R),d.sub(u),f.sub(u),p.sub(g),x.sub(g);const z=1/(p.x*x.y-x.x*p.y);isFinite(z)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(f,-p.y).multiplyScalar(z),b.copy(f).multiplyScalar(p.x).addScaledVector(d,-x.x).multiplyScalar(z),l[O].add(y),l[k].add(y),l[R].add(y),c[O].add(b),c[k].add(b),c[R].add(b))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let O=0,k=E.length;O<k;++O){const R=E[O],z=R.start,D=R.count;for(let K=z,P=z+D;K<P;K+=3)v(e.getX(K+0),e.getX(K+1),e.getX(K+2))}const w=new it,A=new it,N=new it,C=new it;function T(O){N.fromBufferAttribute(i,O),C.copy(N);const k=l[O];w.copy(k),w.sub(N.multiplyScalar(N.dot(k))).normalize(),A.crossVectors(C,k);const z=A.dot(c[O])<0?-1:1;o.setXYZW(O,w.x,w.y,w.z,z)}for(let O=0,k=E.length;O<k;++O){const R=E[O],z=R.start,D=R.count;for(let K=z,P=z+D;K<P;K+=3)T(e.getX(K+0)),T(e.getX(K+1)),T(e.getX(K+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 mo(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new it,a=new it,o=new it,l=new it,c=new it,u=new it,d=new it,f=new it;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),y=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),o.fromBufferAttribute(n,g+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Ui.fromBufferAttribute(e,n),Ui.normalize(),e.setXYZ(n,Ui.x,Ui.y,Ui.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)g[x++]=u[p++]}return new mo(g,d,f)}if(this.index===null)return rn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new YZ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const zH=new gi,hh=new BO,d_=new h2,BH=new it,h_=new it,f_=new it,m_=new it,hC=new it,p_=new it,HH=new it,g_=new it;let kl=class extends Fs{constructor(e=new Ul,n=new HO){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){p_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(hC.fromBufferAttribute(f,e),o?p_.addScaledVector(hC,d):p_.addScaledVector(hC.sub(n),d))}n.add(p_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),d_.copy(r.boundingSphere),d_.applyMatrix4(a),hh.copy(e.ray).recast(e.near),!(d_.containsPoint(hh.origin)===!1&&(hh.intersectSphere(d_,BH)===null||hh.origin.distanceToSquared(BH)>(e.far-e.near)**2))&&(zH.copy(a).invert(),hh.copy(e.ray).applyMatrix4(zH),!(r.boundingBox!==null&&hh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,hh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,g=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let A=E,N=w;A<N;A+=3){const C=l.getX(A),T=l.getX(A+1),O=l.getX(A+2);i=x_(this,v,e,r,u,d,f,C,T,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=l.getX(b),w=l.getX(b+1),A=l.getX(b+2);i=x_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let A=E,N=w;A<N;A+=3){const C=A,T=A+1,O=A+2;i=x_(this,v,e,r,u,d,f,C,T,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=b,w=b+1,A=b+2;i=x_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}};function Gke(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===Rd,l),c===null)return null;g_.copy(l),g_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(g_);return u<n.near||u>n.far?null:{distance:u,point:g_.clone(),object:t}}function x_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,h_),t.getVertexPosition(c,f_),t.getVertexPosition(u,m_);const d=Gke(t,e,n,r,h_,f_,m_,HH);if(d){const f=new it;Ux.getBarycoord(HH,h_,f_,m_,f),i&&(d.uv=Ux.getInterpolatedAttribute(i,l,c,u,f,new xn)),a&&(d.uv1=Ux.getInterpolatedAttribute(a,l,c,u,f,new xn)),o&&(d.normal=Ux.getInterpolatedAttribute(o,l,c,u,f,new it),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const g={a:l,b:c,c:u,normal:new it,materialIndex:0};Ux.getNormal(h_,f_,m_,g.normal),d.face=g,d.barycoord=f}return d}let $O=class ZZ extends Ul{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Vo(u,3)),this.setAttribute("normal",new Vo(d,3)),this.setAttribute("uv",new Vo(f,2));function x(y,b,v,E,w,A,N,C,T,O,k){const R=A/T,z=N/O,D=A/2,K=N/2,P=C/2,W=T+1,Z=O+1;let G=0,Y=0;const X=new it;for(let q=0;q<Z;q++){const F=q*z-K;for(let V=0;V<W;V++){const te=V*R-D;X[y]=te*E,X[b]=F*w,X[v]=P,u.push(X.x,X.y,X.z),X[y]=0,X[b]=0,X[v]=C>0?1:-1,d.push(X.x,X.y,X.z),f.push(V/T),f.push(1-q/O),G+=1}}for(let q=0;q<O;q++)for(let F=0;F<T;F++){const V=g+F+W*q,te=g+F+W*(q+1),re=g+(F+1)+W*(q+1),ae=g+(F+1)+W*q;c.push(V,te,ae),c.push(te,re,ae),Y+=6}l.addGroup(p,Y,k),p+=Y,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ZZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Xp(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?(rn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function Ra(t){const e={};for(let n=0;n<t.length;n++){const r=Xp(t[n]);for(const i in r)e[i]=r[i]}return e}function Wke(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function QZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Bn.workingColorSpace}const qke={clone:Xp,merge:Ra};var Kke=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Xke=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let eu=class extends Ag{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Kke,this.fragmentShader=Xke,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=Xp(e.uniforms),this.uniformsGroups=Wke(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}},JZ=class extends Fs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new gi,this.projectionMatrix=new gi,this.projectionMatrixInverse=new gi,this.coordinateSystem=bl,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const Lu=new it,$H=new xn,VH=new xn;let ao=class extends JZ{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=iP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(R1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return iP*2*Math.atan(Math.tan(R1*.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){Lu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Lu.x,Lu.y).multiplyScalar(-e/Lu.z),Lu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Lu.x,Lu.y).multiplyScalar(-e/Lu.z)}getViewSize(e,n){return this.getViewBounds(e,$H,VH),n.subVectors(VH,$H)}setViewOffset(e,n,r,i,a,o){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(R1*.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 jm=-90,Pm=1;let Yke=class extends Fs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ao(jm,Pm,e,n);i.layers=this.layers,this.add(i);const a=new ao(jm,Pm,e,n);a.layers=this.layers,this.add(a);const o=new ao(jm,Pm,e,n);o.layers=this.layers,this.add(o);const l=new ao(jm,Pm,e,n);l.layers=this.layers,this.add(l);const c=new ao(jm,Pm,e,n);c.layers=this.layers,this.add(c);const u=new ao(jm,Pm,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===bl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===tS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},eQ=class extends Jo{constructor(e=[],n=Wp,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}},Zke=class extends wf{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 eQ(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 $O(5,5,5),a=new eu({name:"CubemapFromEquirect",uniforms:Xp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ss,blending:Fc});a.uniforms.tEquirect.value=n;const o=new kl(i,a),l=n.minFilter;return n.minFilter===Fh&&(n.minFilter=ho),new Yke(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)}},n0=class extends Fs{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Qke={type:"move"};let fC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new n0,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 n0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new it,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new it),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new n0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new it,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new it),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(Qke)))}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 n0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},Jke=class extends Fs{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Dd,this.environmentIntensity=1,this.environmentRotation=new Dd,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}},e3e=class extends Jo{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Ds,d=Ds,f,g){super(null,o,l,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const mC=new it,t3e=new it,n3e=new yn;let Xu=class{constructor(e=new it(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=mC.subVectors(r,n).cross(t3e.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(mC),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||n3e.getNormalMatrix(e),i=this.coplanarPoint(mC).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 fh=new h2,r3e=new xn(.5,.5),b_=new it;let VO=class{constructor(e=new Xu,n=new Xu,r=new Xu,i=new Xu,a=new Xu,o=new Xu){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=bl,r=!1){const i=this.planes,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],g=a[6],p=a[7],x=a[8],y=a[9],b=a[10],v=a[11],E=a[12],w=a[13],A=a[14],N=a[15];if(i[0].setComponents(u-o,p-d,v-x,N-E).normalize(),i[1].setComponents(u+o,p+d,v+x,N+E).normalize(),i[2].setComponents(u+l,p+f,v+y,N+w).normalize(),i[3].setComponents(u-l,p-f,v-y,N-w).normalize(),r)i[4].setComponents(c,g,b,A).normalize(),i[5].setComponents(u-c,p-g,v-b,N-A).normalize();else if(i[4].setComponents(u-c,p-g,v-b,N-A).normalize(),n===bl)i[5].setComponents(u+c,p+g,v+b,N+A).normalize();else if(n===tS)i[5].setComponents(c,g,b,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(),fh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),fh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(fh)}intersectsSprite(e){fh.center.set(0,0,0);const n=r3e.distanceTo(e.center);return fh.radius=.7071067811865476+n,fh.applyMatrix4(e.matrixWorld),this.intersectsSphere(fh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(b_.x=i.normal.x>0?e.max.x:e.min.x,b_.y=i.normal.y>0?e.max.y:e.min.y,b_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(b_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},tQ=class extends Ag{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Tn(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 rS=new it,iS=new it,GH=new gi,Bx=new BO,y_=new h2,pC=new it,WH=new it;let i3e=class extends Fs{constructor(e=new Ul,n=new tQ){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++)rS.fromBufferAttribute(n,i-1),iS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=rS.distanceTo(iS);e.setAttribute("lineDistance",new Vo(r,1))}else rn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),y_.copy(r.boundingSphere),y_.applyMatrix4(i),y_.radius+=a,e.ray.intersectsSphere(y_)===!1)return;GH.copy(i).invert(),Bx.copy(e.ray).applyMatrix4(GH);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,g=r.attributes.position;if(d!==null){const p=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let y=p,b=x-1;y<b;y+=u){const v=d.getX(y),E=d.getX(y+1),w=v_(this,e,Bx,c,v,E,y);w&&n.push(w)}if(this.isLineLoop){const y=d.getX(x-1),b=d.getX(p),v=v_(this,e,Bx,c,y,b,x-1);v&&n.push(v)}}else{const p=Math.max(0,o.start),x=Math.min(g.count,o.start+o.count);for(let y=p,b=x-1;y<b;y+=u){const v=v_(this,e,Bx,c,y,y+1,y);v&&n.push(v)}if(this.isLineLoop){const y=v_(this,e,Bx,c,x-1,p,x-1);y&&n.push(y)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function v_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(rS.fromBufferAttribute(l,i),iS.fromBufferAttribute(l,a),n.distanceSqToSegment(rS,iS,pC,WH)>r)return;pC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(pC);if(!(u<e.near||u>e.far))return{distance:u,point:WH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const qH=new it,KH=new it;let a3e=class extends i3e{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)qH.fromBufferAttribute(n,i),KH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+qH.distanceTo(KH);e.setAttribute("lineDistance",new Vo(r,1))}else rn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},nQ=class extends Jo{constructor(e,n,r=vf,i,a,o,l=Ds,c=Ds,u,d=cb,f=1){if(d!==cb&&d!==ub)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const g={width:e,height:n,depth:f};super(g,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new zO(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}};class rQ extends Jo{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let GO=class iQ extends Ul{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const E=v*g-o;for(let w=0;w<u;w++){const A=w*f-a;x.push(A,-E,0),y.push(0,0,1),b.push(w/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let E=0;E<l;E++){const w=E+u*v,A=E+u*(v+1),N=E+1+u*(v+1),C=E+1+u*v;p.push(w,A,C),p.push(A,N,C)}this.setIndex(p),this.setAttribute("position",new Vo(x,3)),this.setAttribute("normal",new Vo(y,3)),this.setAttribute("uv",new Vo(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new iQ(e.width,e.height,e.widthSegments,e.heightSegments)}};class s3e extends Ag{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Tn(16777215),this.specular=new Tn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Tn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=IZ,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Dd,this.combine=PO,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 o3e=class extends Ag{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=pke,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}},l3e=class extends Ag{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},aQ=class extends Fs{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Tn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const gC=new gi,XH=new it,YH=new it;let c3e=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xn(512,512),this.mapType=Cl,this.map=null,this.mapPass=null,this.matrix=new gi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new VO,this._frameExtents=new xn(1,1),this._viewportCount=1,this._viewports=[new hi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;XH.setFromMatrixPosition(e.matrixWorld),n.position.copy(XH),YH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(YH),n.updateMatrixWorld(),gC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(gC,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(gC)}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}},sQ=class extends JZ{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 u3e extends c3e{constructor(){super(new sQ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ZH extends aQ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Fs.DEFAULT_UP),this.updateMatrix(),this.target=new Fs,this.shadow=new u3e}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let d3e=class extends aQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},h3e=class extends ao{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},QH=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=An(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(An(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class f3e extends a3e{constructor(e=10,n=10,r=4473924,i=8947848){r=new Tn(r),i=new Tn(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let g=0,p=0,x=-l;g<=n;g++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const y=g===a?r:i;y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3,y.toArray(u,p),p+=3}const d=new Ul;d.setAttribute("position",new Vo(c,3)),d.setAttribute("color",new Vo(u,3));const f=new tQ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class m3e extends Df{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){rn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function JH(t,e,n,r){const i=p3e(r);switch(n){case DZ:return t*e;case LZ:return t*e/i.components*i.byteLength;case LO:return t*e/i.components*i.byteLength;case IO:return t*e*2/i.components*i.byteLength;case FO:return t*e*2/i.components*i.byteLength;case OZ:return t*e*3/i.components*i.byteLength;case Uo:return t*e*4/i.components*i.byteLength;case UO:return t*e*4/i.components*i.byteLength;case C1:case k1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case j1:case P1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case jj:case Rj:return Math.max(t,16)*Math.max(e,8)/4;case kj:case Pj:return Math.max(t,8)*Math.max(e,8)/2;case Dj:case Oj:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case Lj:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Ij:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Fj:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case Uj:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case zj:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case Bj:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case Hj:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case $j:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case Vj:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Gj:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case Wj:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case qj:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case Kj:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case Xj:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case Yj:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case Zj:case Qj:case Jj:return Math.ceil(t/4)*Math.ceil(e/4)*16;case eP:case tP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case nP:case rP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function p3e(t){switch(t){case Cl:case kZ:return{byteLength:1,components:1};case ob:case jZ:case Ng:return{byteLength:2,components:1};case DO:case OO:return{byteLength:2,components:4};case vf:case RO:case Pc:return{byteLength:4,components:1};case PZ:case RZ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:jO}}));typeof window<"u"&&(window.__THREE__?rn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jO);function oQ(){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 g3e(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,g=t.createBuffer();t.bindBuffer(c,g),t.bufferData(c,u,d),l.onUploadCallback();let p;if(u instanceof Float32Array)p=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)p=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?p=t.HALF_FLOAT:p=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)p=t.SHORT;else if(u instanceof Uint32Array)p=t.UNSIGNED_INT;else if(u instanceof Int32Array)p=t.INT;else if(u instanceof Int8Array)p=t.BYTE;else if(u instanceof Uint8Array)p=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)p=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:g,type:p,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((p,x)=>p.start-x.start);let g=0;for(let p=1;p<f.length;p++){const x=f[g],y=f[p];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++g,f[g]=y)}f.length=g+1;for(let p=0,x=f.length;p<x;p++){const y=f[p];t.bufferSubData(u,y.start*d.BYTES_PER_ELEMENT,d,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:a,update:o}}var x3e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,b3e=`#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`,y3e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,v3e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,_3e=`#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`,w3e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,S3e=`#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`,M3e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,E3e=`#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`,N3e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,A3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,T3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,C3e=`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`,k3e=`#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`,j3e=`#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`,P3e=`#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`,R3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,D3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,O3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,L3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,I3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,F3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,U3e=`#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`,z3e=`#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`,B3e=`#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`,H3e=`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`,$3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,V3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,G3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,W3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,q3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",K3e=`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 );
- }`,X3e=`#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`,Y3e=`#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`,Z3e=`#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`,Q3e=`#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`,J3e=`#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`,eje=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,tje=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,nje=`#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`,rje=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,ije=`#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
- }`,aje=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,sje=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,oje=`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`,lje=`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`,cje=`#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`,uje=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,dje=`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`,hje=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,fje=`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`,mje=`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_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.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`,pje=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- 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;
- #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 * 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 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 ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- 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;
- }
- 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 = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * 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.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * 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.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_Multiscatter( 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 );
- }`,gje=`
- 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.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`,xje=`#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`,bje=`#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`,yje=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,vje=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,_je=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,wje=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,Sje=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Mje=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,Eje=`#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`,Nje=`#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`,Aje=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,Tje=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,Cje=`#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`,kje=`#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`,jje=`#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`,Pje=`#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`,Rje=`#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`,Dje=`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;`,Oje=`#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`,Lje=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Ije=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Fje=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Uje=`#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`,zje=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Bje=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Hje=`#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`,$je=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Vje=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Gje=`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 );
- }`,Wje=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,qje=`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;`,Kje=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,Xje=`#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`,Yje=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Zje=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Qje=`#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 shadowIntensity;
- 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 shadowIntensity;
- 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 shadowIntensity;
- 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 ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- 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 );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- 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 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 ) {
- #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 mix( 1.0, shadow, shadowIntensity );
- }
- 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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- 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
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,Jje=`#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`,ePe=`#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`,tPe=`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
- 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;
- }`,nPe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,rPe=`#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`,iPe=`#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`,aPe=`#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`,sPe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,oPe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,lPe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,cPe=`#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; }`,uPe=`#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.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`,dPe=`#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`,hPe=`#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`,fPe=`#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`,mPe=`#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`,pPe=`#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 gPe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,xPe=`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>
- }`,bPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,yPe=`#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>
- }`,vPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,_Pe=`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>
- }`,wPe=`#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;
- }`,SPe=`#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
- }`,MPe=`#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;
- }`,EPe=`#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 () {
- 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 = packDepthToRGBA( dist );
- }`,NPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,APe=`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>
- }`,TPe=`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>
- }`,CPe=`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>
- }`,kPe=`#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>
- }`,jPe=`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>
- }`,PPe=`#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>
- }`,RPe=`#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() {
- 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>
- }`,DPe=`#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;
- }`,OPe=`#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>
- }`,LPe=`#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
- }`,IPe=`#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() {
- 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( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,FPe=`#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>
- }`,UPe=`#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() {
- 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>
- }`,zPe=`#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
- }`,BPe=`#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 <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() {
- 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
- 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>
- }`,HPe=`#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>
- }`,$Pe=`#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() {
- 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>
- }`,VPe=`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>
- }`,GPe=`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>
- }`,WPe=`#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>
- }`,qPe=`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>
- }`,KPe=`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>
- }`,XPe=`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>
- }`,pn={alphahash_fragment:x3e,alphahash_pars_fragment:b3e,alphamap_fragment:y3e,alphamap_pars_fragment:v3e,alphatest_fragment:_3e,alphatest_pars_fragment:w3e,aomap_fragment:S3e,aomap_pars_fragment:M3e,batching_pars_vertex:E3e,batching_vertex:N3e,begin_vertex:A3e,beginnormal_vertex:T3e,bsdfs:C3e,iridescence_fragment:k3e,bumpmap_pars_fragment:j3e,clipping_planes_fragment:P3e,clipping_planes_pars_fragment:R3e,clipping_planes_pars_vertex:D3e,clipping_planes_vertex:O3e,color_fragment:L3e,color_pars_fragment:I3e,color_pars_vertex:F3e,color_vertex:U3e,common:z3e,cube_uv_reflection_fragment:B3e,defaultnormal_vertex:H3e,displacementmap_pars_vertex:$3e,displacementmap_vertex:V3e,emissivemap_fragment:G3e,emissivemap_pars_fragment:W3e,colorspace_fragment:q3e,colorspace_pars_fragment:K3e,envmap_fragment:X3e,envmap_common_pars_fragment:Y3e,envmap_pars_fragment:Z3e,envmap_pars_vertex:Q3e,envmap_physical_pars_fragment:cje,envmap_vertex:J3e,fog_vertex:eje,fog_pars_vertex:tje,fog_fragment:nje,fog_pars_fragment:rje,gradientmap_pars_fragment:ije,lightmap_pars_fragment:aje,lights_lambert_fragment:sje,lights_lambert_pars_fragment:oje,lights_pars_begin:lje,lights_toon_fragment:uje,lights_toon_pars_fragment:dje,lights_phong_fragment:hje,lights_phong_pars_fragment:fje,lights_physical_fragment:mje,lights_physical_pars_fragment:pje,lights_fragment_begin:gje,lights_fragment_maps:xje,lights_fragment_end:bje,logdepthbuf_fragment:yje,logdepthbuf_pars_fragment:vje,logdepthbuf_pars_vertex:_je,logdepthbuf_vertex:wje,map_fragment:Sje,map_pars_fragment:Mje,map_particle_fragment:Eje,map_particle_pars_fragment:Nje,metalnessmap_fragment:Aje,metalnessmap_pars_fragment:Tje,morphinstance_vertex:Cje,morphcolor_vertex:kje,morphnormal_vertex:jje,morphtarget_pars_vertex:Pje,morphtarget_vertex:Rje,normal_fragment_begin:Dje,normal_fragment_maps:Oje,normal_pars_fragment:Lje,normal_pars_vertex:Ije,normal_vertex:Fje,normalmap_pars_fragment:Uje,clearcoat_normal_fragment_begin:zje,clearcoat_normal_fragment_maps:Bje,clearcoat_pars_fragment:Hje,iridescence_pars_fragment:$je,opaque_fragment:Vje,packing:Gje,premultiplied_alpha_fragment:Wje,project_vertex:qje,dithering_fragment:Kje,dithering_pars_fragment:Xje,roughnessmap_fragment:Yje,roughnessmap_pars_fragment:Zje,shadowmap_pars_fragment:Qje,shadowmap_pars_vertex:Jje,shadowmap_vertex:ePe,shadowmask_pars_fragment:tPe,skinbase_vertex:nPe,skinning_pars_vertex:rPe,skinning_vertex:iPe,skinnormal_vertex:aPe,specularmap_fragment:sPe,specularmap_pars_fragment:oPe,tonemapping_fragment:lPe,tonemapping_pars_fragment:cPe,transmission_fragment:uPe,transmission_pars_fragment:dPe,uv_pars_fragment:hPe,uv_pars_vertex:fPe,uv_vertex:mPe,worldpos_vertex:pPe,background_vert:gPe,background_frag:xPe,backgroundCube_vert:bPe,backgroundCube_frag:yPe,cube_vert:vPe,cube_frag:_Pe,depth_vert:wPe,depth_frag:SPe,distanceRGBA_vert:MPe,distanceRGBA_frag:EPe,equirect_vert:NPe,equirect_frag:APe,linedashed_vert:TPe,linedashed_frag:CPe,meshbasic_vert:kPe,meshbasic_frag:jPe,meshlambert_vert:PPe,meshlambert_frag:RPe,meshmatcap_vert:DPe,meshmatcap_frag:OPe,meshnormal_vert:LPe,meshnormal_frag:IPe,meshphong_vert:FPe,meshphong_frag:UPe,meshphysical_vert:zPe,meshphysical_frag:BPe,meshtoon_vert:HPe,meshtoon_frag:$Pe,points_vert:VPe,points_frag:GPe,shadow_vert:WPe,shadow_frag:qPe,sprite_vert:KPe,sprite_frag:XPe},kt={common:{diffuse:{value:new Tn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new yn},alphaMap:{value:null},alphaMapTransform:{value:new yn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new yn}},envmap:{envMap:{value:null},envMapRotation:{value:new yn},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 yn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new yn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new yn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new yn},normalScale:{value:new xn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new yn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new yn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new yn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new yn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Tn(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 Tn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new yn},alphaTest:{value:0},uvTransform:{value:new yn}},sprite:{diffuse:{value:new Tn(16777215)},opacity:{value:1},center:{value:new xn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new yn},alphaMap:{value:null},alphaMapTransform:{value:new yn},alphaTest:{value:0}}},fl={basic:{uniforms:Ra([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.fog]),vertexShader:pn.meshbasic_vert,fragmentShader:pn.meshbasic_frag},lambert:{uniforms:Ra([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)}}]),vertexShader:pn.meshlambert_vert,fragmentShader:pn.meshlambert_frag},phong:{uniforms:Ra([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)},specular:{value:new Tn(1118481)},shininess:{value:30}}]),vertexShader:pn.meshphong_vert,fragmentShader:pn.meshphong_frag},standard:{uniforms:Ra([kt.common,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.roughnessmap,kt.metalnessmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag},toon:{uniforms:Ra([kt.common,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.gradientmap,kt.fog,kt.lights,{emissive:{value:new Tn(0)}}]),vertexShader:pn.meshtoon_vert,fragmentShader:pn.meshtoon_frag},matcap:{uniforms:Ra([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,{matcap:{value:null}}]),vertexShader:pn.meshmatcap_vert,fragmentShader:pn.meshmatcap_frag},points:{uniforms:Ra([kt.points,kt.fog]),vertexShader:pn.points_vert,fragmentShader:pn.points_frag},dashed:{uniforms:Ra([kt.common,kt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:pn.linedashed_vert,fragmentShader:pn.linedashed_frag},depth:{uniforms:Ra([kt.common,kt.displacementmap]),vertexShader:pn.depth_vert,fragmentShader:pn.depth_frag},normal:{uniforms:Ra([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,{opacity:{value:1}}]),vertexShader:pn.meshnormal_vert,fragmentShader:pn.meshnormal_frag},sprite:{uniforms:Ra([kt.sprite,kt.fog]),vertexShader:pn.sprite_vert,fragmentShader:pn.sprite_frag},background:{uniforms:{uvTransform:{value:new yn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:pn.background_vert,fragmentShader:pn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new yn}},vertexShader:pn.backgroundCube_vert,fragmentShader:pn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:pn.cube_vert,fragmentShader:pn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:pn.equirect_vert,fragmentShader:pn.equirect_frag},distanceRGBA:{uniforms:Ra([kt.common,kt.displacementmap,{referencePosition:{value:new it},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:pn.distanceRGBA_vert,fragmentShader:pn.distanceRGBA_frag},shadow:{uniforms:Ra([kt.lights,kt.fog,{color:{value:new Tn(0)},opacity:{value:1}}]),vertexShader:pn.shadow_vert,fragmentShader:pn.shadow_frag}};fl.physical={uniforms:Ra([fl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new yn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new yn},clearcoatNormalScale:{value:new xn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new yn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new yn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new yn},sheen:{value:0},sheenColor:{value:new Tn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new yn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new yn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new yn},transmissionSamplerSize:{value:new xn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new yn},attenuationDistance:{value:0},attenuationColor:{value:new Tn(0)},specularColor:{value:new Tn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new yn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new yn},anisotropyVector:{value:new xn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new yn}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag};const __={r:0,b:0,g:0},mh=new Dd,YPe=new gi;function ZPe(t,e,n,r,i,a,o){const l=new Tn(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:e).get(A)),A}function y(w){let A=!1;const N=x(w);N===null?v(l,c):N&&N.isColor&&(v(N,1),A=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||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 b(w,A){const N=x(A);N&&(N.isCubeTexture||N.mapping===d2)?(d===void 0&&(d=new kl(new $O(1,1,1),new eu({name:"BackgroundCubeMaterial",uniforms:Xp(fl.backgroundCube.uniforms),vertexShader:fl.backgroundCube.vertexShader,fragmentShader:fl.backgroundCube.fragmentShader,side:ss,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,T,O){this.matrixWorld.copyPosition(O.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),mh.copy(A.backgroundRotation),mh.x*=-1,mh.y*=-1,mh.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(mh.y*=-1,mh.z*=-1),d.material.uniforms.envMap.value=N,d.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(YPe.makeRotationFromEuler(mh)),d.material.toneMapped=Bn.getTransfer(N.colorSpace)!==ar,(f!==N||g!==N.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=N,g=N.version,p=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new kl(new GO(2,2),new eu({name:"BackgroundMaterial",uniforms:Xp(fl.background.uniforms),vertexShader:fl.background.vertexShader,fragmentShader:fl.background.fragmentShader,side:Rd,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=N,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Bn.getTransfer(N.colorSpace)!==ar,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(f!==N||g!==N.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=N,g=N.version,p=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null))}function v(w,A){w.getRGB(__,QZ(t)),r.buffers.color.setClear(__.r,__.g,__.b,A,o)}function E(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return l},setClearColor:function(w,A=1){l.set(w),c=A,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,v(l,c)},render:y,addToRenderList:b,dispose:E}}function QPe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=g(null);let a=i,o=!1;function l(R,z,D,K,P){let W=!1;const Z=f(K,D,z);a!==Z&&(a=Z,u(a.object)),W=p(R,K,D,P),W&&x(R,K,D,P),P!==null&&e.update(P,t.ELEMENT_ARRAY_BUFFER),(W||o)&&(o=!1,A(R,z,D,K),P!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function c(){return t.createVertexArray()}function u(R){return t.bindVertexArray(R)}function d(R){return t.deleteVertexArray(R)}function f(R,z,D){const K=D.wireframe===!0;let P=r[R.id];P===void 0&&(P={},r[R.id]=P);let W=P[z.id];W===void 0&&(W={},P[z.id]=W);let Z=W[K];return Z===void 0&&(Z=g(c()),W[K]=Z),Z}function g(R){const z=[],D=[],K=[];for(let P=0;P<n;P++)z[P]=0,D[P]=0,K[P]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:D,attributeDivisors:K,object:R,attributes:{},index:null}}function p(R,z,D,K){const P=a.attributes,W=z.attributes;let Z=0;const G=D.getAttributes();for(const Y in G)if(G[Y].location>=0){const q=P[Y];let F=W[Y];if(F===void 0&&(Y==="instanceMatrix"&&R.instanceMatrix&&(F=R.instanceMatrix),Y==="instanceColor"&&R.instanceColor&&(F=R.instanceColor)),q===void 0||q.attribute!==F||F&&q.data!==F.data)return!0;Z++}return a.attributesNum!==Z||a.index!==K}function x(R,z,D,K){const P={},W=z.attributes;let Z=0;const G=D.getAttributes();for(const Y in G)if(G[Y].location>=0){let q=W[Y];q===void 0&&(Y==="instanceMatrix"&&R.instanceMatrix&&(q=R.instanceMatrix),Y==="instanceColor"&&R.instanceColor&&(q=R.instanceColor));const F={};F.attribute=q,q&&q.data&&(F.data=q.data),P[Y]=F,Z++}a.attributes=P,a.attributesNum=Z,a.index=K}function y(){const R=a.newAttributes;for(let z=0,D=R.length;z<D;z++)R[z]=0}function b(R){v(R,0)}function v(R,z){const D=a.newAttributes,K=a.enabledAttributes,P=a.attributeDivisors;D[R]=1,K[R]===0&&(t.enableVertexAttribArray(R),K[R]=1),P[R]!==z&&(t.vertexAttribDivisor(R,z),P[R]=z)}function E(){const R=a.newAttributes,z=a.enabledAttributes;for(let D=0,K=z.length;D<K;D++)z[D]!==R[D]&&(t.disableVertexAttribArray(D),z[D]=0)}function w(R,z,D,K,P,W,Z){Z===!0?t.vertexAttribIPointer(R,z,D,P,W):t.vertexAttribPointer(R,z,D,K,P,W)}function A(R,z,D,K){y();const P=K.attributes,W=D.getAttributes(),Z=z.defaultAttributeValues;for(const G in W){const Y=W[G];if(Y.location>=0){let X=P[G];if(X===void 0&&(G==="instanceMatrix"&&R.instanceMatrix&&(X=R.instanceMatrix),G==="instanceColor"&&R.instanceColor&&(X=R.instanceColor)),X!==void 0){const q=X.normalized,F=X.itemSize,V=e.get(X);if(V===void 0)continue;const te=V.buffer,re=V.type,ae=V.bytesPerElement,he=re===t.INT||re===t.UNSIGNED_INT||X.gpuType===RO;if(X.isInterleavedBufferAttribute){const ue=X.data,ce=ue.stride,fe=X.offset;if(ue.isInstancedInterleavedBuffer){for(let pe=0;pe<Y.locationSize;pe++)v(Y.location+pe,ue.meshPerAttribute);R.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let pe=0;pe<Y.locationSize;pe++)b(Y.location+pe);t.bindBuffer(t.ARRAY_BUFFER,te);for(let pe=0;pe<Y.locationSize;pe++)w(Y.location+pe,F/Y.locationSize,re,q,ce*ae,(fe+F/Y.locationSize*pe)*ae,he)}else{if(X.isInstancedBufferAttribute){for(let ue=0;ue<Y.locationSize;ue++)v(Y.location+ue,X.meshPerAttribute);R.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let ue=0;ue<Y.locationSize;ue++)b(Y.location+ue);t.bindBuffer(t.ARRAY_BUFFER,te);for(let ue=0;ue<Y.locationSize;ue++)w(Y.location+ue,F/Y.locationSize,re,q,F*ae,F/Y.locationSize*ue*ae,he)}}else if(Z!==void 0){const q=Z[G];if(q!==void 0)switch(q.length){case 2:t.vertexAttrib2fv(Y.location,q);break;case 3:t.vertexAttrib3fv(Y.location,q);break;case 4:t.vertexAttrib4fv(Y.location,q);break;default:t.vertexAttrib1fv(Y.location,q)}}}}E()}function N(){O();for(const R in r){const z=r[R];for(const D in z){const K=z[D];for(const P in K)d(K[P].object),delete K[P];delete z[D]}delete r[R]}}function C(R){if(r[R.id]===void 0)return;const z=r[R.id];for(const D in z){const K=z[D];for(const P in K)d(K[P].object),delete K[P];delete z[D]}delete r[R.id]}function T(R){for(const z in r){const D=r[z];if(D[R.id]===void 0)continue;const K=D[R.id];for(const P in K)d(K[P].object),delete K[P];delete D[R.id]}}function O(){k(),o=!0,a!==i&&(a=i,u(a.object))}function k(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:O,resetDefaultState:k,dispose:N,releaseStatesOfGeometry:C,releaseStatesOfProgram:T,initAttributes:y,enableAttribute:b,disableUnusedAttributes:E}}function JPe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let p=0;for(let x=0;x<f;x++)p+=d[x];n.update(p,r,1)}function c(u,d,f,g){if(f===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<u.length;x++)o(u[x],d[x],g[x]);else{p.multiDrawArraysInstancedWEBGL(r,u,0,d,0,g,0,f);let x=0;for(let y=0;y<f;y++)x+=d[y]*g[y];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function eRe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(T){return!(T!==Uo&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(T){const O=T===Ng&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==Cl&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Pc&&!O)}function c(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(rn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,g=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),p=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:g,maxTextures:p,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:N,maxSamples:C}}function tRe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Xu,l=new yn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const E=a?0:r,w=E*4;let A=v.clippingState||null;c.value=A,A=d(x,g,w,p);for(let N=0;N!==w;++N)A[N]=n[N];v.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=p+y*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(b===null||b.length<v)&&(b=new Float32Array(v));for(let w=0,A=p;w!==y;++w,A+=4)o.copy(f[w]).applyMatrix4(E,l),o.normal.toArray(b,A),b[A+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function nRe(t){let e=new WeakMap;function n(o,l){return l===Nj?o.mapping=Wp:l===Aj&&(o.mapping=qp),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===Nj||l===Aj)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 Zke(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 sd=4,e$=[.125,.215,.35,.446,.526,.582],Th=20,rRe=256,Hx=new sQ,t$=new Tn;let xC=null,bC=0,yC=0,vC=!1;const iRe=new it;let n$=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:o=256,position:l=iRe}=a;xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=a$(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=i$(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(xC,bC,yC),this._renderer.xr.enabled=vC,e.scissorTest=!1,Rm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Wp||e.mapping===qp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:ho,minFilter:ho,generateMipmaps:!1,type:Ng,format:Uo,colorSpace:Kp,depthBuffer:!1},i=r$(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=r$(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=aRe(a)),this._blurMaterial=oRe(a,e,n),this._ggxMaterial=sRe(a,e,n)}return i}_compileMaterial(e){const n=new kl(new Ul,e);this._renderer.compile(n,Hx)}_sceneToCubeUV(e,n,r,i,a){const c=new ao(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,g=f.autoClear,p=f.toneMapping;f.getClearColor(t$),f.toneMapping=pd,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new kl(new $O,new HO({name:"PMREM.Background",side:ss,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,b=y.material;let v=!1;const E=e.background;E?E.isColor&&(b.color.copy(E),e.background=null,v=!0):(b.color.copy(t$),v=!0);for(let w=0;w<6;w++){const A=w%3;A===0?(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[w],a.y,a.z)):A===1?(c.up.set(0,0,u[w]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[w],a.z)):(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[w]));const N=this._cubeSize;Rm(i,A*N,w>2?N:0,N,N),f.setRenderTarget(i),v&&f.render(y,c),f.render(e,c)}f.toneMapping=p,f.autoClear=g,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Wp||e.mapping===qp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=a$()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=i$());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Rm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Hx)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),g=.05+u*.95,p=f*g,{_lodMax:x}=this,y=this._sizeLods[r],b=3*y*(r>x-sd?r-x+sd:0),v=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=x-n,Rm(a,b,v,3*y,2*y),i.setRenderTarget(a),i.render(l,Hx),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,Rm(e,b,v,3*y,2*y),i.setRenderTarget(e),i.render(l,Hx)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&ti("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*Th-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):Th;b>Th&&rn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Th}`);const v=[];let E=0;for(let T=0;T<Th;++T){const O=T/y,k=Math.exp(-O*O/2);v.push(k),T===0?E+=k:T<b&&(E+=2*k)}for(let T=0;T<v.length;T++)v[T]=v[T]/E;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=v,g.latitudinal.value=o==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],N=3*A*(i>w-sd?i-w+sd:0),C=4*(this._cubeSize-A);Rm(n,N,C,3*A,2*A),c.setRenderTarget(n),c.render(f,Hx)}};function aRe(t){const e=[],n=[],r=[];let i=t;const a=t-sd+1+e$.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-sd?c=e$[o-t+sd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,y=3,b=2,v=1,E=new Float32Array(y*x*p),w=new Float32Array(b*x*p),A=new Float32Array(v*x*p);for(let C=0;C<p;C++){const T=C%3*2/3-1,O=C>2?0:-1,k=[T,O,0,T+2/3,O,0,T+2/3,O+1,0,T,O,0,T+2/3,O+1,0,T,O+1,0];E.set(k,y*x*C),w.set(g,b*x*C);const R=[C,C,C,C,C,C];A.set(R,v*x*C)}const N=new Ul;N.setAttribute("position",new mo(E,y)),N.setAttribute("uv",new mo(w,b)),N.setAttribute("faceIndex",new mo(A,v)),r.push(new kl(N,null)),i>sd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function r$(t,e,n){const r=new wf(t,e,n);return r.texture.mapping=d2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Rm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function sRe(t,e,n){return new eu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:rRe,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:f2(),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:Fc,depthTest:!1,depthWrite:!1})}function oRe(t,e,n){const r=new Float32Array(Th),i=new it(0,1,0);return new eu({name:"SphericalGaussianBlur",defines:{n:Th,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:f2(),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:Fc,depthTest:!1,depthWrite:!1})}function i$(){return new eu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:f2(),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:Fc,depthTest:!1,depthWrite:!1})}function a$(){return new eu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:f2(),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:Fc,depthTest:!1,depthWrite:!1})}function f2(){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 lRe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===Nj||c===Aj,d=c===Wp||c===qp;if(u||d){let f=e.get(l);const g=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==g)return n===null&&(n=new n$(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const p=l.image;return u&&p&&p.height>0||d&&p&&i(p)?(n===null&&(n=new n$(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function cRe(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&&db("WebGLRenderer: "+r+" extension not supported."),i}}}function uRe(t,e,n,r){const i={},a=new WeakMap;function o(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);g.removeEventListener("dispose",o),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function l(f,g){return i[g.id]===!0||(g.addEventListener("dispose",o),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const p in g)e.update(g[p],t.ARRAY_BUFFER)}function u(f){const g=[],p=f.index,x=f.attributes.position;let y=0;if(p!==null){const E=p.array;y=p.version;for(let w=0,A=E.length;w<A;w+=3){const N=E[w+0],C=E[w+1],T=E[w+2];g.push(N,C,C,T,T,N)}}else if(x!==void 0){const E=x.array;y=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const N=w+0,C=w+1,T=w+2;g.push(N,C,C,T,T,N)}}else return;const b=new(UZ(g)?XZ:KZ)(g,1);b.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,b)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function dRe(t,e,n){let r;function i(g){r=g}let a,o;function l(g){a=g.type,o=g.bytesPerElement}function c(g,p){t.drawElements(r,p,a,g*o),n.update(p,r,1)}function u(g,p,x){x!==0&&(t.drawElementsInstanced(r,p,a,g*o,x),n.update(p,r,x))}function d(g,p,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,p,0,a,g,0,x);let b=0;for(let v=0;v<x;v++)b+=p[v];n.update(b,r,1)}function f(g,p,x,y){if(x===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<g.length;v++)u(g[v]/o,p[v],y[v]);else{b.multiDrawElementsInstancedWEBGL(r,p,0,a,g,0,y,0,x);let v=0;for(let E=0;E<x;E++)v+=p[E]*y[E];n.update(v,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function hRe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:ti("WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function fRe(t,e,n){const r=new WeakMap,i=new hi;function a(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let g=r.get(l);if(g===void 0||g.count!==f){let R=function(){O.dispose(),r.delete(l),l.removeEventListener("dispose",R)};var p=R;g!==void 0&&g.texture.dispose();const x=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,b=l.morphAttributes.color!==void 0,v=l.morphAttributes.position||[],E=l.morphAttributes.normal||[],w=l.morphAttributes.color||[];let A=0;x===!0&&(A=1),y===!0&&(A=2),b===!0&&(A=3);let N=l.attributes.position.count*A,C=1;N>e.maxTextureSize&&(C=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);const T=new Float32Array(N*C*4*f),O=new VZ(T,N,C,f);O.type=Pc,O.needsUpdate=!0;const k=A*4;for(let z=0;z<f;z++){const D=v[z],K=E[z],P=w[z],W=N*C*4*z;for(let Z=0;Z<D.count;Z++){const G=Z*k;x===!0&&(i.fromBufferAttribute(D,Z),T[W+G+0]=i.x,T[W+G+1]=i.y,T[W+G+2]=i.z,T[W+G+3]=0),y===!0&&(i.fromBufferAttribute(K,Z),T[W+G+4]=i.x,T[W+G+5]=i.y,T[W+G+6]=i.z,T[W+G+7]=0),b===!0&&(i.fromBufferAttribute(P,Z),T[W+G+8]=i.x,T[W+G+9]=i.y,T[W+G+10]=i.z,T[W+G+11]=P.itemSize===4?i.w:1)}}g={count:f,texture:O,size:new xn(N,C)},r.set(l,g),l.addEventListener("dispose",R)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let b=0;b<u.length;b++)x+=u[b];const y=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",g.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",g.size)}return{update:a}}function mRe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}const lQ=new Jo,s$=new nQ(1,1),cQ=new VZ,uQ=new Dke,dQ=new eQ,o$=[],l$=[],c$=new Float32Array(16),u$=new Float32Array(9),d$=new Float32Array(4);function Tg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=o$[i];if(a===void 0&&(a=new Float32Array(i),o$[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ni(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 Ai(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function m2(t,e){let n=l$[e];n===void 0&&(n=new Int32Array(e),l$[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function pRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function gRe(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(Ni(n,e))return;t.uniform2fv(this.addr,e),Ai(n,e)}}function xRe(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(Ni(n,e))return;t.uniform3fv(this.addr,e),Ai(n,e)}}function bRe(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(Ni(n,e))return;t.uniform4fv(this.addr,e),Ai(n,e)}}function yRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ni(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ai(n,e)}else{if(Ni(n,r))return;d$.set(r),t.uniformMatrix2fv(this.addr,!1,d$),Ai(n,r)}}function vRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ni(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ai(n,e)}else{if(Ni(n,r))return;u$.set(r),t.uniformMatrix3fv(this.addr,!1,u$),Ai(n,r)}}function _Re(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ni(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ai(n,e)}else{if(Ni(n,r))return;c$.set(r),t.uniformMatrix4fv(this.addr,!1,c$),Ai(n,r)}}function wRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function SRe(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(Ni(n,e))return;t.uniform2iv(this.addr,e),Ai(n,e)}}function MRe(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(Ni(n,e))return;t.uniform3iv(this.addr,e),Ai(n,e)}}function ERe(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(Ni(n,e))return;t.uniform4iv(this.addr,e),Ai(n,e)}}function NRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function ARe(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(Ni(n,e))return;t.uniform2uiv(this.addr,e),Ai(n,e)}}function TRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Ni(n,e))return;t.uniform3uiv(this.addr,e),Ai(n,e)}}function CRe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.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(Ni(n,e))return;t.uniform4uiv(this.addr,e),Ai(n,e)}}function kRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(s$.compareFunction=FZ,a=s$):a=lQ,n.setTexture2D(e||a,i)}function jRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||uQ,i)}function PRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||dQ,i)}function RRe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||cQ,i)}function DRe(t){switch(t){case 5126:return pRe;case 35664:return gRe;case 35665:return xRe;case 35666:return bRe;case 35674:return yRe;case 35675:return vRe;case 35676:return _Re;case 5124:case 35670:return wRe;case 35667:case 35671:return SRe;case 35668:case 35672:return MRe;case 35669:case 35673:return ERe;case 5125:return NRe;case 36294:return ARe;case 36295:return TRe;case 36296:return CRe;case 35678:case 36198:case 36298:case 36306:case 35682:return kRe;case 35679:case 36299:case 36307:return jRe;case 35680:case 36300:case 36308:case 36293:return PRe;case 36289:case 36303:case 36311:case 36292:return RRe}}function ORe(t,e){t.uniform1fv(this.addr,e)}function LRe(t,e){const n=Tg(e,this.size,2);t.uniform2fv(this.addr,n)}function IRe(t,e){const n=Tg(e,this.size,3);t.uniform3fv(this.addr,n)}function FRe(t,e){const n=Tg(e,this.size,4);t.uniform4fv(this.addr,n)}function URe(t,e){const n=Tg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function zRe(t,e){const n=Tg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function BRe(t,e){const n=Tg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function HRe(t,e){t.uniform1iv(this.addr,e)}function $Re(t,e){t.uniform2iv(this.addr,e)}function VRe(t,e){t.uniform3iv(this.addr,e)}function GRe(t,e){t.uniform4iv(this.addr,e)}function WRe(t,e){t.uniform1uiv(this.addr,e)}function qRe(t,e){t.uniform2uiv(this.addr,e)}function KRe(t,e){t.uniform3uiv(this.addr,e)}function XRe(t,e){t.uniform4uiv(this.addr,e)}function YRe(t,e,n){const r=this.cache,i=e.length,a=m2(n,i);Ni(r,a)||(t.uniform1iv(this.addr,a),Ai(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||lQ,a[o])}function ZRe(t,e,n){const r=this.cache,i=e.length,a=m2(n,i);Ni(r,a)||(t.uniform1iv(this.addr,a),Ai(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||uQ,a[o])}function QRe(t,e,n){const r=this.cache,i=e.length,a=m2(n,i);Ni(r,a)||(t.uniform1iv(this.addr,a),Ai(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||dQ,a[o])}function JRe(t,e,n){const r=this.cache,i=e.length,a=m2(n,i);Ni(r,a)||(t.uniform1iv(this.addr,a),Ai(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||cQ,a[o])}function eDe(t){switch(t){case 5126:return ORe;case 35664:return LRe;case 35665:return IRe;case 35666:return FRe;case 35674:return URe;case 35675:return zRe;case 35676:return BRe;case 5124:case 35670:return HRe;case 35667:case 35671:return $Re;case 35668:case 35672:return VRe;case 35669:case 35673:return GRe;case 5125:return WRe;case 36294:return qRe;case 36295:return KRe;case 36296:return XRe;case 35678:case 36198:case 36298:case 36306:case 35682:return YRe;case 35679:case 36299:case 36307:return ZRe;case 35680:case 36300:case 36308:case 36293:return QRe;case 36289:case 36303:case 36311:case 36292:return JRe}}let tDe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=DRe(n.type)}},nDe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=eDe(n.type)}},rDe=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 _C=/(\w+)(\])?(\[|\.)?/g;function h$(t,e){t.seq.push(e),t.map[e.id]=e}function iDe(t,e,n){const r=t.name,i=r.length;for(_C.lastIndex=0;;){const a=_C.exec(r),o=_C.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){h$(n,u===void 0?new tDe(l,t,e):new nDe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new rDe(l),h$(n,f)),n=f}}}let L1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);iDe(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function f$(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const aDe=37297;let sDe=0;function oDe(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 m$=new yn;function lDe(t){Bn._getMatrix(m$,Bn.workingColorSpace,t);const e=`mat3( ${m$.elements.map(n=>n.toFixed(4))} )`;switch(Bn.getTransfer(t)){case eS:return[e,"LinearTransferOETF"];case ar:return[e,"sRGBTransferOETF"];default:return rn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function p$(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+a+`
- `+oDe(t.getShaderSource(e),l)}else return a}function cDe(t,e){const n=lDe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function uDe(t,e){let n;switch(e){case oke:n="Linear";break;case lke:n="Reinhard";break;case cke:n="Cineon";break;case uke:n="ACESFilmic";break;case hke:n="AgX";break;case fke:n="Neutral";break;case dke:n="Custom";break;default:rn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const w_=new it;function dDe(){Bn.getLuminanceCoefficients(w_);const t=w_.x.toFixed(4),e=w_.y.toFixed(4),n=w_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function hDe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(r0).join(`
- `)}function fDe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function mDe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function r0(t){return t!==""}function g$(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function x$(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const pDe=/^[ \t]*#include +<([\w\d./]+)>/gm;function sP(t){return t.replace(pDe,xDe)}const gDe=new Map;function xDe(t,e){let n=pn[e];if(n===void 0){const r=gDe.get(e);if(r!==void 0)n=pn[r],rn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return sP(n)}const bDe=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function b$(t){return t.replace(bDe,yDe)}function yDe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function y$(t){let e=`precision ${t.precision} float;
- 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}function vDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===TZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===zCe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===bc&&(e="SHADOWMAP_TYPE_VSM"),e}function _De(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Wp:case qp:e="ENVMAP_TYPE_CUBE";break;case d2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function wDe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case qp:e="ENVMAP_MODE_REFRACTION";break}return e}function SDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case PO:e="ENVMAP_BLENDING_MULTIPLY";break;case ake:e="ENVMAP_BLENDING_MIX";break;case ske:e="ENVMAP_BLENDING_ADD";break}return e}function MDe(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 EDe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=vDe(n),u=_De(n),d=wDe(n),f=SDe(n),g=MDe(n),p=hDe(n),x=fDe(a),y=i.createProgram();let b,v,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(r0).join(`
- `),b.length>0&&(b+=`
- `),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(r0).join(`
- `),v.length>0&&(v+=`
- `)):(b=[y$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(r0).join(`
- `),v=[y$(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==pd?"#define TONE_MAPPING":"",n.toneMapping!==pd?pn.tonemapping_pars_fragment:"",n.toneMapping!==pd?uDe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",pn.colorspace_pars_fragment,cDe("linearToOutputTexel",n.outputColorSpace),dDe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(r0).join(`
- `)),o=sP(o),o=g$(o,n),o=x$(o,n),l=sP(l),l=g$(l,n),l=x$(l,n),o=b$(o),l=b$(l),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,b=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+b,v=["#define varying in",n.glslVersion===NH?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===NH?"":"#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 w=E+b+o,A=E+v+l,N=f$(i,i.VERTEX_SHADER,w),C=f$(i,i.FRAGMENT_SHADER,A);i.attachShader(y,N),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function T(z){if(t.debug.checkShaderErrors){const D=i.getProgramInfoLog(y)||"",K=i.getShaderInfoLog(N)||"",P=i.getShaderInfoLog(C)||"",W=D.trim(),Z=K.trim(),G=P.trim();let Y=!0,X=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(Y=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,N,C);else{const q=p$(i,N,"vertex"),F=p$(i,C,"fragment");ti("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Material Name: `+z.name+`
- Material Type: `+z.type+`
- Program Info Log: `+W+`
- `+q+`
- `+F)}else W!==""?rn("WebGLProgram: Program Info Log:",W):(Z===""||G==="")&&(X=!1);X&&(z.diagnostics={runnable:Y,programLog:W,vertexShader:{log:Z,prefix:b},fragmentShader:{log:G,prefix:v}})}i.deleteShader(N),i.deleteShader(C),O=new L1(i,y),k=mDe(i,y)}let O;this.getUniforms=function(){return O===void 0&&T(this),O};let k;this.getAttributes=function(){return k===void 0&&T(this),k};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,aDe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=sDe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=N,this.fragmentShader=C,this}let NDe=0,ADe=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 TDe(e),n.set(e,r)),r}},TDe=class{constructor(e){this.id=NDe++,this.code=e,this.usedTimes=0}};function CDe(t,e,n,r,i,a,o){const l=new WZ,c=new ADe,u=new Set,d=[],f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(k){return u.add(k),k===0?"uv":`uv${k}`}function b(k,R,z,D,K){const P=D.fog,W=K.geometry,Z=k.isMeshStandardMaterial?D.environment:null,G=(k.isMeshStandardMaterial?n:e).get(k.envMap||Z),Y=G&&G.mapping===d2?G.image.height:null,X=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&rn("WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,F=q!==void 0?q.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 te,re,ae,he;if(X){const St=fl[X];te=St.vertexShader,re=St.fragmentShader}else te=k.vertexShader,re=k.fragmentShader,c.update(k),ae=c.getVertexShaderID(k),he=c.getFragmentShaderID(k);const ue=t.getRenderTarget(),ce=t.state.buffers.depth.getReversed(),fe=K.isInstancedMesh===!0,pe=K.isBatchedMesh===!0,_e=!!k.map,ne=!!k.matcap,He=!!G,B=!!k.aoMap,H=!!k.lightMap,le=!!k.bumpMap,$=!!k.normalMap,ee=!!k.displacementMap,de=!!k.emissiveMap,ke=!!k.metalnessMap,we=!!k.roughnessMap,Ee=k.anisotropy>0,U=k.clearcoat>0,I=k.dispersion>0,se=k.iridescence>0,ye=k.sheen>0,Se=k.transmission>0,ve=Ee&&!!k.anisotropyMap,Be=U&&!!k.clearcoatMap,Ge=U&&!!k.clearcoatNormalMap,Ke=U&&!!k.clearcoatRoughnessMap,ct=se&&!!k.iridescenceMap,$e=se&&!!k.iridescenceThicknessMap,ge=ye&&!!k.sheenColorMap,Je=ye&&!!k.sheenRoughnessMap,qe=!!k.specularMap,Ze=!!k.specularColorMap,lt=!!k.specularIntensityMap,ie=Se&&!!k.transmissionMap,Ie=Se&&!!k.thicknessMap,xe=!!k.gradientMap,Ue=!!k.alphaMap,Pe=k.alphaTest>0,Me=!!k.alphaHash,Xe=!!k.extensions;let ut=pd;k.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(ut=t.toneMapping);const At={shaderID:X,shaderType:k.type,shaderName:k.name,vertexShader:te,fragmentShader:re,defines:k.defines,customVertexShaderID:ae,customFragmentShaderID:he,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:pe,batchingColor:pe&&K._colorsTexture!==null,instancing:fe,instancingColor:fe&&K.instanceColor!==null,instancingMorph:fe&&K.morphTexture!==null,supportsVertexTextures:g,outputColorSpace:ue===null?t.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:Kp,alphaToCoverage:!!k.alphaToCoverage,map:_e,matcap:ne,envMap:He,envMapMode:He&&G.mapping,envMapCubeUVHeight:Y,aoMap:B,lightMap:H,bumpMap:le,normalMap:$,displacementMap:g&&ee,emissiveMap:de,normalMapObjectSpace:$&&k.normalMapType===xke,normalMapTangentSpace:$&&k.normalMapType===IZ,metalnessMap:ke,roughnessMap:we,anisotropy:Ee,anisotropyMap:ve,clearcoat:U,clearcoatMap:Be,clearcoatNormalMap:Ge,clearcoatRoughnessMap:Ke,dispersion:I,iridescence:se,iridescenceMap:ct,iridescenceThicknessMap:$e,sheen:ye,sheenColorMap:ge,sheenRoughnessMap:Je,specularMap:qe,specularColorMap:Ze,specularIntensityMap:lt,transmission:Se,transmissionMap:ie,thicknessMap:Ie,gradientMap:xe,opaque:k.transparent===!1&&k.blending===wp&&k.alphaToCoverage===!1,alphaMap:Ue,alphaTest:Pe,alphaHash:Me,combine:k.combine,mapUv:_e&&y(k.map.channel),aoMapUv:B&&y(k.aoMap.channel),lightMapUv:H&&y(k.lightMap.channel),bumpMapUv:le&&y(k.bumpMap.channel),normalMapUv:$&&y(k.normalMap.channel),displacementMapUv:ee&&y(k.displacementMap.channel),emissiveMapUv:de&&y(k.emissiveMap.channel),metalnessMapUv:ke&&y(k.metalnessMap.channel),roughnessMapUv:we&&y(k.roughnessMap.channel),anisotropyMapUv:ve&&y(k.anisotropyMap.channel),clearcoatMapUv:Be&&y(k.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&y(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ke&&y(k.clearcoatRoughnessMap.channel),iridescenceMapUv:ct&&y(k.iridescenceMap.channel),iridescenceThicknessMapUv:$e&&y(k.iridescenceThicknessMap.channel),sheenColorMapUv:ge&&y(k.sheenColorMap.channel),sheenRoughnessMapUv:Je&&y(k.sheenRoughnessMap.channel),specularMapUv:qe&&y(k.specularMap.channel),specularColorMapUv:Ze&&y(k.specularColorMap.channel),specularIntensityMapUv:lt&&y(k.specularIntensityMap.channel),transmissionMapUv:ie&&y(k.transmissionMap.channel),thicknessMapUv:Ie&&y(k.thicknessMap.channel),alphaMapUv:Ue&&y(k.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&($||Ee),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,pointsUvs:K.isPoints===!0&&!!W.attributes.uv&&(_e||Ue),fog:!!P,useFog:k.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:k.flatShading===!0&&k.wireframe===!1,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:ce,skinning:K.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:F,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:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:ut,decodeVideoTexture:_e&&k.map.isVideoTexture===!0&&Bn.getTransfer(k.map.colorSpace)===ar,decodeVideoTextureEmissive:de&&k.emissiveMap.isVideoTexture===!0&&Bn.getTransfer(k.emissiveMap.colorSpace)===ar,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===ml,flipSided:k.side===ss,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Xe&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Xe&&k.extensions.multiDraw===!0||pe)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return At.vertexUv1s=u.has(1),At.vertexUv2s=u.has(2),At.vertexUv3s=u.has(3),u.clear(),At}function v(k){const R=[];if(k.shaderID?R.push(k.shaderID):(R.push(k.customVertexShaderID),R.push(k.customFragmentShaderID)),k.defines!==void 0)for(const z in k.defines)R.push(z),R.push(k.defines[z]);return k.isRawShaderMaterial===!1&&(E(R,k),w(R,k),R.push(t.outputColorSpace)),R.push(k.customProgramCacheKey),R.join()}function E(k,R){k.push(R.precision),k.push(R.outputColorSpace),k.push(R.envMapMode),k.push(R.envMapCubeUVHeight),k.push(R.mapUv),k.push(R.alphaMapUv),k.push(R.lightMapUv),k.push(R.aoMapUv),k.push(R.bumpMapUv),k.push(R.normalMapUv),k.push(R.displacementMapUv),k.push(R.emissiveMapUv),k.push(R.metalnessMapUv),k.push(R.roughnessMapUv),k.push(R.anisotropyMapUv),k.push(R.clearcoatMapUv),k.push(R.clearcoatNormalMapUv),k.push(R.clearcoatRoughnessMapUv),k.push(R.iridescenceMapUv),k.push(R.iridescenceThicknessMapUv),k.push(R.sheenColorMapUv),k.push(R.sheenRoughnessMapUv),k.push(R.specularMapUv),k.push(R.specularColorMapUv),k.push(R.specularIntensityMapUv),k.push(R.transmissionMapUv),k.push(R.thicknessMapUv),k.push(R.combine),k.push(R.fogExp2),k.push(R.sizeAttenuation),k.push(R.morphTargetsCount),k.push(R.morphAttributeCount),k.push(R.numDirLights),k.push(R.numPointLights),k.push(R.numSpotLights),k.push(R.numSpotLightMaps),k.push(R.numHemiLights),k.push(R.numRectAreaLights),k.push(R.numDirLightShadows),k.push(R.numPointLightShadows),k.push(R.numSpotLightShadows),k.push(R.numSpotLightShadowsWithMaps),k.push(R.numLightProbes),k.push(R.shadowMapType),k.push(R.toneMapping),k.push(R.numClippingPlanes),k.push(R.numClipIntersection),k.push(R.depthPacking)}function w(k,R){l.disableAll(),R.supportsVertexTextures&&l.enable(0),R.instancing&&l.enable(1),R.instancingColor&&l.enable(2),R.instancingMorph&&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),R.dispersion&&l.enable(20),R.batchingColor&&l.enable(21),R.gradientMap&&l.enable(22),k.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),k.push(l.mask)}function A(k){const R=x[k.type];let z;if(R){const D=fl[R];z=qke.clone(D.uniforms)}else z=k.uniforms;return z}function N(k,R){let z;for(let D=0,K=d.length;D<K;D++){const P=d[D];if(P.cacheKey===R){z=P,++z.usedTimes;break}}return z===void 0&&(z=new EDe(t,R,k,a),d.push(z)),z}function C(k){if(--k.usedTimes===0){const R=d.indexOf(k);d[R]=d[d.length-1],d.pop(),k.destroy()}}function T(k){c.remove(k)}function O(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:A,acquireProgram:N,releaseProgram:C,releaseShaderCache:T,programs:d,dispose:O}}function kDe(){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 jDe(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function v$(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function _$(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,g,p,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=g,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,g){n.length>1&&n.sort(f||jDe),r.length>1&&r.sort(g||v$),i.length>1&&i.sort(g||v$)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function PDe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new _$,t.set(r,[o])):i>=a.length?(o=new _$,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function RDe(){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 it,color:new Tn};break;case"SpotLight":n={position:new it,direction:new it,color:new Tn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new it,color:new Tn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new it,skyColor:new Tn,groundColor:new Tn};break;case"RectAreaLight":n={color:new Tn,position:new it,halfWidth:new it,halfHeight:new it};break}return t[e.id]=n,n}}}function DDe(){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 xn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let ODe=0;function LDe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function IDe(t){const e=new RDe,n=DDe(),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 it);const i=new it,a=new gi,o=new gi;function l(u){let d=0,f=0,g=0;for(let k=0;k<9;k++)r.probe[k].set(0,0,0);let p=0,x=0,y=0,b=0,v=0,E=0,w=0,A=0,N=0,C=0,T=0;u.sort(LDe);for(let k=0,R=u.length;k<R;k++){const z=u[k],D=z.color,K=z.intensity,P=z.distance,W=z.shadow&&z.shadow.map?z.shadow.map.texture:null;if(z.isAmbientLight)d+=D.r*K,f+=D.g*K,g+=D.b*K;else if(z.isLightProbe){for(let Z=0;Z<9;Z++)r.probe[Z].addScaledVector(z.sh.coefficients[Z],K);T++}else if(z.isDirectionalLight){const Z=e.get(z);if(Z.color.copy(z.color).multiplyScalar(z.intensity),z.castShadow){const G=z.shadow,Y=n.get(z);Y.shadowIntensity=G.intensity,Y.shadowBias=G.bias,Y.shadowNormalBias=G.normalBias,Y.shadowRadius=G.radius,Y.shadowMapSize=G.mapSize,r.directionalShadow[p]=Y,r.directionalShadowMap[p]=W,r.directionalShadowMatrix[p]=z.shadow.matrix,E++}r.directional[p]=Z,p++}else if(z.isSpotLight){const Z=e.get(z);Z.position.setFromMatrixPosition(z.matrixWorld),Z.color.copy(D).multiplyScalar(K),Z.distance=P,Z.coneCos=Math.cos(z.angle),Z.penumbraCos=Math.cos(z.angle*(1-z.penumbra)),Z.decay=z.decay,r.spot[y]=Z;const G=z.shadow;if(z.map&&(r.spotLightMap[N]=z.map,N++,G.updateMatrices(z),z.castShadow&&C++),r.spotLightMatrix[y]=G.matrix,z.castShadow){const Y=n.get(z);Y.shadowIntensity=G.intensity,Y.shadowBias=G.bias,Y.shadowNormalBias=G.normalBias,Y.shadowRadius=G.radius,Y.shadowMapSize=G.mapSize,r.spotShadow[y]=Y,r.spotShadowMap[y]=W,A++}y++}else if(z.isRectAreaLight){const Z=e.get(z);Z.color.copy(D).multiplyScalar(K),Z.halfWidth.set(z.width*.5,0,0),Z.halfHeight.set(0,z.height*.5,0),r.rectArea[b]=Z,b++}else if(z.isPointLight){const Z=e.get(z);if(Z.color.copy(z.color).multiplyScalar(z.intensity),Z.distance=z.distance,Z.decay=z.decay,z.castShadow){const G=z.shadow,Y=n.get(z);Y.shadowIntensity=G.intensity,Y.shadowBias=G.bias,Y.shadowNormalBias=G.normalBias,Y.shadowRadius=G.radius,Y.shadowMapSize=G.mapSize,Y.shadowCameraNear=G.camera.near,Y.shadowCameraFar=G.camera.far,r.pointShadow[x]=Y,r.pointShadowMap[x]=W,r.pointShadowMatrix[x]=z.shadow.matrix,w++}r.point[x]=Z,x++}else if(z.isHemisphereLight){const Z=e.get(z);Z.skyColor.copy(z.color).multiplyScalar(K),Z.groundColor.copy(z.groundColor).multiplyScalar(K),r.hemi[v]=Z,v++}}b>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=kt.LTC_FLOAT_1,r.rectAreaLTC2=kt.LTC_FLOAT_2):(r.rectAreaLTC1=kt.LTC_HALF_1,r.rectAreaLTC2=kt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=g;const O=r.hash;(O.directionalLength!==p||O.pointLength!==x||O.spotLength!==y||O.rectAreaLength!==b||O.hemiLength!==v||O.numDirectionalShadows!==E||O.numPointShadows!==w||O.numSpotShadows!==A||O.numSpotMaps!==N||O.numLightProbes!==T)&&(r.directional.length=p,r.spot.length=y,r.rectArea.length=b,r.point.length=x,r.hemi.length=v,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=A+N-C,r.spotLightMap.length=N,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=T,O.directionalLength=p,O.pointLength=x,O.spotLength=y,O.rectAreaLength=b,O.hemiLength=v,O.numDirectionalShadows=E,O.numPointShadows=w,O.numSpotShadows=A,O.numSpotMaps=N,O.numLightProbes=T,r.version=ODe++)}function c(u,d){let f=0,g=0,p=0,x=0,y=0;const b=d.matrixWorldInverse;for(let v=0,E=u.length;v<E;v++){const w=u[v];if(w.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),f++}else if(w.isSpotLight){const A=r.spot[p];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(b),A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(b),p++}else if(w.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(b),o.identity(),a.copy(w.matrixWorld),a.premultiply(b),o.extractRotation(a),A.halfWidth.set(w.width*.5,0,0),A.halfHeight.set(0,w.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),x++}else if(w.isPointLight){const A=r.point[g];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(b),g++}else if(w.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(b),y++}}}return{setup:l,setupView:c,state:r}}function w$(t){const e=new IDe(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 FDe(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new w$(t),e.set(i,[l])):a>=o.length?(l=new w$(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const UDe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,zDe=`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 BDe(t,e,n){let r=new VO;const i=new xn,a=new xn,o=new hi,l=new o3e({depthPacking:gke}),c=new l3e,u={},d=n.maxTextureSize,f={[Rd]:ss,[ss]:Rd,[ml]:ml},g=new eu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xn},radius:{value:4}},vertexShader:UDe,fragmentShader:zDe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ul;x.setAttribute("position",new mo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new kl(x,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=TZ;let v=this.type;this.render=function(C,T,O){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||C.length===0)return;const k=t.getRenderTarget(),R=t.getActiveCubeFace(),z=t.getActiveMipmapLevel(),D=t.state;D.setBlending(Fc),D.buffers.depth.getReversed()===!0?D.buffers.color.setClear(0,0,0,0):D.buffers.color.setClear(1,1,1,1),D.buffers.depth.setTest(!0),D.setScissorTest(!1);const K=v!==bc&&this.type===bc,P=v===bc&&this.type!==bc;for(let W=0,Z=C.length;W<Z;W++){const G=C[W],Y=G.shadow;if(Y===void 0){rn("WebGLShadowMap:",G,"has no shadow.");continue}if(Y.autoUpdate===!1&&Y.needsUpdate===!1)continue;i.copy(Y.mapSize);const X=Y.getFrameExtents();if(i.multiply(X),a.copy(Y.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/X.x),i.x=a.x*X.x,Y.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/X.y),i.y=a.y*X.y,Y.mapSize.y=a.y)),Y.map===null||K===!0||P===!0){const F=this.type!==bc?{minFilter:Ds,magFilter:Ds}:{};Y.map!==null&&Y.map.dispose(),Y.map=new wf(i.x,i.y,F),Y.map.texture.name=G.name+".shadowMap",Y.camera.updateProjectionMatrix()}t.setRenderTarget(Y.map),t.clear();const q=Y.getViewportCount();for(let F=0;F<q;F++){const V=Y.getViewport(F);o.set(a.x*V.x,a.y*V.y,a.x*V.z,a.y*V.w),D.viewport(o),Y.updateMatrices(G,F),r=Y.getFrustum(),A(T,O,Y.camera,G,this.type)}Y.isPointLightShadow!==!0&&this.type===bc&&E(Y,O),Y.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(k,R,z)};function E(C,T){const O=e.update(y);g.defines.VSM_SAMPLES!==C.blurSamples&&(g.defines.VSM_SAMPLES=C.blurSamples,p.defines.VSM_SAMPLES=C.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new wf(i.x,i.y)),g.uniforms.shadow_pass.value=C.map.texture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(T,null,O,g,y,null),p.uniforms.shadow_pass.value=C.mapPass.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(T,null,O,p,y,null)}function w(C,T,O,k){let R=null;const z=O.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(z!==void 0)R=z;else if(R=O.isPointLight===!0?c:l,t.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const D=R.uuid,K=T.uuid;let P=u[D];P===void 0&&(P={},u[D]=P);let W=P[K];W===void 0&&(W=R.clone(),P[K]=W,T.addEventListener("dispose",N)),R=W}if(R.visible=T.visible,R.wireframe=T.wireframe,k===bc?R.side=T.shadowSide!==null?T.shadowSide:T.side:R.side=T.shadowSide!==null?T.shadowSide:f[T.side],R.alphaMap=T.alphaMap,R.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,R.map=T.map,R.clipShadows=T.clipShadows,R.clippingPlanes=T.clippingPlanes,R.clipIntersection=T.clipIntersection,R.displacementMap=T.displacementMap,R.displacementScale=T.displacementScale,R.displacementBias=T.displacementBias,R.wireframeLinewidth=T.wireframeLinewidth,R.linewidth=T.linewidth,O.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const D=t.properties.get(R);D.light=O}return R}function A(C,T,O,k,R){if(C.visible===!1)return;if(C.layers.test(T.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&R===bc)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,C.matrixWorld);const K=e.update(C),P=C.material;if(Array.isArray(P)){const W=K.groups;for(let Z=0,G=W.length;Z<G;Z++){const Y=W[Z],X=P[Y.materialIndex];if(X&&X.visible){const q=w(C,X,k,R);C.onBeforeShadow(t,C,T,O,K,q,Y),t.renderBufferDirect(O,null,K,q,C,Y),C.onAfterShadow(t,C,T,O,K,q,Y)}}}else if(P.visible){const W=w(C,P,k,R);C.onBeforeShadow(t,C,T,O,K,W,null),t.renderBufferDirect(O,null,K,W,C,null),C.onAfterShadow(t,C,T,O,K,W,null)}}const D=C.children;for(let K=0,P=D.length;K<P;K++)A(D[K],T,O,k,R)}function N(C){C.target.removeEventListener("dispose",N);for(const O in u){const k=u[O],R=C.target.uuid;R in k&&(k[R].dispose(),delete k[R])}}}const HDe={[yj]:vj,[_j]:Mj,[wj]:Ej,[Gp]:Sj,[vj]:yj,[Mj]:_j,[Ej]:wj,[Sj]:Gp};function $De(t,e){function n(){let ie=!1;const Ie=new hi;let xe=null;const Ue=new hi(0,0,0,0);return{setMask:function(Pe){xe!==Pe&&!ie&&(t.colorMask(Pe,Pe,Pe,Pe),xe=Pe)},setLocked:function(Pe){ie=Pe},setClear:function(Pe,Me,Xe,ut,At){At===!0&&(Pe*=ut,Me*=ut,Xe*=ut),Ie.set(Pe,Me,Xe,ut),Ue.equals(Ie)===!1&&(t.clearColor(Pe,Me,Xe,ut),Ue.copy(Ie))},reset:function(){ie=!1,xe=null,Ue.set(-1,0,0,0)}}}function r(){let ie=!1,Ie=!1,xe=null,Ue=null,Pe=null;return{setReversed:function(Me){if(Ie!==Me){const Xe=e.get("EXT_clip_control");Me?Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.ZERO_TO_ONE_EXT):Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.NEGATIVE_ONE_TO_ONE_EXT),Ie=Me;const ut=Pe;Pe=null,this.setClear(ut)}},getReversed:function(){return Ie},setTest:function(Me){Me?ue(t.DEPTH_TEST):ce(t.DEPTH_TEST)},setMask:function(Me){xe!==Me&&!ie&&(t.depthMask(Me),xe=Me)},setFunc:function(Me){if(Ie&&(Me=HDe[Me]),Ue!==Me){switch(Me){case yj:t.depthFunc(t.NEVER);break;case vj:t.depthFunc(t.ALWAYS);break;case _j:t.depthFunc(t.LESS);break;case Gp:t.depthFunc(t.LEQUAL);break;case wj:t.depthFunc(t.EQUAL);break;case Sj:t.depthFunc(t.GEQUAL);break;case Mj:t.depthFunc(t.GREATER);break;case Ej:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=Me}},setLocked:function(Me){ie=Me},setClear:function(Me){Pe!==Me&&(Ie&&(Me=1-Me),t.clearDepth(Me),Pe=Me)},reset:function(){ie=!1,xe=null,Ue=null,Pe=null,Ie=!1}}}function i(){let ie=!1,Ie=null,xe=null,Ue=null,Pe=null,Me=null,Xe=null,ut=null,At=null;return{setTest:function(St){ie||(St?ue(t.STENCIL_TEST):ce(t.STENCIL_TEST))},setMask:function(St){Ie!==St&&!ie&&(t.stencilMask(St),Ie=St)},setFunc:function(St,Yt,Pt){(xe!==St||Ue!==Yt||Pe!==Pt)&&(t.stencilFunc(St,Yt,Pt),xe=St,Ue=Yt,Pe=Pt)},setOp:function(St,Yt,Pt){(Me!==St||Xe!==Yt||ut!==Pt)&&(t.stencilOp(St,Yt,Pt),Me=St,Xe=Yt,ut=Pt)},setLocked:function(St){ie=St},setClear:function(St){At!==St&&(t.clearStencil(St),At=St)},reset:function(){ie=!1,Ie=null,xe=null,Ue=null,Pe=null,Me=null,Xe=null,ut=null,At=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},g=new WeakMap,p=[],x=null,y=!1,b=null,v=null,E=null,w=null,A=null,N=null,C=null,T=new Tn(0,0,0),O=0,k=!1,R=null,z=null,D=null,K=null,P=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Z=!1,G=0;const Y=t.getParameter(t.VERSION);Y.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(Y)[1]),Z=G>=1):Y.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(Y)[1]),Z=G>=2);let X=null,q={};const F=t.getParameter(t.SCISSOR_BOX),V=t.getParameter(t.VIEWPORT),te=new hi().fromArray(F),re=new hi().fromArray(V);function ae(ie,Ie,xe,Ue){const Pe=new Uint8Array(4),Me=t.createTexture();t.bindTexture(ie,Me),t.texParameteri(ie,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ie,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Xe=0;Xe<xe;Xe++)ie===t.TEXTURE_3D||ie===t.TEXTURE_2D_ARRAY?t.texImage3D(Ie,0,t.RGBA,1,1,Ue,0,t.RGBA,t.UNSIGNED_BYTE,Pe):t.texImage2D(Ie+Xe,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Pe);return Me}const he={};he[t.TEXTURE_2D]=ae(t.TEXTURE_2D,t.TEXTURE_2D,1),he[t.TEXTURE_CUBE_MAP]=ae(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),he[t.TEXTURE_2D_ARRAY]=ae(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),he[t.TEXTURE_3D]=ae(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ue(t.DEPTH_TEST),o.setFunc(Gp),le(!1),$(vH),ue(t.CULL_FACE),B(Fc);function ue(ie){d[ie]!==!0&&(t.enable(ie),d[ie]=!0)}function ce(ie){d[ie]!==!1&&(t.disable(ie),d[ie]=!1)}function fe(ie,Ie){return f[ie]!==Ie?(t.bindFramebuffer(ie,Ie),f[ie]=Ie,ie===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=Ie),ie===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=Ie),!0):!1}function pe(ie,Ie){let xe=p,Ue=!1;if(ie){xe=g.get(Ie),xe===void 0&&(xe=[],g.set(Ie,xe));const Pe=ie.textures;if(xe.length!==Pe.length||xe[0]!==t.COLOR_ATTACHMENT0){for(let Me=0,Xe=Pe.length;Me<Xe;Me++)xe[Me]=t.COLOR_ATTACHMENT0+Me;xe.length=Pe.length,Ue=!0}}else xe[0]!==t.BACK&&(xe[0]=t.BACK,Ue=!0);Ue&&t.drawBuffers(xe)}function _e(ie){return x!==ie?(t.useProgram(ie),x=ie,!0):!1}const ne={[Ah]:t.FUNC_ADD,[HCe]:t.FUNC_SUBTRACT,[$Ce]:t.FUNC_REVERSE_SUBTRACT};ne[VCe]=t.MIN,ne[GCe]=t.MAX;const He={[WCe]:t.ZERO,[qCe]:t.ONE,[KCe]:t.SRC_COLOR,[xj]:t.SRC_ALPHA,[eke]:t.SRC_ALPHA_SATURATE,[QCe]:t.DST_COLOR,[YCe]:t.DST_ALPHA,[XCe]:t.ONE_MINUS_SRC_COLOR,[bj]:t.ONE_MINUS_SRC_ALPHA,[JCe]:t.ONE_MINUS_DST_COLOR,[ZCe]:t.ONE_MINUS_DST_ALPHA,[tke]:t.CONSTANT_COLOR,[nke]:t.ONE_MINUS_CONSTANT_COLOR,[rke]:t.CONSTANT_ALPHA,[ike]:t.ONE_MINUS_CONSTANT_ALPHA};function B(ie,Ie,xe,Ue,Pe,Me,Xe,ut,At,St){if(ie===Fc){y===!0&&(ce(t.BLEND),y=!1);return}if(y===!1&&(ue(t.BLEND),y=!0),ie!==BCe){if(ie!==b||St!==k){if((v!==Ah||A!==Ah)&&(t.blendEquation(t.FUNC_ADD),v=Ah,A=Ah),St)switch(ie){case wp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _H:t.blendFunc(t.ONE,t.ONE);break;case wH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case SH:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:ti("WebGLState: Invalid blending: ",ie);break}else switch(ie){case wp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case _H:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case wH:ti("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case SH:ti("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ti("WebGLState: Invalid blending: ",ie);break}E=null,w=null,N=null,C=null,T.set(0,0,0),O=0,b=ie,k=St}return}Pe=Pe||Ie,Me=Me||xe,Xe=Xe||Ue,(Ie!==v||Pe!==A)&&(t.blendEquationSeparate(ne[Ie],ne[Pe]),v=Ie,A=Pe),(xe!==E||Ue!==w||Me!==N||Xe!==C)&&(t.blendFuncSeparate(He[xe],He[Ue],He[Me],He[Xe]),E=xe,w=Ue,N=Me,C=Xe),(ut.equals(T)===!1||At!==O)&&(t.blendColor(ut.r,ut.g,ut.b,At),T.copy(ut),O=At),b=ie,k=!1}function H(ie,Ie){ie.side===ml?ce(t.CULL_FACE):ue(t.CULL_FACE);let xe=ie.side===ss;Ie&&(xe=!xe),le(xe),ie.blending===wp&&ie.transparent===!1?B(Fc):B(ie.blending,ie.blendEquation,ie.blendSrc,ie.blendDst,ie.blendEquationAlpha,ie.blendSrcAlpha,ie.blendDstAlpha,ie.blendColor,ie.blendAlpha,ie.premultipliedAlpha),o.setFunc(ie.depthFunc),o.setTest(ie.depthTest),o.setMask(ie.depthWrite),a.setMask(ie.colorWrite);const Ue=ie.stencilWrite;l.setTest(Ue),Ue&&(l.setMask(ie.stencilWriteMask),l.setFunc(ie.stencilFunc,ie.stencilRef,ie.stencilFuncMask),l.setOp(ie.stencilFail,ie.stencilZFail,ie.stencilZPass)),de(ie.polygonOffset,ie.polygonOffsetFactor,ie.polygonOffsetUnits),ie.alphaToCoverage===!0?ue(t.SAMPLE_ALPHA_TO_COVERAGE):ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function le(ie){R!==ie&&(ie?t.frontFace(t.CW):t.frontFace(t.CCW),R=ie)}function $(ie){ie!==FCe?(ue(t.CULL_FACE),ie!==z&&(ie===vH?t.cullFace(t.BACK):ie===UCe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ce(t.CULL_FACE),z=ie}function ee(ie){ie!==D&&(Z&&t.lineWidth(ie),D=ie)}function de(ie,Ie,xe){ie?(ue(t.POLYGON_OFFSET_FILL),(K!==Ie||P!==xe)&&(t.polygonOffset(Ie,xe),K=Ie,P=xe)):ce(t.POLYGON_OFFSET_FILL)}function ke(ie){ie?ue(t.SCISSOR_TEST):ce(t.SCISSOR_TEST)}function we(ie){ie===void 0&&(ie=t.TEXTURE0+W-1),X!==ie&&(t.activeTexture(ie),X=ie)}function Ee(ie,Ie,xe){xe===void 0&&(X===null?xe=t.TEXTURE0+W-1:xe=X);let Ue=q[xe];Ue===void 0&&(Ue={type:void 0,texture:void 0},q[xe]=Ue),(Ue.type!==ie||Ue.texture!==Ie)&&(X!==xe&&(t.activeTexture(xe),X=xe),t.bindTexture(ie,Ie||he[ie]),Ue.type=ie,Ue.texture=Ie)}function U(){const ie=q[X];ie!==void 0&&ie.type!==void 0&&(t.bindTexture(ie.type,null),ie.type=void 0,ie.texture=void 0)}function I(){try{t.compressedTexImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function se(){try{t.compressedTexImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function ye(){try{t.texSubImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function Se(){try{t.texSubImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function ve(){try{t.compressedTexSubImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function Be(){try{t.compressedTexSubImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function Ge(){try{t.texStorage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function Ke(){try{t.texStorage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function ct(){try{t.texImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function $e(){try{t.texImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function ge(ie){te.equals(ie)===!1&&(t.scissor(ie.x,ie.y,ie.z,ie.w),te.copy(ie))}function Je(ie){re.equals(ie)===!1&&(t.viewport(ie.x,ie.y,ie.z,ie.w),re.copy(ie))}function qe(ie,Ie){let xe=u.get(Ie);xe===void 0&&(xe=new WeakMap,u.set(Ie,xe));let Ue=xe.get(ie);Ue===void 0&&(Ue=t.getUniformBlockIndex(Ie,ie.name),xe.set(ie,Ue))}function Ze(ie,Ie){const Ue=u.get(Ie).get(ie);c.get(Ie)!==Ue&&(t.uniformBlockBinding(Ie,Ue,ie.__bindingPointIndex),c.set(Ie,Ue))}function lt(){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={},X=null,q={},f={},g=new WeakMap,p=[],x=null,y=!1,b=null,v=null,E=null,w=null,A=null,N=null,C=null,T=new Tn(0,0,0),O=0,k=!1,R=null,z=null,D=null,K=null,P=null,te.set(0,0,t.canvas.width,t.canvas.height),re.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:ue,disable:ce,bindFramebuffer:fe,drawBuffers:pe,useProgram:_e,setBlending:B,setMaterial:H,setFlipSided:le,setCullFace:$,setLineWidth:ee,setPolygonOffset:de,setScissorTest:ke,activeTexture:we,bindTexture:Ee,unbindTexture:U,compressedTexImage2D:I,compressedTexImage3D:se,texImage2D:ct,texImage3D:$e,updateUBOMapping:qe,uniformBlockBinding:Ze,texStorage2D:Ge,texStorage3D:Ke,texSubImage2D:ye,texSubImage3D:Se,compressedTexSubImage2D:ve,compressedTexSubImage3D:Be,scissor:ge,viewport:Je,reset:lt}}function VDe(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 xn,d=new WeakMap;let f;const g=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(U,I){return p?new OffscreenCanvas(U,I):nS("canvas")}function y(U,I,se){let ye=1;const Se=Ee(U);if((Se.width>se||Se.height>se)&&(ye=se/Math.max(Se.width,Se.height)),ye<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const ve=Math.floor(ye*Se.width),Be=Math.floor(ye*Se.height);f===void 0&&(f=x(ve,Be));const Ge=I?x(ve,Be):f;return Ge.width=ve,Ge.height=Be,Ge.getContext("2d").drawImage(U,0,0,ve,Be),rn("WebGLRenderer: Texture has been resized from ("+Se.width+"x"+Se.height+") to ("+ve+"x"+Be+")."),Ge}else return"data"in U&&rn("WebGLRenderer: Image in DataTexture is too big ("+Se.width+"x"+Se.height+")."),U;return U}function b(U){return U.generateMipmaps}function v(U){t.generateMipmap(U)}function E(U){return U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?t.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(U,I,se,ye,Se=!1){if(U!==null){if(t[U]!==void 0)return t[U];rn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let ve=I;if(I===t.RED&&(se===t.FLOAT&&(ve=t.R32F),se===t.HALF_FLOAT&&(ve=t.R16F),se===t.UNSIGNED_BYTE&&(ve=t.R8)),I===t.RED_INTEGER&&(se===t.UNSIGNED_BYTE&&(ve=t.R8UI),se===t.UNSIGNED_SHORT&&(ve=t.R16UI),se===t.UNSIGNED_INT&&(ve=t.R32UI),se===t.BYTE&&(ve=t.R8I),se===t.SHORT&&(ve=t.R16I),se===t.INT&&(ve=t.R32I)),I===t.RG&&(se===t.FLOAT&&(ve=t.RG32F),se===t.HALF_FLOAT&&(ve=t.RG16F),se===t.UNSIGNED_BYTE&&(ve=t.RG8)),I===t.RG_INTEGER&&(se===t.UNSIGNED_BYTE&&(ve=t.RG8UI),se===t.UNSIGNED_SHORT&&(ve=t.RG16UI),se===t.UNSIGNED_INT&&(ve=t.RG32UI),se===t.BYTE&&(ve=t.RG8I),se===t.SHORT&&(ve=t.RG16I),se===t.INT&&(ve=t.RG32I)),I===t.RGB_INTEGER&&(se===t.UNSIGNED_BYTE&&(ve=t.RGB8UI),se===t.UNSIGNED_SHORT&&(ve=t.RGB16UI),se===t.UNSIGNED_INT&&(ve=t.RGB32UI),se===t.BYTE&&(ve=t.RGB8I),se===t.SHORT&&(ve=t.RGB16I),se===t.INT&&(ve=t.RGB32I)),I===t.RGBA_INTEGER&&(se===t.UNSIGNED_BYTE&&(ve=t.RGBA8UI),se===t.UNSIGNED_SHORT&&(ve=t.RGBA16UI),se===t.UNSIGNED_INT&&(ve=t.RGBA32UI),se===t.BYTE&&(ve=t.RGBA8I),se===t.SHORT&&(ve=t.RGBA16I),se===t.INT&&(ve=t.RGBA32I)),I===t.RGB&&(se===t.UNSIGNED_INT_5_9_9_9_REV&&(ve=t.RGB9_E5),se===t.UNSIGNED_INT_10F_11F_11F_REV&&(ve=t.R11F_G11F_B10F)),I===t.RGBA){const Be=Se?eS:Bn.getTransfer(ye);se===t.FLOAT&&(ve=t.RGBA32F),se===t.HALF_FLOAT&&(ve=t.RGBA16F),se===t.UNSIGNED_BYTE&&(ve=Be===ar?t.SRGB8_ALPHA8:t.RGBA8),se===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),se===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function A(U,I){let se;return U?I===null||I===vf||I===lb?se=t.DEPTH24_STENCIL8:I===Pc?se=t.DEPTH32F_STENCIL8:I===ob&&(se=t.DEPTH24_STENCIL8,rn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===vf||I===lb?se=t.DEPTH_COMPONENT24:I===Pc?se=t.DEPTH_COMPONENT32F:I===ob&&(se=t.DEPTH_COMPONENT16),se}function N(U,I){return b(U)===!0||U.isFramebufferTexture&&U.minFilter!==Ds&&U.minFilter!==ho?Math.log2(Math.max(I.width,I.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?I.mipmaps.length:1}function C(U){const I=U.target;I.removeEventListener("dispose",C),O(I),I.isVideoTexture&&d.delete(I)}function T(U){const I=U.target;I.removeEventListener("dispose",T),R(I)}function O(U){const I=r.get(U);if(I.__webglInit===void 0)return;const se=U.source,ye=g.get(se);if(ye){const Se=ye[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&k(U),Object.keys(ye).length===0&&g.delete(se)}r.remove(U)}function k(U){const I=r.get(U);t.deleteTexture(I.__webglTexture);const se=U.source,ye=g.get(se);delete ye[I.__cacheKey],o.memory.textures--}function R(U){const I=r.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),r.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(I.__webglFramebuffer[ye]))for(let Se=0;Se<I.__webglFramebuffer[ye].length;Se++)t.deleteFramebuffer(I.__webglFramebuffer[ye][Se]);else t.deleteFramebuffer(I.__webglFramebuffer[ye]);I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer[ye])}else{if(Array.isArray(I.__webglFramebuffer))for(let ye=0;ye<I.__webglFramebuffer.length;ye++)t.deleteFramebuffer(I.__webglFramebuffer[ye]);else t.deleteFramebuffer(I.__webglFramebuffer);if(I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer),I.__webglMultisampledFramebuffer&&t.deleteFramebuffer(I.__webglMultisampledFramebuffer),I.__webglColorRenderbuffer)for(let ye=0;ye<I.__webglColorRenderbuffer.length;ye++)I.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(I.__webglColorRenderbuffer[ye]);I.__webglDepthRenderbuffer&&t.deleteRenderbuffer(I.__webglDepthRenderbuffer)}const se=U.textures;for(let ye=0,Se=se.length;ye<Se;ye++){const ve=r.get(se[ye]);ve.__webglTexture&&(t.deleteTexture(ve.__webglTexture),o.memory.textures--),r.remove(se[ye])}r.remove(U)}let z=0;function D(){z=0}function K(){const U=z;return U>=i.maxTextures&&rn("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+i.maxTextures),z+=1,U}function P(U){const I=[];return I.push(U.wrapS),I.push(U.wrapT),I.push(U.wrapR||0),I.push(U.magFilter),I.push(U.minFilter),I.push(U.anisotropy),I.push(U.internalFormat),I.push(U.format),I.push(U.type),I.push(U.generateMipmaps),I.push(U.premultiplyAlpha),I.push(U.flipY),I.push(U.unpackAlignment),I.push(U.colorSpace),I.join()}function W(U,I){const se=r.get(U);if(U.isVideoTexture&&ke(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&se.__version!==U.version){const ye=U.image;if(ye===null)rn("WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)rn("WebGLRenderer: Texture marked for update but image is incomplete");else{he(se,U,I);return}}else U.isExternalTexture&&(se.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,se.__webglTexture,t.TEXTURE0+I)}function Z(U,I){const se=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&se.__version!==U.version){he(se,U,I);return}else U.isExternalTexture&&(se.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,se.__webglTexture,t.TEXTURE0+I)}function G(U,I){const se=r.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&se.__version!==U.version){he(se,U,I);return}n.bindTexture(t.TEXTURE_3D,se.__webglTexture,t.TEXTURE0+I)}function Y(U,I){const se=r.get(U);if(U.version>0&&se.__version!==U.version){ue(se,U,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,se.__webglTexture,t.TEXTURE0+I)}const X={[Tj]:t.REPEAT,[jc]:t.CLAMP_TO_EDGE,[Cj]:t.MIRRORED_REPEAT},q={[Ds]:t.NEAREST,[mke]:t.NEAREST_MIPMAP_NEAREST,[t_]:t.NEAREST_MIPMAP_LINEAR,[ho]:t.LINEAR,[GT]:t.LINEAR_MIPMAP_NEAREST,[Fh]:t.LINEAR_MIPMAP_LINEAR},F={[bke]:t.NEVER,[Mke]:t.ALWAYS,[yke]:t.LESS,[FZ]:t.LEQUAL,[vke]:t.EQUAL,[Ske]:t.GEQUAL,[_ke]:t.GREATER,[wke]:t.NOTEQUAL};function V(U,I){if(I.type===Pc&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===ho||I.magFilter===GT||I.magFilter===t_||I.magFilter===Fh||I.minFilter===ho||I.minFilter===GT||I.minFilter===t_||I.minFilter===Fh)&&rn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(U,t.TEXTURE_WRAP_S,X[I.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,X[I.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,X[I.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,q[I.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,q[I.minFilter]),I.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,F[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===Ds||I.minFilter!==t_&&I.minFilter!==Fh||I.type===Pc&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||r.get(I).__currentAnisotropy){const se=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy}}}function te(U,I){let se=!1;U.__webglInit===void 0&&(U.__webglInit=!0,I.addEventListener("dispose",C));const ye=I.source;let Se=g.get(ye);Se===void 0&&(Se={},g.set(ye,Se));const ve=P(I);if(ve!==U.__cacheKey){Se[ve]===void 0&&(Se[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,se=!0),Se[ve].usedTimes++;const Be=Se[U.__cacheKey];Be!==void 0&&(Se[U.__cacheKey].usedTimes--,Be.usedTimes===0&&k(I)),U.__cacheKey=ve,U.__webglTexture=Se[ve].texture}return se}function re(U,I,se){return Math.floor(Math.floor(U/se)/I)}function ae(U,I,se,ye){const ve=U.updateRanges;if(ve.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,I.width,I.height,se,ye,I.data);else{ve.sort(($e,ge)=>$e.start-ge.start);let Be=0;for(let $e=1;$e<ve.length;$e++){const ge=ve[Be],Je=ve[$e],qe=ge.start+ge.count,Ze=re(Je.start,I.width,4),lt=re(ge.start,I.width,4);Je.start<=qe+1&&Ze===lt&&re(Je.start+Je.count-1,I.width,4)===Ze?ge.count=Math.max(ge.count,Je.start+Je.count-ge.start):(++Be,ve[Be]=Je)}ve.length=Be+1;const Ge=t.getParameter(t.UNPACK_ROW_LENGTH),Ke=t.getParameter(t.UNPACK_SKIP_PIXELS),ct=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,I.width);for(let $e=0,ge=ve.length;$e<ge;$e++){const Je=ve[$e],qe=Math.floor(Je.start/4),Ze=Math.ceil(Je.count/4),lt=qe%I.width,ie=Math.floor(qe/I.width),Ie=Ze,xe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,lt),t.pixelStorei(t.UNPACK_SKIP_ROWS,ie),n.texSubImage2D(t.TEXTURE_2D,0,lt,ie,Ie,xe,se,ye,I.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ge),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(t.UNPACK_SKIP_ROWS,ct)}}function he(U,I,se){let ye=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(ye=t.TEXTURE_3D);const Se=te(U,I),ve=I.source;n.bindTexture(ye,U.__webglTexture,t.TEXTURE0+se);const Be=r.get(ve);if(ve.version!==Be.__version||Se===!0){n.activeTexture(t.TEXTURE0+se);const Ge=Bn.getPrimaries(Bn.workingColorSpace),Ke=I.colorSpace===nd?null:Bn.getPrimaries(I.colorSpace),ct=I.colorSpace===nd||Ge===Ke?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ct);let $e=y(I.image,!1,i.maxTextureSize);$e=we(I,$e);const ge=a.convert(I.format,I.colorSpace),Je=a.convert(I.type);let qe=w(I.internalFormat,ge,Je,I.colorSpace,I.isVideoTexture);V(ye,I);let Ze;const lt=I.mipmaps,ie=I.isVideoTexture!==!0,Ie=Be.__version===void 0||Se===!0,xe=ve.dataReady,Ue=N(I,$e);if(I.isDepthTexture)qe=A(I.format===ub,I.type),Ie&&(ie?n.texStorage2D(t.TEXTURE_2D,1,qe,$e.width,$e.height):n.texImage2D(t.TEXTURE_2D,0,qe,$e.width,$e.height,0,ge,Je,null));else if(I.isDataTexture)if(lt.length>0){ie&&Ie&&n.texStorage2D(t.TEXTURE_2D,Ue,qe,lt[0].width,lt[0].height);for(let Pe=0,Me=lt.length;Pe<Me;Pe++)Ze=lt[Pe],ie?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,ge,Je,Ze.data):n.texImage2D(t.TEXTURE_2D,Pe,qe,Ze.width,Ze.height,0,ge,Je,Ze.data);I.generateMipmaps=!1}else ie?(Ie&&n.texStorage2D(t.TEXTURE_2D,Ue,qe,$e.width,$e.height),xe&&ae(I,$e,ge,Je)):n.texImage2D(t.TEXTURE_2D,0,qe,$e.width,$e.height,0,ge,Je,$e.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){ie&&Ie&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,qe,lt[0].width,lt[0].height,$e.depth);for(let Pe=0,Me=lt.length;Pe<Me;Pe++)if(Ze=lt[Pe],I.format!==Uo)if(ge!==null)if(ie){if(xe)if(I.layerUpdates.size>0){const Xe=JH(Ze.width,Ze.height,I.format,I.type);for(const ut of I.layerUpdates){const At=Ze.data.subarray(ut*Xe/Ze.data.BYTES_PER_ELEMENT,(ut+1)*Xe/Ze.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,ut,Ze.width,Ze.height,1,ge,At)}I.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Ze.width,Ze.height,$e.depth,ge,Ze.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Pe,qe,Ze.width,Ze.height,$e.depth,0,Ze.data,0,0);else rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ie?xe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Pe,0,0,0,Ze.width,Ze.height,$e.depth,ge,Je,Ze.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Pe,qe,Ze.width,Ze.height,$e.depth,0,ge,Je,Ze.data)}else{ie&&Ie&&n.texStorage2D(t.TEXTURE_2D,Ue,qe,lt[0].width,lt[0].height);for(let Pe=0,Me=lt.length;Pe<Me;Pe++)Ze=lt[Pe],I.format!==Uo?ge!==null?ie?xe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,ge,Ze.data):n.compressedTexImage2D(t.TEXTURE_2D,Pe,qe,Ze.width,Ze.height,0,Ze.data):rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ie?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,Ze.width,Ze.height,ge,Je,Ze.data):n.texImage2D(t.TEXTURE_2D,Pe,qe,Ze.width,Ze.height,0,ge,Je,Ze.data)}else if(I.isDataArrayTexture)if(ie){if(Ie&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,qe,$e.width,$e.height,$e.depth),xe)if(I.layerUpdates.size>0){const Pe=JH($e.width,$e.height,I.format,I.type);for(const Me of I.layerUpdates){const Xe=$e.data.subarray(Me*Pe/$e.data.BYTES_PER_ELEMENT,(Me+1)*Pe/$e.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Me,$e.width,$e.height,1,ge,Je,Xe)}I.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,$e.width,$e.height,$e.depth,ge,Je,$e.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,qe,$e.width,$e.height,$e.depth,0,ge,Je,$e.data);else if(I.isData3DTexture)ie?(Ie&&n.texStorage3D(t.TEXTURE_3D,Ue,qe,$e.width,$e.height,$e.depth),xe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,$e.width,$e.height,$e.depth,ge,Je,$e.data)):n.texImage3D(t.TEXTURE_3D,0,qe,$e.width,$e.height,$e.depth,0,ge,Je,$e.data);else if(I.isFramebufferTexture){if(Ie)if(ie)n.texStorage2D(t.TEXTURE_2D,Ue,qe,$e.width,$e.height);else{let Pe=$e.width,Me=$e.height;for(let Xe=0;Xe<Ue;Xe++)n.texImage2D(t.TEXTURE_2D,Xe,qe,Pe,Me,0,ge,Je,null),Pe>>=1,Me>>=1}}else if(lt.length>0){if(ie&&Ie){const Pe=Ee(lt[0]);n.texStorage2D(t.TEXTURE_2D,Ue,qe,Pe.width,Pe.height)}for(let Pe=0,Me=lt.length;Pe<Me;Pe++)Ze=lt[Pe],ie?xe&&n.texSubImage2D(t.TEXTURE_2D,Pe,0,0,ge,Je,Ze):n.texImage2D(t.TEXTURE_2D,Pe,qe,ge,Je,Ze);I.generateMipmaps=!1}else if(ie){if(Ie){const Pe=Ee($e);n.texStorage2D(t.TEXTURE_2D,Ue,qe,Pe.width,Pe.height)}xe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,ge,Je,$e)}else n.texImage2D(t.TEXTURE_2D,0,qe,ge,Je,$e);b(I)&&v(ye),Be.__version=ve.version,I.onUpdate&&I.onUpdate(I)}U.__version=I.version}function ue(U,I,se){if(I.image.length!==6)return;const ye=te(U,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+se);const ve=r.get(Se);if(Se.version!==ve.__version||ye===!0){n.activeTexture(t.TEXTURE0+se);const Be=Bn.getPrimaries(Bn.workingColorSpace),Ge=I.colorSpace===nd?null:Bn.getPrimaries(I.colorSpace),Ke=I.colorSpace===nd||Be===Ge?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const ct=I.isCompressedTexture||I.image[0].isCompressedTexture,$e=I.image[0]&&I.image[0].isDataTexture,ge=[];for(let Me=0;Me<6;Me++)!ct&&!$e?ge[Me]=y(I.image[Me],!0,i.maxCubemapSize):ge[Me]=$e?I.image[Me].image:I.image[Me],ge[Me]=we(I,ge[Me]);const Je=ge[0],qe=a.convert(I.format,I.colorSpace),Ze=a.convert(I.type),lt=w(I.internalFormat,qe,Ze,I.colorSpace),ie=I.isVideoTexture!==!0,Ie=ve.__version===void 0||ye===!0,xe=Se.dataReady;let Ue=N(I,Je);V(t.TEXTURE_CUBE_MAP,I);let Pe;if(ct){ie&&Ie&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,lt,Je.width,Je.height);for(let Me=0;Me<6;Me++){Pe=ge[Me].mipmaps;for(let Xe=0;Xe<Pe.length;Xe++){const ut=Pe[Xe];I.format!==Uo?qe!==null?ie?xe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,0,0,ut.width,ut.height,qe,ut.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,lt,ut.width,ut.height,0,ut.data):rn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ie?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,0,0,ut.width,ut.height,qe,Ze,ut.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,lt,ut.width,ut.height,0,qe,Ze,ut.data)}}}else{if(Pe=I.mipmaps,ie&&Ie){Pe.length>0&&Ue++;const Me=Ee(ge[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,lt,Me.width,Me.height)}for(let Me=0;Me<6;Me++)if($e){ie?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,ge[Me].width,ge[Me].height,qe,Ze,ge[Me].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,lt,ge[Me].width,ge[Me].height,0,qe,Ze,ge[Me].data);for(let Xe=0;Xe<Pe.length;Xe++){const At=Pe[Xe].image[Me].image;ie?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,0,0,At.width,At.height,qe,Ze,At.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,lt,At.width,At.height,0,qe,Ze,At.data)}}else{ie?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,qe,Ze,ge[Me]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,lt,qe,Ze,ge[Me]);for(let Xe=0;Xe<Pe.length;Xe++){const ut=Pe[Xe];ie?xe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,0,0,qe,Ze,ut.image[Me]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,lt,qe,Ze,ut.image[Me])}}}b(I)&&v(t.TEXTURE_CUBE_MAP),ve.__version=Se.version,I.onUpdate&&I.onUpdate(I)}U.__version=I.version}function ce(U,I,se,ye,Se,ve){const Be=a.convert(se.format,se.colorSpace),Ge=a.convert(se.type),Ke=w(se.internalFormat,Be,Ge,se.colorSpace),ct=r.get(I),$e=r.get(se);if($e.__renderTarget=I,!ct.__hasExternalTextures){const ge=Math.max(1,I.width>>ve),Je=Math.max(1,I.height>>ve);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ve,Ke,ge,Je,I.depth,0,Be,Ge,null):n.texImage2D(Se,ve,Ke,ge,Je,0,Be,Ge,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),de(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,Se,$e.__webglTexture,0,ee(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,Se,$e.__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function fe(U,I,se){if(t.bindRenderbuffer(t.RENDERBUFFER,U),I.depthBuffer){const ye=I.depthTexture,Se=ye&&ye.isDepthTexture?ye.type:null,ve=A(I.stencilBuffer,Se),Be=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ge=ee(I);de(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ge,ve,I.width,I.height):se?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ge,ve,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,ve,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Be,t.RENDERBUFFER,U)}else{const ye=I.textures;for(let Se=0;Se<ye.length;Se++){const ve=ye[Se],Be=a.convert(ve.format,ve.colorSpace),Ge=a.convert(ve.type),Ke=w(ve.internalFormat,Be,Ge,ve.colorSpace),ct=ee(I);se&&de(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ct,Ke,I.width,I.height):de(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ct,Ke,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,Ke,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function pe(U,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const ye=r.get(I.depthTexture);ye.__renderTarget=I,(!ye.__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),W(I.depthTexture,0);const Se=ye.__webglTexture,ve=ee(I);if(I.depthTexture.format===cb)de(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0);else if(I.depthTexture.format===ub)de(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0);else throw new Error("Unknown depthTexture format")}function _e(U){const I=r.get(U),se=U.isWebGLCubeRenderTarget===!0;if(I.__boundDepthTexture!==U.depthTexture){const ye=U.depthTexture;if(I.__depthDisposeCallback&&I.__depthDisposeCallback(),ye){const Se=()=>{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,ye.removeEventListener("dispose",Se)};ye.addEventListener("dispose",Se),I.__depthDisposeCallback=Se}I.__boundDepthTexture=ye}if(U.depthTexture&&!I.__autoAllocateDepthBuffer){if(se)throw new Error("target.depthTexture not supported in Cube render targets");const ye=U.texture.mipmaps;ye&&ye.length>0?pe(I.__webglFramebuffer[0],U):pe(I.__webglFramebuffer,U)}else if(se){I.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)if(n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[ye]),I.__webglDepthbuffer[ye]===void 0)I.__webglDepthbuffer[ye]=t.createRenderbuffer(),fe(I.__webglDepthbuffer[ye],U,!1);else{const Se=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=I.__webglDepthbuffer[ye];t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ve)}}else{const ye=U.texture.mipmaps;if(ye&&ye.length>0?n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=t.createRenderbuffer(),fe(I.__webglDepthbuffer,U,!1);else{const Se=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=I.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,ve)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ne(U,I,se){const ye=r.get(U);I!==void 0&&ce(ye.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),se!==void 0&&_e(U)}function He(U){const I=U.texture,se=r.get(U),ye=r.get(I);U.addEventListener("dispose",T);const Se=U.textures,ve=U.isWebGLCubeRenderTarget===!0,Be=Se.length>1;if(Be||(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=I.version,o.memory.textures++),ve){se.__webglFramebuffer=[];for(let Ge=0;Ge<6;Ge++)if(I.mipmaps&&I.mipmaps.length>0){se.__webglFramebuffer[Ge]=[];for(let Ke=0;Ke<I.mipmaps.length;Ke++)se.__webglFramebuffer[Ge][Ke]=t.createFramebuffer()}else se.__webglFramebuffer[Ge]=t.createFramebuffer()}else{if(I.mipmaps&&I.mipmaps.length>0){se.__webglFramebuffer=[];for(let Ge=0;Ge<I.mipmaps.length;Ge++)se.__webglFramebuffer[Ge]=t.createFramebuffer()}else se.__webglFramebuffer=t.createFramebuffer();if(Be)for(let Ge=0,Ke=Se.length;Ge<Ke;Ge++){const ct=r.get(Se[Ge]);ct.__webglTexture===void 0&&(ct.__webglTexture=t.createTexture(),o.memory.textures++)}if(U.samples>0&&de(U)===!1){se.__webglMultisampledFramebuffer=t.createFramebuffer(),se.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,se.__webglMultisampledFramebuffer);for(let Ge=0;Ge<Se.length;Ge++){const Ke=Se[Ge];se.__webglColorRenderbuffer[Ge]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,se.__webglColorRenderbuffer[Ge]);const ct=a.convert(Ke.format,Ke.colorSpace),$e=a.convert(Ke.type),ge=w(Ke.internalFormat,ct,$e,Ke.colorSpace,U.isXRRenderTarget===!0),Je=ee(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,Je,ge,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ge,t.RENDERBUFFER,se.__webglColorRenderbuffer[Ge])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(se.__webglDepthRenderbuffer=t.createRenderbuffer(),fe(se.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ve){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),V(t.TEXTURE_CUBE_MAP,I);for(let Ge=0;Ge<6;Ge++)if(I.mipmaps&&I.mipmaps.length>0)for(let Ke=0;Ke<I.mipmaps.length;Ke++)ce(se.__webglFramebuffer[Ge][Ke],U,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Ke);else ce(se.__webglFramebuffer[Ge],U,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,0);b(I)&&v(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Be){for(let Ge=0,Ke=Se.length;Ge<Ke;Ge++){const ct=Se[Ge],$e=r.get(ct);let ge=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(ge=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(ge,$e.__webglTexture),V(ge,ct),ce(se.__webglFramebuffer,U,ct,t.COLOR_ATTACHMENT0+Ge,ge,0),b(ct)&&v(ge)}n.unbindTexture()}else{let Ge=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Ge=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ge,ye.__webglTexture),V(Ge,I),I.mipmaps&&I.mipmaps.length>0)for(let Ke=0;Ke<I.mipmaps.length;Ke++)ce(se.__webglFramebuffer[Ke],U,I,t.COLOR_ATTACHMENT0,Ge,Ke);else ce(se.__webglFramebuffer,U,I,t.COLOR_ATTACHMENT0,Ge,0);b(I)&&v(Ge),n.unbindTexture()}U.depthBuffer&&_e(U)}function B(U){const I=U.textures;for(let se=0,ye=I.length;se<ye;se++){const Se=I[se];if(b(Se)){const ve=E(U),Be=r.get(Se).__webglTexture;n.bindTexture(ve,Be),v(ve),n.unbindTexture()}}}const H=[],le=[];function $(U){if(U.samples>0){if(de(U)===!1){const I=U.textures,se=U.width,ye=U.height;let Se=t.COLOR_BUFFER_BIT;const ve=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Be=r.get(U),Ge=I.length>1;if(Ge)for(let ct=0;ct<I.length;ct++)n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Be.__webglMultisampledFramebuffer);const Ke=U.texture.mipmaps;Ke&&Ke.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglFramebuffer);for(let ct=0;ct<I.length;ct++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Ge){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Be.__webglColorRenderbuffer[ct]);const $e=r.get(I[ct]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,$e,0)}t.blitFramebuffer(0,0,se,ye,0,0,se,ye,Se,t.NEAREST),c===!0&&(H.length=0,le.length=0,H.push(t.COLOR_ATTACHMENT0+ct),U.depthBuffer&&U.resolveDepthBuffer===!1&&(H.push(ve),le.push(ve),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,le)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,H))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ge)for(let ct=0;ct<I.length;ct++){n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,Be.__webglColorRenderbuffer[ct]);const $e=r.get(I[ct]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Be.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,$e,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Be.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&c){const I=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[I])}}}function ee(U){return Math.min(i.maxSamples,U.samples)}function de(U){const I=r.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function ke(U){const I=o.render.frame;d.get(U)!==I&&(d.set(U,I),U.update())}function we(U,I){const se=U.colorSpace,ye=U.format,Se=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||se!==Kp&&se!==nd&&(Bn.getTransfer(se)===ar?(ye!==Uo||Se!==Cl)&&rn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ti("WebGLTextures: Unsupported texture color space:",se)),I}function Ee(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(u.width=U.naturalWidth||U.width,u.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(u.width=U.displayWidth,u.height=U.displayHeight):(u.width=U.width,u.height=U.height),u}this.allocateTextureUnit=K,this.resetTextureUnits=D,this.setTexture2D=W,this.setTexture2DArray=Z,this.setTexture3D=G,this.setTextureCube=Y,this.rebindTextures=ne,this.setupRenderTarget=He,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=$,this.setupDepthRenderbuffer=_e,this.setupFrameBufferTexture=ce,this.useMultisampledRTT=de}function GDe(t,e){function n(r,i=nd){let a;const o=Bn.getTransfer(i);if(r===Cl)return t.UNSIGNED_BYTE;if(r===DO)return t.UNSIGNED_SHORT_4_4_4_4;if(r===OO)return t.UNSIGNED_SHORT_5_5_5_1;if(r===PZ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===RZ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===kZ)return t.BYTE;if(r===jZ)return t.SHORT;if(r===ob)return t.UNSIGNED_SHORT;if(r===RO)return t.INT;if(r===vf)return t.UNSIGNED_INT;if(r===Pc)return t.FLOAT;if(r===Ng)return t.HALF_FLOAT;if(r===DZ)return t.ALPHA;if(r===OZ)return t.RGB;if(r===Uo)return t.RGBA;if(r===cb)return t.DEPTH_COMPONENT;if(r===ub)return t.DEPTH_STENCIL;if(r===LZ)return t.RED;if(r===LO)return t.RED_INTEGER;if(r===IO)return t.RG;if(r===FO)return t.RG_INTEGER;if(r===UO)return t.RGBA_INTEGER;if(r===C1||r===k1||r===j1||r===P1)if(o===ar)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===C1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===k1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===j1)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===C1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===k1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===j1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===P1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===kj||r===jj||r===Pj||r===Rj)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===kj)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===jj)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Pj)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Rj)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Dj||r===Oj||r===Lj)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===Dj||r===Oj)return o===ar?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===Lj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Ij||r===Fj||r===Uj||r===zj||r===Bj||r===Hj||r===$j||r===Vj||r===Gj||r===Wj||r===qj||r===Kj||r===Xj||r===Yj)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===Ij)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Fj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Uj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===zj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Bj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Hj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===$j)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Vj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Gj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Wj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===qj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Kj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Xj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Yj)return o===ar?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Zj||r===Qj||r===Jj)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===Zj)return o===ar?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Qj)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Jj)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===eP||r===tP||r===nP||r===rP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===eP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===tP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===nP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===rP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===lb?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const WDe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,qDe=`
- 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 KDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new rQ(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 eu({vertexShader:WDe,fragmentShader:qDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new kl(new GO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let XDe=class extends Df{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const y=typeof XRWebGLBinding<"u",b=new KDe,v={},E=n.getContextAttributes();let w=null,A=null;const N=[],C=[],T=new xn;let O=null;const k=new ao;k.viewport=new hi;const R=new ao;R.viewport=new hi;const z=[k,R],D=new h3e;let K=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(he){let ue=N[he];return ue===void 0&&(ue=new fC,N[he]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(he){let ue=N[he];return ue===void 0&&(ue=new fC,N[he]=ue),ue.getGripSpace()},this.getHand=function(he){let ue=N[he];return ue===void 0&&(ue=new fC,N[he]=ue),ue.getHandSpace()};function W(he){const ue=C.indexOf(he.inputSource);if(ue===-1)return;const ce=N[ue];ce!==void 0&&(ce.update(he.inputSource,he.frame,u||o),ce.dispatchEvent({type:he.type,data:he.inputSource}))}function Z(){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",Z),i.removeEventListener("inputsourceschange",G);for(let he=0;he<N.length;he++){const ue=C[he];ue!==null&&(C[he]=null,N[he].disconnect(ue))}K=null,P=null,b.reset();for(const he in v)delete v[he];e.setRenderTarget(w),p=null,g=null,f=null,i=null,A=null,ae.stop(),r.isPresenting=!1,e.setPixelRatio(O),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(he){a=he,r.isPresenting===!0&&rn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(he){l=he,r.isPresenting===!0&&rn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(he){u=he},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f===null&&y&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(he){if(i=he,i!==null){if(w=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",Z),i.addEventListener("inputsourceschange",G),E.xrCompatible!==!0&&await n.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(T),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ce=null,fe=null,pe=null;E.depth&&(pe=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ce=E.stencil?ub:cb,fe=E.stencil?lb:vf);const _e={colorFormat:n.RGBA8,depthFormat:pe,scaleFactor:a};f=this.getBinding(),g=f.createProjectionLayer(_e),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),A=new wf(g.textureWidth,g.textureHeight,{format:Uo,type:Cl,depthTexture:new nQ(g.textureWidth,g.textureHeight,fe,void 0,void 0,void 0,void 0,void 0,void 0,ce),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}else{const ce={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,ce),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),A=new wf(p.framebufferWidth,p.framebufferHeight,{format:Uo,type:Cl,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),ae.setContext(i),ae.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return b.getDepthTexture()};function G(he){for(let ue=0;ue<he.removed.length;ue++){const ce=he.removed[ue],fe=C.indexOf(ce);fe>=0&&(C[fe]=null,N[fe].disconnect(ce))}for(let ue=0;ue<he.added.length;ue++){const ce=he.added[ue];let fe=C.indexOf(ce);if(fe===-1){for(let _e=0;_e<N.length;_e++)if(_e>=C.length){C.push(ce),fe=_e;break}else if(C[_e]===null){C[_e]=ce,fe=_e;break}if(fe===-1)break}const pe=N[fe];pe&&pe.connect(ce)}}const Y=new it,X=new it;function q(he,ue,ce){Y.setFromMatrixPosition(ue.matrixWorld),X.setFromMatrixPosition(ce.matrixWorld);const fe=Y.distanceTo(X),pe=ue.projectionMatrix.elements,_e=ce.projectionMatrix.elements,ne=pe[14]/(pe[10]-1),He=pe[14]/(pe[10]+1),B=(pe[9]+1)/pe[5],H=(pe[9]-1)/pe[5],le=(pe[8]-1)/pe[0],$=(_e[8]+1)/_e[0],ee=ne*le,de=ne*$,ke=fe/(-le+$),we=ke*-le;if(ue.matrixWorld.decompose(he.position,he.quaternion,he.scale),he.translateX(we),he.translateZ(ke),he.matrixWorld.compose(he.position,he.quaternion,he.scale),he.matrixWorldInverse.copy(he.matrixWorld).invert(),pe[10]===-1)he.projectionMatrix.copy(ue.projectionMatrix),he.projectionMatrixInverse.copy(ue.projectionMatrixInverse);else{const Ee=ne+ke,U=He+ke,I=ee-we,se=de+(fe-we),ye=B*He/U*Ee,Se=H*He/U*Ee;he.projectionMatrix.makePerspective(I,se,ye,Se,Ee,U),he.projectionMatrixInverse.copy(he.projectionMatrix).invert()}}function F(he,ue){ue===null?he.matrixWorld.copy(he.matrix):he.matrixWorld.multiplyMatrices(ue.matrixWorld,he.matrix),he.matrixWorldInverse.copy(he.matrixWorld).invert()}this.updateCamera=function(he){if(i===null)return;let ue=he.near,ce=he.far;b.texture!==null&&(b.depthNear>0&&(ue=b.depthNear),b.depthFar>0&&(ce=b.depthFar)),D.near=R.near=k.near=ue,D.far=R.far=k.far=ce,(K!==D.near||P!==D.far)&&(i.updateRenderState({depthNear:D.near,depthFar:D.far}),K=D.near,P=D.far),D.layers.mask=he.layers.mask|6,k.layers.mask=D.layers.mask&3,R.layers.mask=D.layers.mask&5;const fe=he.parent,pe=D.cameras;F(D,fe);for(let _e=0;_e<pe.length;_e++)F(pe[_e],fe);pe.length===2?q(D,k,R):D.projectionMatrix.copy(k.projectionMatrix),V(he,D,fe)};function V(he,ue,ce){ce===null?he.matrix.copy(ue.matrixWorld):(he.matrix.copy(ce.matrixWorld),he.matrix.invert(),he.matrix.multiply(ue.matrixWorld)),he.matrix.decompose(he.position,he.quaternion,he.scale),he.updateMatrixWorld(!0),he.projectionMatrix.copy(ue.projectionMatrix),he.projectionMatrixInverse.copy(ue.projectionMatrixInverse),he.isPerspectiveCamera&&(he.fov=iP*2*Math.atan(1/he.projectionMatrix.elements[5]),he.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(he){c=he,g!==null&&(g.fixedFoveation=he),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=he)},this.hasDepthSensing=function(){return b.texture!==null},this.getDepthSensingMesh=function(){return b.getMesh(D)},this.getCameraTexture=function(he){return v[he]};let te=null;function re(he,ue){if(d=ue.getViewerPose(u||o),x=ue,d!==null){const ce=d.views;p!==null&&(e.setRenderTargetFramebuffer(A,p.framebuffer),e.setRenderTarget(A));let fe=!1;ce.length!==D.cameras.length&&(D.cameras.length=0,fe=!0);for(let He=0;He<ce.length;He++){const B=ce[He];let H=null;if(p!==null)H=p.getViewport(B);else{const $=f.getViewSubImage(g,B);H=$.viewport,He===0&&(e.setRenderTargetTextures(A,$.colorTexture,$.depthStencilTexture),e.setRenderTarget(A))}let le=z[He];le===void 0&&(le=new ao,le.layers.enable(He),le.viewport=new hi,z[He]=le),le.matrix.fromArray(B.transform.matrix),le.matrix.decompose(le.position,le.quaternion,le.scale),le.projectionMatrix.fromArray(B.projectionMatrix),le.projectionMatrixInverse.copy(le.projectionMatrix).invert(),le.viewport.set(H.x,H.y,H.width,H.height),He===0&&(D.matrix.copy(le.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),fe===!0&&D.cameras.push(le)}const pe=i.enabledFeatures;if(pe&&pe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){f=r.getBinding();const He=f.getDepthInformation(ce[0]);He&&He.isValid&&He.texture&&b.init(He,i.renderState)}if(pe&&pe.includes("camera-access")&&y){e.state.unbindTexture(),f=r.getBinding();for(let He=0;He<ce.length;He++){const B=ce[He].camera;if(B){let H=v[B];H||(H=new rQ,v[B]=H);const le=f.getCameraImage(B);H.sourceTexture=le}}}}for(let ce=0;ce<N.length;ce++){const fe=C[ce],pe=N[ce];fe!==null&&pe!==void 0&&pe.update(fe,ue,u||o)}te&&te(he,ue),ue.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ue}),x=null}const ae=new oQ;ae.setAnimationLoop(re),this.setAnimationLoop=function(he){te=he},this.dispose=function(){}}};const ph=new Dd,YDe=new gi;function ZDe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,QZ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,E,w,A){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(b,v):v.isMeshToonMaterial?(a(b,v),f(b,v)):v.isMeshPhongMaterial?(a(b,v),d(b,v)):v.isMeshStandardMaterial?(a(b,v),g(b,v),v.isMeshPhysicalMaterial&&p(b,v,A)):v.isMeshMatcapMaterial?(a(b,v),x(b,v)):v.isMeshDepthMaterial?a(b,v):v.isMeshDistanceMaterial?(a(b,v),y(b,v)):v.isMeshNormalMaterial?a(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,E,w):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===ss&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===ss&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const E=e.get(v),w=E.envMap,A=E.envMapRotation;w&&(b.envMap.value=w,ph.copy(A),ph.x*=-1,ph.y*=-1,ph.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(ph.y*=-1,ph.z*=-1),b.envMapRotation.value.setFromMatrix4(YDe.makeRotationFromEuler(ph)),b.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap&&(b.lightMap.value=v.lightMap,b.lightMapIntensity.value=v.lightMapIntensity,n(v.lightMap,b.lightMapTransform)),v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,E,w){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*E,b.scale.value=w*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function g(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),v.envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function p(b,v,E){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ss&&b.clearcoatNormalScale.value.negate())),v.dispersion>0&&(b.dispersion.value=v.dispersion),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=E.texture,b.transmissionSamplerSize.value.set(E.width,E.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const E=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(E.matrixWorld),b.nearDistance.value=E.shadow.camera.near,b.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function QDe(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",b));const N=w.program;r.updateUBOMapping(E,N);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),N=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,N,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<l;E++)if(o.indexOf(E)===-1)return o.push(E),E;return ti("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],A=E.uniforms,N=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,T=A.length;C<T;C++){const O=Array.isArray(A[C])?A[C]:[A[C]];for(let k=0,R=O.length;k<R;k++){const z=O[k];if(p(z,C,k,N)===!0){const D=z.__offset,K=Array.isArray(z.value)?z.value:[z.value];let P=0;for(let W=0;W<K.length;W++){const Z=K[W],G=y(Z);typeof Z=="number"||typeof Z=="boolean"?(z.__data[0]=Z,t.bufferSubData(t.UNIFORM_BUFFER,D+P,z.__data)):Z.isMatrix3?(z.__data[0]=Z.elements[0],z.__data[1]=Z.elements[1],z.__data[2]=Z.elements[2],z.__data[3]=0,z.__data[4]=Z.elements[3],z.__data[5]=Z.elements[4],z.__data[6]=Z.elements[5],z.__data[7]=0,z.__data[8]=Z.elements[6],z.__data[9]=Z.elements[7],z.__data[10]=Z.elements[8],z.__data[11]=0):(Z.toArray(z.__data,P),P+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,D,z.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,A,N){const C=E.value,T=w+"_"+A;if(N[T]===void 0)return typeof C=="number"||typeof C=="boolean"?N[T]=C:N[T]=C.clone(),!0;{const O=N[T];if(typeof C=="number"||typeof C=="boolean"){if(O!==C)return N[T]=C,!0}else if(O.equals(C)===!1)return O.copy(C),!0}return!1}function x(E){const w=E.uniforms;let A=0;const N=16;for(let T=0,O=w.length;T<O;T++){const k=Array.isArray(w[T])?w[T]:[w[T]];for(let R=0,z=k.length;R<z;R++){const D=k[R],K=Array.isArray(D.value)?D.value:[D.value];for(let P=0,W=K.length;P<W;P++){const Z=K[P],G=y(Z),Y=A%N,X=Y%G.boundary,q=Y+X;A+=X,q!==0&&N-q<G.storage&&(A+=N-q),D.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),D.__offset=A,A+=G.storage}}}const C=A%N;return C>0&&(A+=N-C),E.__size=A,E.__cache={},this}function y(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?rn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):rn("WebGLRenderer: Unsupported uniform value type.",E),w}function b(E){const w=E.target;w.removeEventListener("dispose",b);const A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function v(){for(const E in i)t.deleteBuffer(i[E]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}const JDe=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let cc=null;function eOe(){return cc===null&&(cc=new e3e(JDe,32,32,IO,Ng),cc.minFilter=ho,cc.magFilter=ho,cc.wrapS=jc,cc.wrapT=jc,cc.generateMipmaps=!1,cc.needsUpdate=!0),cc}let tOe=class{constructor(e={}){const{canvas:n=Eke(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:g=!1}=e;this.isWebGLRenderer=!0;let p;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=r.getContextAttributes().alpha}else p=o;const x=new Set([UO,FO,LO]),y=new Set([Cl,vf,ob,lb,DO,OO]),b=new Uint32Array(4),v=new Int32Array(4);let E=null,w=null;const A=[],N=[];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=pd,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let T=!1;this._outputColorSpace=no;let O=0,k=0,R=null,z=-1,D=null;const K=new hi,P=new hi;let W=null;const Z=new Tn(0);let G=0,Y=n.width,X=n.height,q=1,F=null,V=null;const te=new hi(0,0,Y,X),re=new hi(0,0,Y,X);let ae=!1;const he=new VO;let ue=!1,ce=!1;const fe=new gi,pe=new it,_e=new hi,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let He=!1;function B(){return R===null?q:1}let H=r;function le(oe,Ae){return n.getContext(oe,Ae)}try{const oe={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${jO}`),n.addEventListener("webglcontextlost",Pe,!1),n.addEventListener("webglcontextrestored",Me,!1),n.addEventListener("webglcontextcreationerror",Xe,!1),H===null){const Ae="webgl2";if(H=le(Ae,oe),H===null)throw le(Ae)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(oe){throw oe("WebGLRenderer: "+oe.message),oe}let $,ee,de,ke,we,Ee,U,I,se,ye,Se,ve,Be,Ge,Ke,ct,$e,ge,Je,qe,Ze,lt,ie,Ie;function xe(){$=new cRe(H),$.init(),lt=new GDe(H,$),ee=new eRe(H,$,e,lt),de=new $De(H,$),ee.reversedDepthBuffer&&g&&de.buffers.depth.setReversed(!0),ke=new hRe(H),we=new kDe,Ee=new VDe(H,$,de,we,ee,lt,ke),U=new nRe(C),I=new lRe(C),se=new g3e(H),ie=new QPe(H,se),ye=new uRe(H,se,ke,ie),Se=new mRe(H,ye,se,ke),Je=new fRe(H,ee,Ee),ct=new tRe(we),ve=new CDe(C,U,I,$,ee,ie,ct),Be=new ZDe(C,we),Ge=new PDe,Ke=new FDe($),ge=new ZPe(C,U,I,de,Se,p,c),$e=new BDe(C,Se,ee),Ie=new QDe(H,ke,ee,de),qe=new JPe(H,$,ke),Ze=new dRe(H,$,ke),ke.programs=ve.programs,C.capabilities=ee,C.extensions=$,C.properties=we,C.renderLists=Ge,C.shadowMap=$e,C.state=de,C.info=ke}xe();const Ue=new XDe(C,H);this.xr=Ue,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const oe=$.get("WEBGL_lose_context");oe&&oe.loseContext()},this.forceContextRestore=function(){const oe=$.get("WEBGL_lose_context");oe&&oe.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(oe){oe!==void 0&&(q=oe,this.setSize(Y,X,!1))},this.getSize=function(oe){return oe.set(Y,X)},this.setSize=function(oe,Ae,Re=!0){if(Ue.isPresenting){rn("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=oe,X=Ae,n.width=Math.floor(oe*q),n.height=Math.floor(Ae*q),Re===!0&&(n.style.width=oe+"px",n.style.height=Ae+"px"),this.setViewport(0,0,oe,Ae)},this.getDrawingBufferSize=function(oe){return oe.set(Y*q,X*q).floor()},this.setDrawingBufferSize=function(oe,Ae,Re){Y=oe,X=Ae,q=Re,n.width=Math.floor(oe*Re),n.height=Math.floor(Ae*Re),this.setViewport(0,0,oe,Ae)},this.getCurrentViewport=function(oe){return oe.copy(K)},this.getViewport=function(oe){return oe.copy(te)},this.setViewport=function(oe,Ae,Re,De){oe.isVector4?te.set(oe.x,oe.y,oe.z,oe.w):te.set(oe,Ae,Re,De),de.viewport(K.copy(te).multiplyScalar(q).round())},this.getScissor=function(oe){return oe.copy(re)},this.setScissor=function(oe,Ae,Re,De){oe.isVector4?re.set(oe.x,oe.y,oe.z,oe.w):re.set(oe,Ae,Re,De),de.scissor(P.copy(re).multiplyScalar(q).round())},this.getScissorTest=function(){return ae},this.setScissorTest=function(oe){de.setScissorTest(ae=oe)},this.setOpaqueSort=function(oe){F=oe},this.setTransparentSort=function(oe){V=oe},this.getClearColor=function(oe){return oe.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor(...arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha(...arguments)},this.clear=function(oe=!0,Ae=!0,Re=!0){let De=0;if(oe){let je=!1;if(R!==null){const at=R.texture.format;je=x.has(at)}if(je){const at=R.texture.type,bt=y.has(at),Tt=ge.getClearColor(),Nt=ge.getClearAlpha(),Ft=Tt.r,jt=Tt.g,_t=Tt.b;bt?(b[0]=Ft,b[1]=jt,b[2]=_t,b[3]=Nt,H.clearBufferuiv(H.COLOR,0,b)):(v[0]=Ft,v[1]=jt,v[2]=_t,v[3]=Nt,H.clearBufferiv(H.COLOR,0,v))}else De|=H.COLOR_BUFFER_BIT}Ae&&(De|=H.DEPTH_BUFFER_BIT),Re&&(De|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(De)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Pe,!1),n.removeEventListener("webglcontextrestored",Me,!1),n.removeEventListener("webglcontextcreationerror",Xe,!1),ge.dispose(),Ge.dispose(),Ke.dispose(),we.dispose(),U.dispose(),I.dispose(),Se.dispose(),ie.dispose(),Ie.dispose(),ve.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",Fn),Ue.removeEventListener("sessionend",Sn),vr.stop()};function Pe(oe){oe.preventDefault(),TH("WebGLRenderer: Context Lost."),T=!0}function Me(){TH("WebGLRenderer: Context Restored."),T=!1;const oe=ke.autoReset,Ae=$e.enabled,Re=$e.autoUpdate,De=$e.needsUpdate,je=$e.type;xe(),ke.autoReset=oe,$e.enabled=Ae,$e.autoUpdate=Re,$e.needsUpdate=De,$e.type=je}function Xe(oe){ti("WebGLRenderer: A WebGL context could not be created. Reason: ",oe.statusMessage)}function ut(oe){const Ae=oe.target;Ae.removeEventListener("dispose",ut),At(Ae)}function At(oe){St(oe),we.remove(oe)}function St(oe){const Ae=we.get(oe).programs;Ae!==void 0&&(Ae.forEach(function(Re){ve.releaseProgram(Re)}),oe.isShaderMaterial&&ve.releaseShaderCache(oe))}this.renderBufferDirect=function(oe,Ae,Re,De,je,at){Ae===null&&(Ae=ne);const bt=je.isMesh&&je.matrixWorld.determinant()<0,Tt=J(oe,Ae,Re,De,je);de.setMaterial(De,bt);let Nt=Re.index,Ft=1;if(De.wireframe===!0){if(Nt=ye.getWireframeAttribute(Re),Nt===void 0)return;Ft=2}const jt=Re.drawRange,_t=Re.attributes.position;let nn=jt.start*Ft,Vt=(jt.start+jt.count)*Ft;at!==null&&(nn=Math.max(nn,at.start*Ft),Vt=Math.min(Vt,(at.start+at.count)*Ft)),Nt!==null?(nn=Math.max(nn,0),Vt=Math.min(Vt,Nt.count)):_t!=null&&(nn=Math.max(nn,0),Vt=Math.min(Vt,_t.count));const fn=Vt-nn;if(fn<0||fn===1/0)return;ie.setup(je,De,Tt,Re,Nt);let _n,jn=qe;if(Nt!==null&&(_n=se.get(Nt),jn=Ze,jn.setIndex(_n)),je.isMesh)De.wireframe===!0?(de.setLineWidth(De.wireframeLinewidth*B()),jn.setMode(H.LINES)):jn.setMode(H.TRIANGLES);else if(je.isLine){let Bt=De.linewidth;Bt===void 0&&(Bt=1),de.setLineWidth(Bt*B()),je.isLineSegments?jn.setMode(H.LINES):je.isLineLoop?jn.setMode(H.LINE_LOOP):jn.setMode(H.LINE_STRIP)}else je.isPoints?jn.setMode(H.POINTS):je.isSprite&&jn.setMode(H.TRIANGLES);if(je.isBatchedMesh)if(je._multiDrawInstances!==null)db("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),jn.renderMultiDrawInstances(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount,je._multiDrawInstances);else if($.get("WEBGL_multi_draw"))jn.renderMultiDraw(je._multiDrawStarts,je._multiDrawCounts,je._multiDrawCount);else{const Bt=je._multiDrawStarts,sn=je._multiDrawCounts,un=je._multiDrawCount,zr=Nt?se.get(Nt).bytesPerElement:1,Yr=we.get(De).currentProgram.getUniforms();for(let Gn=0;Gn<un;Gn++)Yr.setValue(H,"_gl_DrawID",Gn),jn.render(Bt[Gn]/zr,sn[Gn])}else if(je.isInstancedMesh)jn.renderInstances(nn,fn,je.count);else if(Re.isInstancedBufferGeometry){const Bt=Re._maxInstanceCount!==void 0?Re._maxInstanceCount:1/0,sn=Math.min(Re.instanceCount,Bt);jn.renderInstances(nn,fn,sn)}else jn.render(nn,fn)};function Yt(oe,Ae,Re){oe.transparent===!0&&oe.side===ml&&oe.forceSinglePass===!1?(oe.side=ss,oe.needsUpdate=!0,cn(oe,Ae,Re),oe.side=Rd,oe.needsUpdate=!0,cn(oe,Ae,Re),oe.side=ml):cn(oe,Ae,Re)}this.compile=function(oe,Ae,Re=null){Re===null&&(Re=oe),w=Ke.get(Re),w.init(Ae),N.push(w),Re.traverseVisible(function(je){je.isLight&&je.layers.test(Ae.layers)&&(w.pushLight(je),je.castShadow&&w.pushShadow(je))}),oe!==Re&&oe.traverseVisible(function(je){je.isLight&&je.layers.test(Ae.layers)&&(w.pushLight(je),je.castShadow&&w.pushShadow(je))}),w.setupLights();const De=new Set;return oe.traverse(function(je){if(!(je.isMesh||je.isPoints||je.isLine||je.isSprite))return;const at=je.material;if(at)if(Array.isArray(at))for(let bt=0;bt<at.length;bt++){const Tt=at[bt];Yt(Tt,Re,je),De.add(Tt)}else Yt(at,Re,je),De.add(at)}),w=N.pop(),De},this.compileAsync=function(oe,Ae,Re=null){const De=this.compile(oe,Ae,Re);return new Promise(je=>{function at(){if(De.forEach(function(bt){we.get(bt).currentProgram.isReady()&&De.delete(bt)}),De.size===0){je(oe);return}setTimeout(at,10)}$.get("KHR_parallel_shader_compile")!==null?at():setTimeout(at,10)})};let Pt=null;function Jt(oe){Pt&&Pt(oe)}function Fn(){vr.stop()}function Sn(){vr.start()}const vr=new oQ;vr.setAnimationLoop(Jt),typeof self<"u"&&vr.setContext(self),this.setAnimationLoop=function(oe){Pt=oe,Ue.setAnimationLoop(oe),oe===null?vr.stop():vr.start()},Ue.addEventListener("sessionstart",Fn),Ue.addEventListener("sessionend",Sn),this.render=function(oe,Ae){if(Ae!==void 0&&Ae.isCamera!==!0){ti("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;if(oe.matrixWorldAutoUpdate===!0&&oe.updateMatrixWorld(),Ae.parent===null&&Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),Ue.enabled===!0&&Ue.isPresenting===!0&&(Ue.cameraAutoUpdate===!0&&Ue.updateCamera(Ae),Ae=Ue.getCamera()),oe.isScene===!0&&oe.onBeforeRender(C,oe,Ae,R),w=Ke.get(oe,N.length),w.init(Ae),N.push(w),fe.multiplyMatrices(Ae.projectionMatrix,Ae.matrixWorldInverse),he.setFromProjectionMatrix(fe,bl,Ae.reversedDepth),ce=this.localClippingEnabled,ue=ct.init(this.clippingPlanes,ce),E=Ge.get(oe,A.length),E.init(),A.push(E),Ue.enabled===!0&&Ue.isPresenting===!0){const at=C.xr.getDepthSensingMesh();at!==null&&ft(at,Ae,-1/0,C.sortObjects)}ft(oe,Ae,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(F,V),He=Ue.enabled===!1||Ue.isPresenting===!1||Ue.hasDepthSensing()===!1,He&&ge.addToRenderList(E,oe),this.info.render.frame++,ue===!0&&ct.beginShadows();const Re=w.state.shadowsArray;$e.render(Re,oe,Ae),ue===!0&&ct.endShadows(),this.info.autoReset===!0&&this.info.reset();const De=E.opaque,je=E.transmissive;if(w.setupLights(),Ae.isArrayCamera){const at=Ae.cameras;if(je.length>0)for(let bt=0,Tt=at.length;bt<Tt;bt++){const Nt=at[bt];Qt(De,je,oe,Nt)}He&&ge.render(oe);for(let bt=0,Tt=at.length;bt<Tt;bt++){const Nt=at[bt];Ht(E,oe,Nt,Nt.viewport)}}else je.length>0&&Qt(De,je,oe,Ae),He&&ge.render(oe),Ht(E,oe,Ae);R!==null&&k===0&&(Ee.updateMultisampleRenderTarget(R),Ee.updateRenderTargetMipmap(R)),oe.isScene===!0&&oe.onAfterRender(C,oe,Ae),ie.resetDefaultState(),z=-1,D=null,N.pop(),N.length>0?(w=N[N.length-1],ue===!0&&ct.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function ft(oe,Ae,Re,De){if(oe.visible===!1)return;if(oe.layers.test(Ae.layers)){if(oe.isGroup)Re=oe.renderOrder;else if(oe.isLOD)oe.autoUpdate===!0&&oe.update(Ae);else if(oe.isLight)w.pushLight(oe),oe.castShadow&&w.pushShadow(oe);else if(oe.isSprite){if(!oe.frustumCulled||he.intersectsSprite(oe)){De&&_e.setFromMatrixPosition(oe.matrixWorld).applyMatrix4(fe);const bt=Se.update(oe),Tt=oe.material;Tt.visible&&E.push(oe,bt,Tt,Re,_e.z,null)}}else if((oe.isMesh||oe.isLine||oe.isPoints)&&(!oe.frustumCulled||he.intersectsObject(oe))){const bt=Se.update(oe),Tt=oe.material;if(De&&(oe.boundingSphere!==void 0?(oe.boundingSphere===null&&oe.computeBoundingSphere(),_e.copy(oe.boundingSphere.center)):(bt.boundingSphere===null&&bt.computeBoundingSphere(),_e.copy(bt.boundingSphere.center)),_e.applyMatrix4(oe.matrixWorld).applyMatrix4(fe)),Array.isArray(Tt)){const Nt=bt.groups;for(let Ft=0,jt=Nt.length;Ft<jt;Ft++){const _t=Nt[Ft],nn=Tt[_t.materialIndex];nn&&nn.visible&&E.push(oe,bt,nn,Re,_e.z,_t)}}else Tt.visible&&E.push(oe,bt,Tt,Re,_e.z,null)}}const at=oe.children;for(let bt=0,Tt=at.length;bt<Tt;bt++)ft(at[bt],Ae,Re,De)}function Ht(oe,Ae,Re,De){const{opaque:je,transmissive:at,transparent:bt}=oe;w.setupLightsView(Re),ue===!0&&ct.setGlobalState(C.clippingPlanes,Re),De&&de.viewport(K.copy(De)),je.length>0&&mt(je,Ae,Re),at.length>0&&mt(at,Ae,Re),bt.length>0&&mt(bt,Ae,Re),de.buffers.depth.setTest(!0),de.buffers.depth.setMask(!0),de.buffers.color.setMask(!0),de.setPolygonOffset(!1)}function Qt(oe,Ae,Re,De){if((Re.isScene===!0?Re.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[De.id]===void 0&&(w.state.transmissionRenderTarget[De.id]=new wf(1,1,{generateMipmaps:!0,type:$.has("EXT_color_buffer_half_float")||$.has("EXT_color_buffer_float")?Ng:Cl,minFilter:Fh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Bn.workingColorSpace}));const at=w.state.transmissionRenderTarget[De.id],bt=De.viewport||K;at.setSize(bt.z*C.transmissionResolutionScale,bt.w*C.transmissionResolutionScale);const Tt=C.getRenderTarget(),Nt=C.getActiveCubeFace(),Ft=C.getActiveMipmapLevel();C.setRenderTarget(at),C.getClearColor(Z),G=C.getClearAlpha(),G<1&&C.setClearColor(16777215,.5),C.clear(),He&&ge.render(Re);const jt=C.toneMapping;C.toneMapping=pd;const _t=De.viewport;if(De.viewport!==void 0&&(De.viewport=void 0),w.setupLightsView(De),ue===!0&&ct.setGlobalState(C.clippingPlanes,De),mt(oe,Re,De),Ee.updateMultisampleRenderTarget(at),Ee.updateRenderTargetMipmap(at),$.has("WEBGL_multisampled_render_to_texture")===!1){let nn=!1;for(let Vt=0,fn=Ae.length;Vt<fn;Vt++){const _n=Ae[Vt],{object:jn,geometry:Bt,material:sn,group:un}=_n;if(sn.side===ml&&jn.layers.test(De.layers)){const zr=sn.side;sn.side=ss,sn.needsUpdate=!0,$t(jn,Re,De,Bt,sn,un),sn.side=zr,sn.needsUpdate=!0,nn=!0}}nn===!0&&(Ee.updateMultisampleRenderTarget(at),Ee.updateRenderTargetMipmap(at))}C.setRenderTarget(Tt,Nt,Ft),C.setClearColor(Z,G),_t!==void 0&&(De.viewport=_t),C.toneMapping=jt}function mt(oe,Ae,Re){const De=Ae.isScene===!0?Ae.overrideMaterial:null;for(let je=0,at=oe.length;je<at;je++){const bt=oe[je],{object:Tt,geometry:Nt,group:Ft}=bt;let jt=bt.material;jt.allowOverride===!0&&De!==null&&(jt=De),Tt.layers.test(Re.layers)&&$t(Tt,Ae,Re,Nt,jt,Ft)}}function $t(oe,Ae,Re,De,je,at){oe.onBeforeRender(C,Ae,Re,De,je,at),oe.modelViewMatrix.multiplyMatrices(Re.matrixWorldInverse,oe.matrixWorld),oe.normalMatrix.getNormalMatrix(oe.modelViewMatrix),je.onBeforeRender(C,Ae,Re,De,oe,at),je.transparent===!0&&je.side===ml&&je.forceSinglePass===!1?(je.side=ss,je.needsUpdate=!0,C.renderBufferDirect(Re,Ae,De,je,oe,at),je.side=Rd,je.needsUpdate=!0,C.renderBufferDirect(Re,Ae,De,je,oe,at),je.side=ml):C.renderBufferDirect(Re,Ae,De,je,oe,at),oe.onAfterRender(C,Ae,Re,De,je,at)}function cn(oe,Ae,Re){Ae.isScene!==!0&&(Ae=ne);const De=we.get(oe),je=w.state.lights,at=w.state.shadowsArray,bt=je.state.version,Tt=ve.getParameters(oe,je.state,at,Ae,Re),Nt=ve.getProgramCacheKey(Tt);let Ft=De.programs;De.environment=oe.isMeshStandardMaterial?Ae.environment:null,De.fog=Ae.fog,De.envMap=(oe.isMeshStandardMaterial?I:U).get(oe.envMap||De.environment),De.envMapRotation=De.environment!==null&&oe.envMap===null?Ae.environmentRotation:oe.envMapRotation,Ft===void 0&&(oe.addEventListener("dispose",ut),Ft=new Map,De.programs=Ft);let jt=Ft.get(Nt);if(jt!==void 0){if(De.currentProgram===jt&&De.lightsStateVersion===bt)return qt(oe,Tt),jt}else Tt.uniforms=ve.getUniforms(oe),oe.onBeforeCompile(Tt,C),jt=ve.acquireProgram(Tt,Nt),Ft.set(Nt,jt),De.uniforms=Tt.uniforms;const _t=De.uniforms;return(!oe.isShaderMaterial&&!oe.isRawShaderMaterial||oe.clipping===!0)&&(_t.clippingPlanes=ct.uniform),qt(oe,Tt),De.needsLights=ze(oe),De.lightsStateVersion=bt,De.needsLights&&(_t.ambientLightColor.value=je.state.ambient,_t.lightProbe.value=je.state.probe,_t.directionalLights.value=je.state.directional,_t.directionalLightShadows.value=je.state.directionalShadow,_t.spotLights.value=je.state.spot,_t.spotLightShadows.value=je.state.spotShadow,_t.rectAreaLights.value=je.state.rectArea,_t.ltc_1.value=je.state.rectAreaLTC1,_t.ltc_2.value=je.state.rectAreaLTC2,_t.pointLights.value=je.state.point,_t.pointLightShadows.value=je.state.pointShadow,_t.hemisphereLights.value=je.state.hemi,_t.directionalShadowMap.value=je.state.directionalShadowMap,_t.directionalShadowMatrix.value=je.state.directionalShadowMatrix,_t.spotShadowMap.value=je.state.spotShadowMap,_t.spotLightMatrix.value=je.state.spotLightMatrix,_t.spotLightMap.value=je.state.spotLightMap,_t.pointShadowMap.value=je.state.pointShadowMap,_t.pointShadowMatrix.value=je.state.pointShadowMatrix),De.currentProgram=jt,De.uniformsList=null,jt}function Mn(oe){if(oe.uniformsList===null){const Ae=oe.currentProgram.getUniforms();oe.uniformsList=L1.seqWithValue(Ae.seq,oe.uniforms)}return oe.uniformsList}function qt(oe,Ae){const Re=we.get(oe);Re.outputColorSpace=Ae.outputColorSpace,Re.batching=Ae.batching,Re.batchingColor=Ae.batchingColor,Re.instancing=Ae.instancing,Re.instancingColor=Ae.instancingColor,Re.instancingMorph=Ae.instancingMorph,Re.skinning=Ae.skinning,Re.morphTargets=Ae.morphTargets,Re.morphNormals=Ae.morphNormals,Re.morphColors=Ae.morphColors,Re.morphTargetsCount=Ae.morphTargetsCount,Re.numClippingPlanes=Ae.numClippingPlanes,Re.numIntersection=Ae.numClipIntersection,Re.vertexAlphas=Ae.vertexAlphas,Re.vertexTangents=Ae.vertexTangents,Re.toneMapping=Ae.toneMapping}function J(oe,Ae,Re,De,je){Ae.isScene!==!0&&(Ae=ne),Ee.resetTextureUnits();const at=Ae.fog,bt=De.isMeshStandardMaterial?Ae.environment:null,Tt=R===null?C.outputColorSpace:R.isXRRenderTarget===!0?R.texture.colorSpace:Kp,Nt=(De.isMeshStandardMaterial?I:U).get(De.envMap||bt),Ft=De.vertexColors===!0&&!!Re.attributes.color&&Re.attributes.color.itemSize===4,jt=!!Re.attributes.tangent&&(!!De.normalMap||De.anisotropy>0),_t=!!Re.morphAttributes.position,nn=!!Re.morphAttributes.normal,Vt=!!Re.morphAttributes.color;let fn=pd;De.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(fn=C.toneMapping);const _n=Re.morphAttributes.position||Re.morphAttributes.normal||Re.morphAttributes.color,jn=_n!==void 0?_n.length:0,Bt=we.get(De),sn=w.state.lights;if(ue===!0&&(ce===!0||oe!==D)){const Ii=oe===D&&De.id===z;ct.setState(De,oe,Ii)}let un=!1;De.version===Bt.__version?(Bt.needsLights&&Bt.lightsStateVersion!==sn.state.version||Bt.outputColorSpace!==Tt||je.isBatchedMesh&&Bt.batching===!1||!je.isBatchedMesh&&Bt.batching===!0||je.isBatchedMesh&&Bt.batchingColor===!0&&je.colorTexture===null||je.isBatchedMesh&&Bt.batchingColor===!1&&je.colorTexture!==null||je.isInstancedMesh&&Bt.instancing===!1||!je.isInstancedMesh&&Bt.instancing===!0||je.isSkinnedMesh&&Bt.skinning===!1||!je.isSkinnedMesh&&Bt.skinning===!0||je.isInstancedMesh&&Bt.instancingColor===!0&&je.instanceColor===null||je.isInstancedMesh&&Bt.instancingColor===!1&&je.instanceColor!==null||je.isInstancedMesh&&Bt.instancingMorph===!0&&je.morphTexture===null||je.isInstancedMesh&&Bt.instancingMorph===!1&&je.morphTexture!==null||Bt.envMap!==Nt||De.fog===!0&&Bt.fog!==at||Bt.numClippingPlanes!==void 0&&(Bt.numClippingPlanes!==ct.numPlanes||Bt.numIntersection!==ct.numIntersection)||Bt.vertexAlphas!==Ft||Bt.vertexTangents!==jt||Bt.morphTargets!==_t||Bt.morphNormals!==nn||Bt.morphColors!==Vt||Bt.toneMapping!==fn||Bt.morphTargetsCount!==jn)&&(un=!0):(un=!0,Bt.__version=De.version);let zr=Bt.currentProgram;un===!0&&(zr=cn(De,Ae,je));let Yr=!1,Gn=!1,So=!1;const qn=zr.getUniforms(),Li=Bt.uniforms;if(de.useProgram(zr.program)&&(Yr=!0,Gn=!0,So=!0),De.id!==z&&(z=De.id,Gn=!0),Yr||D!==oe){de.buffers.depth.getReversed()&&oe.reversedDepth!==!0&&(oe._reversedDepth=!0,oe.updateProjectionMatrix()),qn.setValue(H,"projectionMatrix",oe.projectionMatrix),qn.setValue(H,"viewMatrix",oe.matrixWorldInverse);const Zi=qn.map.cameraPosition;Zi!==void 0&&Zi.setValue(H,pe.setFromMatrixPosition(oe.matrixWorld)),ee.logarithmicDepthBuffer&&qn.setValue(H,"logDepthBufFC",2/(Math.log(oe.far+1)/Math.LN2)),(De.isMeshPhongMaterial||De.isMeshToonMaterial||De.isMeshLambertMaterial||De.isMeshBasicMaterial||De.isMeshStandardMaterial||De.isShaderMaterial)&&qn.setValue(H,"isOrthographic",oe.isOrthographicCamera===!0),D!==oe&&(D=oe,Gn=!0,So=!0)}if(je.isSkinnedMesh){qn.setOptional(H,je,"bindMatrix"),qn.setOptional(H,je,"bindMatrixInverse");const Ii=je.skeleton;Ii&&(Ii.boneTexture===null&&Ii.computeBoneTexture(),qn.setValue(H,"boneTexture",Ii.boneTexture,Ee))}je.isBatchedMesh&&(qn.setOptional(H,je,"batchingTexture"),qn.setValue(H,"batchingTexture",je._matricesTexture,Ee),qn.setOptional(H,je,"batchingIdTexture"),qn.setValue(H,"batchingIdTexture",je._indirectTexture,Ee),qn.setOptional(H,je,"batchingColorTexture"),je._colorsTexture!==null&&qn.setValue(H,"batchingColorTexture",je._colorsTexture,Ee));const bi=Re.morphAttributes;if((bi.position!==void 0||bi.normal!==void 0||bi.color!==void 0)&&Je.update(je,Re,zr),(Gn||Bt.receiveShadow!==je.receiveShadow)&&(Bt.receiveShadow=je.receiveShadow,qn.setValue(H,"receiveShadow",je.receiveShadow)),De.isMeshGouraudMaterial&&De.envMap!==null&&(Li.envMap.value=Nt,Li.flipEnvMap.value=Nt.isCubeTexture&&Nt.isRenderTargetTexture===!1?-1:1),De.isMeshStandardMaterial&&De.envMap===null&&Ae.environment!==null&&(Li.envMapIntensity.value=Ae.environmentIntensity),Li.dfgLUT!==void 0&&(Li.dfgLUT.value=eOe()),Gn&&(qn.setValue(H,"toneMappingExposure",C.toneMappingExposure),Bt.needsLights&&Ne(Li,So),at&&De.fog===!0&&Be.refreshFogUniforms(Li,at),Be.refreshMaterialUniforms(Li,De,q,X,w.state.transmissionRenderTarget[oe.id]),L1.upload(H,Mn(Bt),Li,Ee)),De.isShaderMaterial&&De.uniformsNeedUpdate===!0&&(L1.upload(H,Mn(Bt),Li,Ee),De.uniformsNeedUpdate=!1),De.isSpriteMaterial&&qn.setValue(H,"center",je.center),qn.setValue(H,"modelViewMatrix",je.modelViewMatrix),qn.setValue(H,"normalMatrix",je.normalMatrix),qn.setValue(H,"modelMatrix",je.matrixWorld),De.isShaderMaterial||De.isRawShaderMaterial){const Ii=De.uniformsGroups;for(let Zi=0,el=Ii.length;Zi<el;Zi++){const zl=Ii[Zi];Ie.update(zl,zr),Ie.bind(zl,zr)}}return zr}function Ne(oe,Ae){oe.ambientLightColor.needsUpdate=Ae,oe.lightProbe.needsUpdate=Ae,oe.directionalLights.needsUpdate=Ae,oe.directionalLightShadows.needsUpdate=Ae,oe.pointLights.needsUpdate=Ae,oe.pointLightShadows.needsUpdate=Ae,oe.spotLights.needsUpdate=Ae,oe.spotLightShadows.needsUpdate=Ae,oe.rectAreaLights.needsUpdate=Ae,oe.hemisphereLights.needsUpdate=Ae}function ze(oe){return oe.isMeshLambertMaterial||oe.isMeshToonMaterial||oe.isMeshPhongMaterial||oe.isMeshStandardMaterial||oe.isShadowMaterial||oe.isShaderMaterial&&oe.lights===!0}this.getActiveCubeFace=function(){return O},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return R},this.setRenderTargetTextures=function(oe,Ae,Re){const De=we.get(oe);De.__autoAllocateDepthBuffer=oe.resolveDepthBuffer===!1,De.__autoAllocateDepthBuffer===!1&&(De.__useRenderToTexture=!1),we.get(oe.texture).__webglTexture=Ae,we.get(oe.depthTexture).__webglTexture=De.__autoAllocateDepthBuffer?void 0:Re,De.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(oe,Ae){const Re=we.get(oe);Re.__webglFramebuffer=Ae,Re.__useDefaultFramebuffer=Ae===void 0};const Ye=H.createFramebuffer();this.setRenderTarget=function(oe,Ae=0,Re=0){R=oe,O=Ae,k=Re;let De=!0,je=null,at=!1,bt=!1;if(oe){const Nt=we.get(oe);if(Nt.__useDefaultFramebuffer!==void 0)de.bindFramebuffer(H.FRAMEBUFFER,null),De=!1;else if(Nt.__webglFramebuffer===void 0)Ee.setupRenderTarget(oe);else if(Nt.__hasExternalTextures)Ee.rebindTextures(oe,we.get(oe.texture).__webglTexture,we.get(oe.depthTexture).__webglTexture);else if(oe.depthBuffer){const _t=oe.depthTexture;if(Nt.__boundDepthTexture!==_t){if(_t!==null&&we.has(_t)&&(oe.width!==_t.image.width||oe.height!==_t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Ee.setupDepthRenderbuffer(oe)}}const Ft=oe.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(bt=!0);const jt=we.get(oe).__webglFramebuffer;oe.isWebGLCubeRenderTarget?(Array.isArray(jt[Ae])?je=jt[Ae][Re]:je=jt[Ae],at=!0):oe.samples>0&&Ee.useMultisampledRTT(oe)===!1?je=we.get(oe).__webglMultisampledFramebuffer:Array.isArray(jt)?je=jt[Re]:je=jt,K.copy(oe.viewport),P.copy(oe.scissor),W=oe.scissorTest}else K.copy(te).multiplyScalar(q).floor(),P.copy(re).multiplyScalar(q).floor(),W=ae;if(Re!==0&&(je=Ye),de.bindFramebuffer(H.FRAMEBUFFER,je)&&De&&de.drawBuffers(oe,je),de.viewport(K),de.scissor(P),de.setScissorTest(W),at){const Nt=we.get(oe.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Nt.__webglTexture,Re)}else if(bt){const Nt=Ae;for(let Ft=0;Ft<oe.textures.length;Ft++){const jt=we.get(oe.textures[Ft]);H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0+Ft,jt.__webglTexture,Re,Nt)}}else if(oe!==null&&Re!==0){const Nt=we.get(oe.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Nt.__webglTexture,Re)}z=-1},this.readRenderTargetPixels=function(oe,Ae,Re,De,je,at,bt,Tt=0){if(!(oe&&oe.isWebGLRenderTarget)){ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Nt=we.get(oe).__webglFramebuffer;if(oe.isWebGLCubeRenderTarget&&bt!==void 0&&(Nt=Nt[bt]),Nt){de.bindFramebuffer(H.FRAMEBUFFER,Nt);try{const Ft=oe.textures[Tt],jt=Ft.format,_t=Ft.type;if(!ee.textureFormatReadable(jt)){ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ee.textureTypeReadable(_t)){ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ae>=0&&Ae<=oe.width-De&&Re>=0&&Re<=oe.height-je&&(oe.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Tt),H.readPixels(Ae,Re,De,je,lt.convert(jt),lt.convert(_t),at))}finally{const Ft=R!==null?we.get(R).__webglFramebuffer:null;de.bindFramebuffer(H.FRAMEBUFFER,Ft)}}},this.readRenderTargetPixelsAsync=async function(oe,Ae,Re,De,je,at,bt,Tt=0){if(!(oe&&oe.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Nt=we.get(oe).__webglFramebuffer;if(oe.isWebGLCubeRenderTarget&&bt!==void 0&&(Nt=Nt[bt]),Nt)if(Ae>=0&&Ae<=oe.width-De&&Re>=0&&Re<=oe.height-je){de.bindFramebuffer(H.FRAMEBUFFER,Nt);const Ft=oe.textures[Tt],jt=Ft.format,_t=Ft.type;if(!ee.textureFormatReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ee.textureTypeReadable(_t))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const nn=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,nn),H.bufferData(H.PIXEL_PACK_BUFFER,at.byteLength,H.STREAM_READ),oe.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+Tt),H.readPixels(Ae,Re,De,je,lt.convert(jt),lt.convert(_t),0);const Vt=R!==null?we.get(R).__webglFramebuffer:null;de.bindFramebuffer(H.FRAMEBUFFER,Vt);const fn=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await Nke(H,fn,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,nn),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,at),H.deleteBuffer(nn),H.deleteSync(fn),at}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(oe,Ae=null,Re=0){const De=Math.pow(2,-Re),je=Math.floor(oe.image.width*De),at=Math.floor(oe.image.height*De),bt=Ae!==null?Ae.x:0,Tt=Ae!==null?Ae.y:0;Ee.setTexture2D(oe,0),H.copyTexSubImage2D(H.TEXTURE_2D,Re,0,0,bt,Tt,je,at),de.unbindTexture()};const nt=H.createFramebuffer(),Et=H.createFramebuffer();this.copyTextureToTexture=function(oe,Ae,Re=null,De=null,je=0,at=null){at===null&&(je!==0?(db("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),at=je,je=0):at=0);let bt,Tt,Nt,Ft,jt,_t,nn,Vt,fn;const _n=oe.isCompressedTexture?oe.mipmaps[at]:oe.image;if(Re!==null)bt=Re.max.x-Re.min.x,Tt=Re.max.y-Re.min.y,Nt=Re.isBox3?Re.max.z-Re.min.z:1,Ft=Re.min.x,jt=Re.min.y,_t=Re.isBox3?Re.min.z:0;else{const bi=Math.pow(2,-je);bt=Math.floor(_n.width*bi),Tt=Math.floor(_n.height*bi),oe.isDataArrayTexture?Nt=_n.depth:oe.isData3DTexture?Nt=Math.floor(_n.depth*bi):Nt=1,Ft=0,jt=0,_t=0}De!==null?(nn=De.x,Vt=De.y,fn=De.z):(nn=0,Vt=0,fn=0);const jn=lt.convert(Ae.format),Bt=lt.convert(Ae.type);let sn;Ae.isData3DTexture?(Ee.setTexture3D(Ae,0),sn=H.TEXTURE_3D):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?(Ee.setTexture2DArray(Ae,0),sn=H.TEXTURE_2D_ARRAY):(Ee.setTexture2D(Ae,0),sn=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,Ae.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ae.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,Ae.unpackAlignment);const un=H.getParameter(H.UNPACK_ROW_LENGTH),zr=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Yr=H.getParameter(H.UNPACK_SKIP_PIXELS),Gn=H.getParameter(H.UNPACK_SKIP_ROWS),So=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,_n.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,_n.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Ft),H.pixelStorei(H.UNPACK_SKIP_ROWS,jt),H.pixelStorei(H.UNPACK_SKIP_IMAGES,_t);const qn=oe.isDataArrayTexture||oe.isData3DTexture,Li=Ae.isDataArrayTexture||Ae.isData3DTexture;if(oe.isDepthTexture){const bi=we.get(oe),Ii=we.get(Ae),Zi=we.get(bi.__renderTarget),el=we.get(Ii.__renderTarget);de.bindFramebuffer(H.READ_FRAMEBUFFER,Zi.__webglFramebuffer),de.bindFramebuffer(H.DRAW_FRAMEBUFFER,el.__webglFramebuffer);for(let zl=0;zl<Nt;zl++)qn&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,we.get(oe).__webglTexture,je,_t+zl),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,we.get(Ae).__webglTexture,at,fn+zl)),H.blitFramebuffer(Ft,jt,bt,Tt,nn,Vt,bt,Tt,H.DEPTH_BUFFER_BIT,H.NEAREST);de.bindFramebuffer(H.READ_FRAMEBUFFER,null),de.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(je!==0||oe.isRenderTargetTexture||we.has(oe)){const bi=we.get(oe),Ii=we.get(Ae);de.bindFramebuffer(H.READ_FRAMEBUFFER,nt),de.bindFramebuffer(H.DRAW_FRAMEBUFFER,Et);for(let Zi=0;Zi<Nt;Zi++)qn?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,bi.__webglTexture,je,_t+Zi):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,bi.__webglTexture,je),Li?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Ii.__webglTexture,at,fn+Zi):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Ii.__webglTexture,at),je!==0?H.blitFramebuffer(Ft,jt,bt,Tt,nn,Vt,bt,Tt,H.COLOR_BUFFER_BIT,H.NEAREST):Li?H.copyTexSubImage3D(sn,at,nn,Vt,fn+Zi,Ft,jt,bt,Tt):H.copyTexSubImage2D(sn,at,nn,Vt,Ft,jt,bt,Tt);de.bindFramebuffer(H.READ_FRAMEBUFFER,null),de.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Li?oe.isDataTexture||oe.isData3DTexture?H.texSubImage3D(sn,at,nn,Vt,fn,bt,Tt,Nt,jn,Bt,_n.data):Ae.isCompressedArrayTexture?H.compressedTexSubImage3D(sn,at,nn,Vt,fn,bt,Tt,Nt,jn,_n.data):H.texSubImage3D(sn,at,nn,Vt,fn,bt,Tt,Nt,jn,Bt,_n):oe.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,at,nn,Vt,bt,Tt,jn,Bt,_n.data):oe.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,at,nn,Vt,_n.width,_n.height,jn,_n.data):H.texSubImage2D(H.TEXTURE_2D,at,nn,Vt,bt,Tt,jn,Bt,_n);H.pixelStorei(H.UNPACK_ROW_LENGTH,un),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,zr),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Yr),H.pixelStorei(H.UNPACK_SKIP_ROWS,Gn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,So),at===0&&Ae.generateMipmaps&&H.generateMipmap(sn),de.unbindTexture()},this.initRenderTarget=function(oe){we.get(oe).__webglFramebuffer===void 0&&Ee.setupRenderTarget(oe)},this.initTexture=function(oe){oe.isCubeTexture?Ee.setTextureCube(oe,0):oe.isData3DTexture?Ee.setTexture3D(oe,0):oe.isDataArrayTexture||oe.isCompressedArrayTexture?Ee.setTexture2DArray(oe,0):Ee.setTexture2D(oe,0),de.unbindTexture()},this.resetState=function(){O=0,k=0,R=null,de.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return bl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Bn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Bn._getUnpackColorSpace()}};const S$={type:"change"},WO={type:"start"},hQ={type:"end"},S_=new BO,M$=new Xu,nOe=Math.cos(70*Tke.DEG2RAD),vi=new it,Ja=2*Math.PI,lr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},wC=1e-6;class rOe extends m3e{constructor(e,n=null){super(e,n),this.state=lr.NONE,this.target=new it,this.cursor=new it,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:_p.ROTATE,MIDDLE:_p.DOLLY,RIGHT:_p.PAN},this.touches={ONE:fp.ROTATE,TWO:fp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new it,this._lastQuaternion=new _f,this._lastTargetPosition=new it,this._quat=new _f().setFromUnitVectors(e.up,new it(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new QH,this._sphericalDelta=new QH,this._scale=1,this._panOffset=new it,this._rotateStart=new xn,this._rotateEnd=new xn,this._rotateDelta=new xn,this._panStart=new xn,this._panEnd=new xn,this._panDelta=new xn,this._dollyStart=new xn,this._dollyEnd=new xn,this._dollyDelta=new xn,this._dollyDirection=new it,this._mouse=new xn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=aOe.bind(this),this._onPointerDown=iOe.bind(this),this._onPointerUp=sOe.bind(this),this._onContextMenu=fOe.bind(this),this._onMouseWheel=cOe.bind(this),this._onKeyDown=uOe.bind(this),this._onTouchStart=dOe.bind(this),this._onTouchMove=hOe.bind(this),this._onMouseDown=oOe.bind(this),this._onMouseMove=lOe.bind(this),this._interceptControlDown=mOe.bind(this),this._interceptControlUp=pOe.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(S$),this.update(),this.state=lr.NONE}update(e=null){const n=this.object.position;vi.copy(n).sub(this.target),vi.applyQuaternion(this._quat),this._spherical.setFromVector3(vi),this.autoRotate&&this.state===lr.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Ja:r>Math.PI&&(r-=Ja),i<-Math.PI?i+=Ja:i>Math.PI&&(i-=Ja),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(vi.setFromSpherical(this._spherical),vi.applyQuaternion(this._quatInverse),n.copy(this.target).add(vi),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=vi.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 it(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 it(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=vi.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):(S_.origin.copy(this.object.position),S_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(S_.direction))<nOe?this.object.lookAt(this.target):(M$.setFromNormalAndCoplanarPoint(this.object.up,this.target),S_.intersectPlane(M$,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>wC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>wC||this._lastTargetPosition.distanceToSquared(this.target)>wC?(this.dispatchEvent(S$),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ja/60*this.autoRotateSpeed*e:Ja/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){vi.setFromMatrixColumn(n,0),vi.multiplyScalar(-e),this._panOffset.add(vi)}_panUp(e,n){this.screenSpacePanning===!0?vi.setFromMatrixColumn(n,1):(vi.setFromMatrixColumn(n,0),vi.crossVectors(this.object.up,vi)),vi.multiplyScalar(e),this._panOffset.add(vi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;vi.copy(i).sub(this.target);let a=vi.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ja*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ja*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ja*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ja*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ja*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new xn,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 iOe(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function aOe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function sOe(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(hQ),this.state=lr.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 oOe(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 _p.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=lr.DOLLY;break;case _p.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=lr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=lr.ROTATE}break;case _p.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=lr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=lr.PAN}break;default:this.state=lr.NONE}this.state!==lr.NONE&&this.dispatchEvent(WO)}function lOe(t){switch(this.state){case lr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case lr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case lr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function cOe(t){this.enabled===!1||this.enableZoom===!1||this.state!==lr.NONE||(t.preventDefault(),this.dispatchEvent(WO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(hQ))}function uOe(t){this.enabled!==!1&&this._handleKeyDown(t)}function dOe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case fp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=lr.TOUCH_ROTATE;break;case fp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=lr.TOUCH_PAN;break;default:this.state=lr.NONE}break;case 2:switch(this.touches.TWO){case fp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=lr.TOUCH_DOLLY_PAN;break;case fp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=lr.TOUCH_DOLLY_ROTATE;break;default:this.state=lr.NONE}break;default:this.state=lr.NONE}this.state!==lr.NONE&&this.dispatchEvent(WO)}function hOe(t){switch(this._trackPointer(t),this.state){case lr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case lr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case lr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case lr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=lr.NONE}}function fOe(t){this.enabled!==!1&&t.preventDefault()}function mOe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function pOe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function gOe(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},o={},l=t[0].morphTargetsRelative,c=new Ul;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let g=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(f.attributes[p]),g++}if(g!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(f.morphAttributes[p])}if(e){let p;if(n)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,p,d),u+=p}}if(n){let d=0;const f=[];for(let g=0;g<t.length;++g){const p=t[g].index;for(let x=0;x<p.count;++x)f.push(p.getX(x)+d);d+=t[g].attributes.position.count}c.setIndex(f)}for(const d in a){const f=E$(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let g=0;g<f;++g){const p=[];for(let y=0;y<o[d].length;++y)p.push(o[d][y][g]);const x=E$(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(x)}}return c}function E$(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const o=new e(a),l=new mo(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let g=0,p=d.count;g<p;g++)for(let x=0;x<n;x++){const y=d.getComponent(g,x);l.setComponent(g+f,x,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function M_(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 SC={exports:{}};var N$;function xOe(){return N$||(N$=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 M_=="function"&&M_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var g=new Error("Cannot find module '"+u+"'");throw g.code="MODULE_NOT_FOUND",g}var p=i[u]={exports:{}};r[u][0].call(p.exports,function(x){var y=r[u][1][x];return o(y||x)},p,p.exports,n,r,i,a)}return i[u].exports}for(var l=typeof M_=="function"&&M_,c=0;c<a.length;c++)o(a[c]);return o})({1:[function(n,r,i){var a=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,g,p,x,y,b=[],v=0,E=c.length,w=E,A=a.getTypeOf(c)!=="string";v<c.length;)w=E-v,f=A?(u=c[v++],d=v<E?c[v++]:0,v<E?c[v++]:0):(u=c.charCodeAt(v++),d=v<E?c.charCodeAt(v++):0,v<E?c.charCodeAt(v++):0),g=u>>2,p=(3&u)<<4|d>>4,x=1<w?(15&d)<<2|f>>6:64,y=2<w?63&f:64,b.push(l.charAt(g)+l.charAt(p)+l.charAt(x)+l.charAt(y));return b.join("")},i.decode=function(c){var u,d,f,g,p,x,y=0,b=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var E,w=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&w--,c.charAt(c.length-2)===l.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=o.uint8array?new Uint8Array(0|w):new Array(0|w);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(g=l.indexOf(c.charAt(y++)))>>4,d=(15&g)<<4|(p=l.indexOf(c.charAt(y++)))>>2,f=(3&p)<<6|(x=l.indexOf(c.charAt(y++))),E[b++]=u,p!==64&&(E[b++]=d),x!==64&&(E[b++]=f);return E}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,g,p,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=g,this.compression=p,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,g){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),o=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?(function(u,d,f,g){var p=o,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^p[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,g){var p=o,x=g+f;u^=-1;for(var y=g;y<x;y++)u=u>>>8^p[255&(u^d.charCodeAt(y))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,g){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(p,x){var y,b="";for(y=0;y<x;y++)b+=String.fromCharCode(255&p),p>>>=8;return b}function o(p,x,y,b,v,E){var w,A,N=p.file,C=p.compression,T=E!==u.utf8encode,O=l.transformTo("string",E(N.name)),k=l.transformTo("string",u.utf8encode(N.name)),R=N.comment,z=l.transformTo("string",E(R)),D=l.transformTo("string",u.utf8encode(R)),K=k.length!==N.name.length,P=D.length!==R.length,W="",Z="",G="",Y=N.dir,X=N.date,q={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(q.crc32=p.crc32,q.compressedSize=p.compressedSize,q.uncompressedSize=p.uncompressedSize);var F=0;x&&(F|=8),T||!K&&!P||(F|=2048);var V=0,te=0;Y&&(V|=16),v==="UNIX"?(te=798,V|=(function(ae,he){var ue=ae;return ae||(ue=he?16893:33204),(65535&ue)<<16})(N.unixPermissions,Y)):(te=20,V|=(function(ae){return 63&(ae||0)})(N.dosPermissions)),w=X.getUTCHours(),w<<=6,w|=X.getUTCMinutes(),w<<=5,w|=X.getUTCSeconds()/2,A=X.getUTCFullYear()-1980,A<<=4,A|=X.getUTCMonth()+1,A<<=5,A|=X.getUTCDate(),K&&(Z=a(1,1)+a(d(O),4)+k,W+="up"+a(Z.length,2)+Z),P&&(G=a(1,1)+a(d(z),4)+D,W+="uc"+a(G.length,2)+G);var re="";return re+=`
- \0`,re+=a(F,2),re+=C.magic,re+=a(w,2),re+=a(A,2),re+=a(q.crc32,4),re+=a(q.compressedSize,4),re+=a(q.uncompressedSize,4),re+=a(O.length,2),re+=a(W.length,2),{fileRecord:f.LOCAL_FILE_HEADER+re+O+W,dirRecord:f.CENTRAL_FILE_HEADER+a(te,2)+re+a(z.length,2)+"\0\0\0\0"+a(V,4)+a(b,4)+O+W+z}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function g(p,x,y,b){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=b,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(g,c),g.prototype.push=function(p){var x=p.meta.percent||0,y=this.entriesCount,b=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-b-1))/y:100}}))},g.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var x=this.streamFiles&&!p.file.dir;if(x){var y=o(p,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(p){this.accumulate=!1;var x=this.streamFiles&&!p.file.dir,y=o(p,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(b){return f.DATA_DESCRIPTOR+a(b.crc32,4)+a(b.compressedSize,4)+a(b.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var p=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-p,b=(function(v,E,w,A,N){var C=l.transformTo("string",N(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(v,2)+a(v,2)+a(E,4)+a(w,4)+a(C.length,2)+C})(this.dirRecords.length,y,p,this.zipComment,this.encodeFileName);this.push({data:b,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(p){this._sources.push(p);var x=this;return p.on("data",function(y){x.processChunk(y)}),p.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),p.on("error",function(y){x.error(y)}),this},g.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(p){var x=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var y=0;y<x.length;y++)try{x[y].error(p)}catch{}return!0},g.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,x=0;x<p.length;x++)p[x].lock()},r.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(g,p){f++;var x=(function(E,w){var A=E||w,N=a[A];if(!N)throw new Error(A+" is not a valid compression method !");return N})(p.options.compression,c.compression),y=p.options.compressionOptions||c.compressionOptions||{},b=p.dir,v=p.date;p._compressWorker(x,y).withStreamInfo("file",{name:g,dir:b,date:v,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(g){d.error(g)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new a;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(o,l){return new a().loadAsync(o,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(g){return new o.Promise(function(p,x){var y=g.decompressed.getContentWorker().pipe(new u);y.on("error",function(b){x(b)}).on("end",function(){y.streamInfo.crc32!==g.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}r.exports=function(g,p){var x=this;return p=a.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(g)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",g,!0,p.optimizedBinaryString,p.base64).then(function(y){var b=new c(p);return b.load(y),b}).then(function(y){var b=[o.Promise.resolve(y)],v=y.files;if(p.checkCRC32)for(var E=0;E<v.length;E++)b.push(f(v[E]));return o.Promise.all(b)}).then(function(y){for(var b=y.shift(),v=b.files,E=0;E<v.length;E++){var w=v[E],A=w.fileNameStr,N=a.resolve(w.fileNameStr);x.file(N,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:p.createFolders}),w.dir||(x.file(N).unsafeOriginalName=A)}return b.zipComment.length&&(x.comment=b.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function o(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,g){d.push(f)||d._helper.pause(),u&&u(g)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,a),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(N,C,T){var O,k=l.getTypeOf(C),R=l.extend(T||{},d);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(N=v(N)),R.createFolders&&(O=b(N))&&E.call(this,O,!0);var z=k==="string"&&R.binary===!1&&R.base64===!1;T&&T.binary!==void 0||(R.binary=!z),(C instanceof f&&C.uncompressedSize===0||R.dir||!C||C.length===0)&&(R.base64=!1,R.binary=!0,C="",R.compression="STORE",k="string");var D=null;D=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new y(N,C):l.prepareContent(N,C,R.binary,R.optimizedBinaryString,R.base64);var K=new g(N,D,R);this.files[N]=K}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),g=n("./zipObject"),p=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),b=function(N){N.slice(-1)==="/"&&(N=N.substring(0,N.length-1));var C=N.lastIndexOf("/");return 0<C?N.substring(0,C):""},v=function(N){return N.slice(-1)!=="/"&&(N+="/"),N},E=function(N,C){return C=C!==void 0?C:d.createFolders,N=v(N),this.files[N]||a.call(this,N,null,{dir:!0,createFolders:C}),this.files[N]};function w(N){return Object.prototype.toString.call(N)==="[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(N){var C,T,O;for(C in this.files)O=this.files[C],(T=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&N(T,O)},filter:function(N){var C=[];return this.forEach(function(T,O){N(T,O)&&C.push(O)}),C},file:function(N,C,T){if(arguments.length!==1)return N=this.root+N,a.call(this,N,C,T),this;if(w(N)){var O=N;return this.filter(function(R,z){return!z.dir&&O.test(R)})}var k=this.files[this.root+N];return k&&!k.dir?k:null},folder:function(N){if(!N)return this;if(w(N))return this.filter(function(k,R){return R.dir&&N.test(k)});var C=this.root+N,T=E.call(this,C),O=this.clone();return O.root=T.name,O},remove:function(N){N=this.root+N;var C=this.files[N];if(C||(N.slice(-1)!=="/"&&(N+="/"),C=this.files[N]),C&&!C.dir)delete this.files[N];else for(var T=this.filter(function(k,R){return R.name.slice(0,N.length)===N}),O=0;O<T.length;O++)delete this.files[T[O].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(N){var C,T={};try{if((T=l.extend(N||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=T.type.toLowerCase(),T.compression=T.compression.toUpperCase(),T.type==="binarystring"&&(T.type="string"),!T.type)throw new Error("No output type specified.");l.checkSupport(T.type),T.platform!=="darwin"&&T.platform!=="freebsd"&&T.platform!=="linux"&&T.platform!=="sunos"||(T.platform="UNIX"),T.platform==="win32"&&(T.platform="DOS");var O=T.comment||this.comment||"";C=p.generateWorker(this,T,O)}catch(k){(C=new c("error")).error(k)}return new u(C,T.type||"string",T.mimeType)},generateAsync:function(N,C){return this.generateInternalStream(N).accumulate(C)},generateNodeStream:function(N,C){return(N=N||{}).type||(N.type="nodebuffer"),this.generateInternalStream(N).toNodejsStream(C)}};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),g=this.length-4;0<=g;--g)if(this.data[g]===c&&this.data[g+1]===u&&this.data[g+2]===d&&this.data[g+3]===f)return g-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),g=this.readData(4);return c===g[0]&&u===g[1]&&d===g[2]&&f===g[3]},o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var g=a.getTypeOf(f);return a.checkSupport(g),g!=="string"||o.uint8array?g==="nodebuffer"?new u(f):o.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),o=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),o=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(x,y){return new d.Promise(function(b,v){var E=[],w=x._internalType,A=x._outputType,N=x._mimeType;x.on("data",function(C,T){E.push(C),y&&y(T)}).on("error",function(C){E=[],v(C)}).on("end",function(){try{var C=(function(T,O,k){switch(T){case"blob":return a.newBlob(a.transformTo("arraybuffer",O),k);case"base64":return c.encode(O);default:return a.transformTo(T,O)}})(A,(function(T,O){var k,R=0,z=null,D=0;for(k=0;k<O.length;k++)D+=O[k].length;switch(T){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(z=new Uint8Array(D),k=0;k<O.length;k++)z.set(O[k],R),R+=O[k].length;return z;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+T+"'")}})(w,E),N);b(C)}catch(T){v(T)}E=[]}).resume()})}function p(x,y,b){var v=y;switch(y){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=y,this._mimeType=b,a.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(E){this._worker=new l("error"),this._worker.error(E)}}p.prototype={accumulate:function(x){return g(this,x)},on:function(x,y){var b=this;return x==="data"?this._worker.on(x,function(v){y.call(b,v.data,v.meta)}):this._worker.on(x,function(){a.delay(y,arguments,b)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(a),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function g(){c.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?l.newBufferFrom(p,"utf-8"):(function(x){var y,b,v,E,w,A=x.length,N=0;for(E=0;E<A;E++)(64512&(b=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(v=x.charCodeAt(E+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),E++),N+=b<128?1:b<2048?2:b<65536?3:4;for(y=o.uint8array?new Uint8Array(N):new Array(N),E=w=0;w<N;E++)(64512&(b=x.charCodeAt(E)))==55296&&E+1<A&&(64512&(v=x.charCodeAt(E+1)))==56320&&(b=65536+(b-55296<<10)+(v-56320),E++),b<128?y[w++]=b:(b<2048?y[w++]=192|b>>>6:(b<65536?y[w++]=224|b>>>12:(y[w++]=240|b>>>18,y[w++]=128|b>>>12&63),y[w++]=128|b>>>6&63),y[w++]=128|63&b);return y})(p)},i.utf8decode=function(p){return o.nodebuffer?a.transformTo("nodebuffer",p).toString("utf-8"):(function(x){var y,b,v,E,w=x.length,A=new Array(2*w);for(y=b=0;y<w;)if((v=x[y++])<128)A[b++]=v;else if(4<(E=u[v]))A[b++]=65533,y+=E-1;else{for(v&=E===2?31:E===3?15:7;1<E&&y<w;)v=v<<6|63&x[y++],E--;1<E?A[b++]=65533:v<65536?A[b++]=v:(v-=65536,A[b++]=55296|v>>10&1023,A[b++]=56320|1023&v)}return A.length!==b&&(A.subarray?A=A.subarray(0,b):A.length=b),a.applyFromCharCode(A)})(p=a.transformTo(o.uint8array?"uint8array":"array",p))},a.inherits(f,c),f.prototype.processChunk=function(p){var x=a.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var y=x;(x=new Uint8Array(y.length+this.leftOver.length)).set(this.leftOver,0),x.set(y,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var b=(function(E,w){var A;for((w=w||E.length)>E.length&&(w=E.length),A=w-1;0<=A&&(192&E[A])==128;)A--;return A<0||A===0?w:A+u[E[A]]>w?A:w})(x),v=x;b!==x.length&&(o.uint8array?(v=x.subarray(0,b),this.leftOver=x.subarray(b,x.length)):(v=x.slice(0,b),this.leftOver=x.slice(b,x.length))),this.push({data:i.utf8decode(v),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(g,c),g.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(y){return y}function d(y,b){for(var v=0;v<y.length;++v)b[v]=255&y.charCodeAt(v);return b}n("setimmediate"),i.newBlob=function(y,b){i.checkSupport("blob");try{return new Blob([y],{type:b})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(y),v.getBlob(b)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(y,b,v){var E=[],w=0,A=y.length;if(A<=v)return String.fromCharCode.apply(null,y);for(;w<A;)b==="array"||b==="nodebuffer"?E.push(String.fromCharCode.apply(null,y.slice(w,Math.min(w+v,A)))):E.push(String.fromCharCode.apply(null,y.subarray(w,Math.min(w+v,A)))),w+=v;return E.join("")},stringifyByChar:function(y){for(var b="",v=0;v<y.length;v++)b+=String.fromCharCode(y[v]);return b},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function g(y){var b=65536,v=i.getTypeOf(y),E=!0;if(v==="uint8array"?E=f.applyCanBeUsed.uint8array:v==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<b;)try{return f.stringifyByChunk(y,v,b)}catch{b=Math.floor(b/2)}return f.stringifyByChar(y)}function p(y,b){for(var v=0;v<y.length;v++)b[v]=y[v];return b}i.applyFromCharCode=g;var x={};x.string={string:u,array:function(y){return d(y,new Array(y.length))},arraybuffer:function(y){return x.string.uint8array(y).buffer},uint8array:function(y){return d(y,new Uint8Array(y.length))},nodebuffer:function(y){return d(y,l.allocBuffer(y.length))}},x.array={string:g,array:u,arraybuffer:function(y){return new Uint8Array(y).buffer},uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(y)}},x.arraybuffer={string:function(y){return g(new Uint8Array(y))},array:function(y){return p(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},x.uint8array={string:g,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},x.nodebuffer={string:g,array:function(y){return p(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return p(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,b){if(b=b||"",!y)return b;i.checkSupport(y);var v=i.getTypeOf(b);return x[v][y](b)},i.resolve=function(y){for(var b=y.split("/"),v=[],E=0;E<b.length;E++){var w=b[E];w==="."||w===""&&E!==0&&E!==b.length-1||(w===".."?v.pop():v.push(w))}return v.join("/")},i.getTypeOf=function(y){return typeof y=="string"?"string":Object.prototype.toString.call(y)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(y)?"nodebuffer":a.uint8array&&y instanceof Uint8Array?"uint8array":a.arraybuffer&&y instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(y){if(!a[y.toLowerCase()])throw new Error(y+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(y){var b,v,E="";for(v=0;v<(y||"").length;v++)E+="\\x"+((b=y.charCodeAt(v))<16?"0":"")+b.toString(16).toUpperCase();return E},i.delay=function(y,b,v){setImmediate(function(){y.apply(v||null,b||[])})},i.inherits=function(y,b){function v(){}v.prototype=b.prototype,y.prototype=new v},i.extend=function(){var y,b,v={};for(y=0;y<arguments.length;y++)for(b in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],b)&&v[b]===void 0&&(v[b]=arguments[y][b]);return v},i.prepareContent=function(y,b,v,E,w){return c.Promise.resolve(b).then(function(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(N,C){var T=new FileReader;T.onload=function(O){N(O.target.result)},T.onerror=function(O){C(O.target.error)},T.readAsArrayBuffer(A)}):A}).then(function(A){var N=i.getTypeOf(A);return N?(N==="arraybuffer"?A=i.transformTo("uint8array",A):N==="string"&&(w?A=o.decode(A):v&&E!==!0&&(A=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.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 g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(g)+", expected "+o.pretty(f)+")")}},isSignature:function(f,g){var p=this.reader.index;this.reader.setIndex(f);var x=this.reader.readString(4)===g;return this.reader.setIndex(p),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),g=u.uint8array?"uint8array":"array",p=o.transformTo(g,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,g,p,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),g=this.reader.readInt(4),p=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var g=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var x=g-p;if(0<x)this.isSignature(g,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function g(p,x){this.options=p,this.loadOptions=x}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var x,y;if(p.skip(22),this.fileNameLength=p.readInt(2),y=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(b){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===b)return d[v];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var x=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(x),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=a(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var x,y,b,v=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<v;)x=p.readInt(2),y=p.readInt(2),b=p.readData(y),this.extraFields[x]={id:x,length:y,value:b};p.setIndex(v)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var y=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var b=this.findExtraFieldUnicodeComment();if(b!==null)this.fileCommentStr=b;else{var v=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var x=a(p.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(p.length-5))}return null}},r.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(x,y,b){this.name=x,this.dir=b.dir,this.date=b.date,this.comment=b.comment,this.unixPermissions=b.unixPermissions,this.dosPermissions=b.dosPermissions,this._data=y,this._dataBinary=b.binary,this.options={compression:b.compression,compressionOptions:b.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(x){var y=null,b="string";try{if(!x)throw new Error("No output type specified.");var v=(b=x.toLowerCase())==="string"||b==="text";b!=="binarystring"&&b!=="text"||(b="string"),y=this._decompressWorker();var E=!this._dataBinary;E&&!v&&(y=y.pipe(new c.Utf8EncodeWorker)),!E&&v&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(w){(y=new d("error")).error(w)}return new o(y,b,"")},async:function(x,y){return this.internalStream(x).accumulate(y)},nodeStream:function(x,y){return this.internalStream(x||"nodebuffer").toNodejsStream(y)},_compressWorker:function(x,y){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var b=this._decompressWorker();return this._dataBinary||(b=b.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(b,x,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)a.prototype[f[p]]=g;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var o,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)o="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var y=a.document.createElement("script");y.onreadystatechange=function(){x(),y.onreadystatechange=null,y.parentNode.removeChild(y),y=null},a.document.documentElement.appendChild(y)}:function(){setTimeout(x,0)};else{var g=new a.MessageChannel;g.port1.onmessage=x,o=function(){g.port2.postMessage(0)}}var p=[];function x(){var y,b;l=!0;for(var v=p.length;v;){for(b=p,p=[],y=-1;++y<v;)b[y]();v=p.length}l=!1}r.exports=function(y){p.push(y)!==1||l||o()}}).call(this,typeof Pv<"u"?Pv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&y(this,v)}function g(v,E,w){this.promise=v,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(v,E,w){a(function(){var A;try{A=E(w)}catch(N){return l.reject(v,N)}A===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,A)})}function x(v){var E=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof E=="function")return function(){E.apply(v,arguments)}}function y(v,E){var w=!1;function A(T){w||(w=!0,l.reject(v,T))}function N(T){w||(w=!0,l.resolve(v,T))}var C=b(function(){E(N,A)});C.status==="error"&&A(C.value)}function b(v,E){var w={};try{w.value=v(E),w.status="success"}catch(A){w.status="error",w.value=A}return w}(r.exports=f).prototype.finally=function(v){if(typeof v!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(v()).then(function(){return w})},function(w){return E.resolve(v()).then(function(){throw w})})},f.prototype.catch=function(v){return this.then(null,v)},f.prototype.then=function(v,E){if(typeof v!="function"&&this.state===u||typeof E!="function"&&this.state===c)return this;var w=new this.constructor(o);return this.state!==d?p(w,this.state===u?v:E,this.outcome):this.queue.push(new g(w,v,E)),w},g.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},g.prototype.otherCallFulfilled=function(v){p(this.promise,this.onFulfilled,v)},g.prototype.callRejected=function(v){l.reject(this.promise,v)},g.prototype.otherCallRejected=function(v){p(this.promise,this.onRejected,v)},l.resolve=function(v,E){var w=b(x,E);if(w.status==="error")return l.reject(v,w.value);var A=w.value;if(A)y(v,A);else{v.state=u,v.outcome=E;for(var N=-1,C=v.queue.length;++N<C;)v.queue[N].callFulfilled(E)}return v},l.reject=function(v,E){v.state=c,v.outcome=E;for(var w=-1,A=v.queue.length;++w<A;)v.queue[w].callRejected(E);return v},f.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},f.reject=function(v){var E=new this(o);return l.reject(E,v)},f.all=function(v){var E=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=v.length,A=!1;if(!w)return this.resolve([]);for(var N=new Array(w),C=0,T=-1,O=new this(o);++T<w;)k(v[T],T);return O;function k(R,z){E.resolve(R).then(function(D){N[z]=D,++C!==w||A||(A=!0,l.resolve(O,N))},function(D){A||(A=!0,l.reject(O,D))})}},f.race=function(v){var E=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=v.length,A=!1;if(!w)return this.resolve([]);for(var N=-1,C=new this(o);++N<w;)T=v[N],E.resolve(T).then(function(O){A||(A=!0,l.resolve(C,O))},function(O){A||(A=!0,l.reject(C,O))});var T;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,g=-1,p=0,x=8;function y(v){if(!(this instanceof y))return new y(v);this.options=o.assign({level:g,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},v||{});var E=this.options;E.raw&&0<E.windowBits?E.windowBits=-E.windowBits:E.gzip&&0<E.windowBits&&E.windowBits<16&&(E.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(w!==f)throw new Error(c[w]);if(E.header&&a.deflateSetHeader(this.strm,E.header),E.dictionary){var A;if(A=typeof E.dictionary=="string"?l.string2buf(E.dictionary):d.call(E.dictionary)==="[object ArrayBuffer]"?new Uint8Array(E.dictionary):E.dictionary,(w=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[w]);this._dict_set=!0}}function b(v,E){var w=new y(E);if(w.push(v,!0),w.err)throw w.msg||c[w.err];return w.result}y.prototype.push=function(v,E){var w,A,N=this.strm,C=this.options.chunkSize;if(this.ended)return!1;A=E===~~E?E:E===!0?4:0,typeof v=="string"?N.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?N.input=new Uint8Array(v):N.input=v,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new o.Buf8(C),N.next_out=0,N.avail_out=C),(w=a.deflate(N,A))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);N.avail_out!==0&&(N.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(N.output,N.next_out))):this.onData(o.shrinkBuf(N.output,N.next_out)))}while((0<N.avail_in||N.avail_out===0)&&w!==1);return A===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):A!==2||(this.onEnd(f),!(N.avail_out=0))},y.prototype.onData=function(v){this.chunks.push(v)},y.prototype.onEnd=function(v){v===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Deflate=y,i.deflate=b,i.deflateRaw=function(v,E){return(E=E||{}).raw=!0,b(v,E)},i.gzip=function(v,E){return(E=E||{}).gzip=!0,b(v,E)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),g=Object.prototype.toString;function p(y){if(!(this instanceof p))return new p(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});var b=this.options;b.raw&&0<=b.windowBits&&b.windowBits<16&&(b.windowBits=-b.windowBits,b.windowBits===0&&(b.windowBits=-15)),!(0<=b.windowBits&&b.windowBits<16)||y&&y.windowBits||(b.windowBits+=32),15<b.windowBits&&b.windowBits<48&&(15&b.windowBits)==0&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=a.inflateInit2(this.strm,b.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(y,b){var v=new p(b);if(v.push(y,!0),v.err)throw v.msg||u[v.err];return v.result}p.prototype.push=function(y,b){var v,E,w,A,N,C,T=this.strm,O=this.options.chunkSize,k=this.options.dictionary,R=!1;if(this.ended)return!1;E=b===~~b?b:b===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?T.input=l.binstring2buf(y):g.call(y)==="[object ArrayBuffer]"?T.input=new Uint8Array(y):T.input=y,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new o.Buf8(O),T.next_out=0,T.avail_out=O),(v=a.inflate(T,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&k&&(C=typeof k=="string"?l.string2buf(k):g.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,v=a.inflateSetDictionary(this.strm,C)),v===c.Z_BUF_ERROR&&R===!0&&(v=c.Z_OK,R=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&v!==c.Z_STREAM_END&&(T.avail_in!==0||E!==c.Z_FINISH&&E!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=l.utf8border(T.output,T.next_out),A=T.next_out-w,N=l.buf2string(T.output,w),T.next_out=A,T.avail_out=O-A,A&&o.arraySet(T.output,T.output,w,A,0),this.onData(N)):this.onData(o.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(R=!0)}while((0<T.avail_in||T.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(v=a.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):E!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(T.avail_out=0))},p.prototype.onData=function(y){this.chunks.push(y)},p.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=p,i.inflate=x,i.inflateRaw=function(y,b){return(b=b||{}).raw=!0,x(y,b)},i.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,g){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),g);else for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){var u,d,f,g,p,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),u=g=0,d=c.length;u<d;u++)p=c[u],x.set(p,g),g+=p.length;return x}},l={arraySet:function(c,u,d,f,g){for(var p=0;p<f;p++)c[g+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,g){if(g<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,g));for(var p="",x=0;x<g;x++)p+=String.fromCharCode(f[x]);return p}c[254]=c[254]=1,i.string2buf=function(f){var g,p,x,y,b,v=f.length,E=0;for(y=0;y<v;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),y++),E+=p<128?1:p<2048?2:p<65536?3:4;for(g=new a.Buf8(E),y=b=0;b<E;y++)(64512&(p=f.charCodeAt(y)))==55296&&y+1<v&&(64512&(x=f.charCodeAt(y+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),y++),p<128?g[b++]=p:(p<2048?g[b++]=192|p>>>6:(p<65536?g[b++]=224|p>>>12:(g[b++]=240|p>>>18,g[b++]=128|p>>>12&63),g[b++]=128|p>>>6&63),g[b++]=128|63&p);return g},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var g=new a.Buf8(f.length),p=0,x=g.length;p<x;p++)g[p]=f.charCodeAt(p);return g},i.buf2string=function(f,g){var p,x,y,b,v=g||f.length,E=new Array(2*v);for(p=x=0;p<v;)if((y=f[p++])<128)E[x++]=y;else if(4<(b=c[y]))E[x++]=65533,p+=b-1;else{for(y&=b===2?31:b===3?15:7;1<b&&p<v;)y=y<<6|63&f[p++],b--;1<b?E[x++]=65533:y<65536?E[x++]=y:(y-=65536,E[x++]=55296|y>>10&1023,E[x++]=56320|1023&y)}return d(E,x)},i.utf8border=function(f,g){var p;for((g=g||f.length)>f.length&&(g=f.length),p=g-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?g:p+c[f[p]]>g?p:g}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,o,l,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();r.exports=function(o,l,c,u){var d=a,f=u+c;o^=-1;for(var g=u;g<f;g++)o=o>>>8^d[255&(o^l[g])];return-1^o}},{}],46:[function(n,r,i){var a,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,g=4,p=0,x=-2,y=-1,b=4,v=2,E=8,w=9,A=286,N=30,C=19,T=2*A+1,O=15,k=3,R=258,z=R+k+1,D=42,K=113,P=1,W=2,Z=3,G=4;function Y(B,H){return B.msg=d[H],H}function X(B){return(B<<1)-(4<B?9:0)}function q(B){for(var H=B.length;0<=--H;)B[H]=0}function F(B){var H=B.state,le=H.pending;le>B.avail_out&&(le=B.avail_out),le!==0&&(o.arraySet(B.output,H.pending_buf,H.pending_out,le,B.next_out),B.next_out+=le,H.pending_out+=le,B.total_out+=le,B.avail_out-=le,H.pending-=le,H.pending===0&&(H.pending_out=0))}function V(B,H){l._tr_flush_block(B,0<=B.block_start?B.block_start:-1,B.strstart-B.block_start,H),B.block_start=B.strstart,F(B.strm)}function te(B,H){B.pending_buf[B.pending++]=H}function re(B,H){B.pending_buf[B.pending++]=H>>>8&255,B.pending_buf[B.pending++]=255&H}function ae(B,H){var le,$,ee=B.max_chain_length,de=B.strstart,ke=B.prev_length,we=B.nice_match,Ee=B.strstart>B.w_size-z?B.strstart-(B.w_size-z):0,U=B.window,I=B.w_mask,se=B.prev,ye=B.strstart+R,Se=U[de+ke-1],ve=U[de+ke];B.prev_length>=B.good_match&&(ee>>=2),we>B.lookahead&&(we=B.lookahead);do if(U[(le=H)+ke]===ve&&U[le+ke-1]===Se&&U[le]===U[de]&&U[++le]===U[de+1]){de+=2,le++;do;while(U[++de]===U[++le]&&U[++de]===U[++le]&&U[++de]===U[++le]&&U[++de]===U[++le]&&U[++de]===U[++le]&&U[++de]===U[++le]&&U[++de]===U[++le]&&U[++de]===U[++le]&&de<ye);if($=R-(ye-de),de=ye-R,ke<$){if(B.match_start=H,we<=(ke=$))break;Se=U[de+ke-1],ve=U[de+ke]}}while((H=se[H&I])>Ee&&--ee!=0);return ke<=B.lookahead?ke:B.lookahead}function he(B){var H,le,$,ee,de,ke,we,Ee,U,I,se=B.w_size;do{if(ee=B.window_size-B.lookahead-B.strstart,B.strstart>=se+(se-z)){for(o.arraySet(B.window,B.window,se,se,0),B.match_start-=se,B.strstart-=se,B.block_start-=se,H=le=B.hash_size;$=B.head[--H],B.head[H]=se<=$?$-se:0,--le;);for(H=le=se;$=B.prev[--H],B.prev[H]=se<=$?$-se:0,--le;);ee+=se}if(B.strm.avail_in===0)break;if(ke=B.strm,we=B.window,Ee=B.strstart+B.lookahead,U=ee,I=void 0,I=ke.avail_in,U<I&&(I=U),le=I===0?0:(ke.avail_in-=I,o.arraySet(we,ke.input,ke.next_in,I,Ee),ke.state.wrap===1?ke.adler=c(ke.adler,we,I,Ee):ke.state.wrap===2&&(ke.adler=u(ke.adler,we,I,Ee)),ke.next_in+=I,ke.total_in+=I,I),B.lookahead+=le,B.lookahead+B.insert>=k)for(de=B.strstart-B.insert,B.ins_h=B.window[de],B.ins_h=(B.ins_h<<B.hash_shift^B.window[de+1])&B.hash_mask;B.insert&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[de+k-1])&B.hash_mask,B.prev[de&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=de,de++,B.insert--,!(B.lookahead+B.insert<k)););}while(B.lookahead<z&&B.strm.avail_in!==0)}function ue(B,H){for(var le,$;;){if(B.lookahead<z){if(he(B),B.lookahead<z&&H===f)return P;if(B.lookahead===0)break}if(le=0,B.lookahead>=k&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,le=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),le!==0&&B.strstart-le<=B.w_size-z&&(B.match_length=ae(B,le)),B.match_length>=k)if($=l._tr_tally(B,B.strstart-B.match_start,B.match_length-k),B.lookahead-=B.match_length,B.match_length<=B.max_lazy_match&&B.lookahead>=k){for(B.match_length--;B.strstart++,B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,le=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart,--B.match_length!=0;);B.strstart++}else B.strstart+=B.match_length,B.match_length=0,B.ins_h=B.window[B.strstart],B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+1])&B.hash_mask;else $=l._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++;if($&&(V(B,!1),B.strm.avail_out===0))return P}return B.insert=B.strstart<k-1?B.strstart:k-1,H===g?(V(B,!0),B.strm.avail_out===0?Z:G):B.last_lit&&(V(B,!1),B.strm.avail_out===0)?P:W}function ce(B,H){for(var le,$,ee;;){if(B.lookahead<z){if(he(B),B.lookahead<z&&H===f)return P;if(B.lookahead===0)break}if(le=0,B.lookahead>=k&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,le=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),B.prev_length=B.match_length,B.prev_match=B.match_start,B.match_length=k-1,le!==0&&B.prev_length<B.max_lazy_match&&B.strstart-le<=B.w_size-z&&(B.match_length=ae(B,le),B.match_length<=5&&(B.strategy===1||B.match_length===k&&4096<B.strstart-B.match_start)&&(B.match_length=k-1)),B.prev_length>=k&&B.match_length<=B.prev_length){for(ee=B.strstart+B.lookahead-k,$=l._tr_tally(B,B.strstart-1-B.prev_match,B.prev_length-k),B.lookahead-=B.prev_length-1,B.prev_length-=2;++B.strstart<=ee&&(B.ins_h=(B.ins_h<<B.hash_shift^B.window[B.strstart+k-1])&B.hash_mask,le=B.prev[B.strstart&B.w_mask]=B.head[B.ins_h],B.head[B.ins_h]=B.strstart),--B.prev_length!=0;);if(B.match_available=0,B.match_length=k-1,B.strstart++,$&&(V(B,!1),B.strm.avail_out===0))return P}else if(B.match_available){if(($=l._tr_tally(B,0,B.window[B.strstart-1]))&&V(B,!1),B.strstart++,B.lookahead--,B.strm.avail_out===0)return P}else B.match_available=1,B.strstart++,B.lookahead--}return B.match_available&&($=l._tr_tally(B,0,B.window[B.strstart-1]),B.match_available=0),B.insert=B.strstart<k-1?B.strstart:k-1,H===g?(V(B,!0),B.strm.avail_out===0?Z:G):B.last_lit&&(V(B,!1),B.strm.avail_out===0)?P:W}function fe(B,H,le,$,ee){this.good_length=B,this.max_lazy=H,this.nice_length=le,this.max_chain=$,this.func=ee}function pe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=E,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*T),this.dyn_dtree=new o.Buf16(2*(2*N+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),q(this.dyn_ltree),q(this.dyn_dtree),q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(O+1),this.heap=new o.Buf16(2*A+1),q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*A+1),q(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(B){var H;return B&&B.state?(B.total_in=B.total_out=0,B.data_type=v,(H=B.state).pending=0,H.pending_out=0,H.wrap<0&&(H.wrap=-H.wrap),H.status=H.wrap?D:K,B.adler=H.wrap===2?0:1,H.last_flush=f,l._tr_init(H),p):Y(B,x)}function ne(B){var H=_e(B);return H===p&&(function(le){le.window_size=2*le.w_size,q(le.head),le.max_lazy_match=a[le.level].max_lazy,le.good_match=a[le.level].good_length,le.nice_match=a[le.level].nice_length,le.max_chain_length=a[le.level].max_chain,le.strstart=0,le.block_start=0,le.lookahead=0,le.insert=0,le.match_length=le.prev_length=k-1,le.match_available=0,le.ins_h=0})(B.state),H}function He(B,H,le,$,ee,de){if(!B)return x;var ke=1;if(H===y&&(H=6),$<0?(ke=0,$=-$):15<$&&(ke=2,$-=16),ee<1||w<ee||le!==E||$<8||15<$||H<0||9<H||de<0||b<de)return Y(B,x);$===8&&($=9);var we=new pe;return(B.state=we).strm=B,we.wrap=ke,we.gzhead=null,we.w_bits=$,we.w_size=1<<we.w_bits,we.w_mask=we.w_size-1,we.hash_bits=ee+7,we.hash_size=1<<we.hash_bits,we.hash_mask=we.hash_size-1,we.hash_shift=~~((we.hash_bits+k-1)/k),we.window=new o.Buf8(2*we.w_size),we.head=new o.Buf16(we.hash_size),we.prev=new o.Buf16(we.w_size),we.lit_bufsize=1<<ee+6,we.pending_buf_size=4*we.lit_bufsize,we.pending_buf=new o.Buf8(we.pending_buf_size),we.d_buf=1*we.lit_bufsize,we.l_buf=3*we.lit_bufsize,we.level=H,we.strategy=de,we.method=le,ne(B)}a=[new fe(0,0,0,0,function(B,H){var le=65535;for(le>B.pending_buf_size-5&&(le=B.pending_buf_size-5);;){if(B.lookahead<=1){if(he(B),B.lookahead===0&&H===f)return P;if(B.lookahead===0)break}B.strstart+=B.lookahead,B.lookahead=0;var $=B.block_start+le;if((B.strstart===0||B.strstart>=$)&&(B.lookahead=B.strstart-$,B.strstart=$,V(B,!1),B.strm.avail_out===0)||B.strstart-B.block_start>=B.w_size-z&&(V(B,!1),B.strm.avail_out===0))return P}return B.insert=0,H===g?(V(B,!0),B.strm.avail_out===0?Z:G):(B.strstart>B.block_start&&(V(B,!1),B.strm.avail_out),P)}),new fe(4,4,8,4,ue),new fe(4,5,16,8,ue),new fe(4,6,32,32,ue),new fe(4,4,16,16,ce),new fe(8,16,32,32,ce),new fe(8,16,128,128,ce),new fe(8,32,128,256,ce),new fe(32,128,258,1024,ce),new fe(32,258,258,4096,ce)],i.deflateInit=function(B,H){return He(B,H,E,15,8,0)},i.deflateInit2=He,i.deflateReset=ne,i.deflateResetKeep=_e,i.deflateSetHeader=function(B,H){return B&&B.state?B.state.wrap!==2?x:(B.state.gzhead=H,p):x},i.deflate=function(B,H){var le,$,ee,de;if(!B||!B.state||5<H||H<0)return B?Y(B,x):x;if($=B.state,!B.output||!B.input&&B.avail_in!==0||$.status===666&&H!==g)return Y(B,B.avail_out===0?-5:x);if($.strm=B,le=$.last_flush,$.last_flush=H,$.status===D)if($.wrap===2)B.adler=0,te($,31),te($,139),te($,8),$.gzhead?(te($,($.gzhead.text?1:0)+($.gzhead.hcrc?2:0)+($.gzhead.extra?4:0)+($.gzhead.name?8:0)+($.gzhead.comment?16:0)),te($,255&$.gzhead.time),te($,$.gzhead.time>>8&255),te($,$.gzhead.time>>16&255),te($,$.gzhead.time>>24&255),te($,$.level===9?2:2<=$.strategy||$.level<2?4:0),te($,255&$.gzhead.os),$.gzhead.extra&&$.gzhead.extra.length&&(te($,255&$.gzhead.extra.length),te($,$.gzhead.extra.length>>8&255)),$.gzhead.hcrc&&(B.adler=u(B.adler,$.pending_buf,$.pending,0)),$.gzindex=0,$.status=69):(te($,0),te($,0),te($,0),te($,0),te($,0),te($,$.level===9?2:2<=$.strategy||$.level<2?4:0),te($,3),$.status=K);else{var ke=E+($.w_bits-8<<4)<<8;ke|=(2<=$.strategy||$.level<2?0:$.level<6?1:$.level===6?2:3)<<6,$.strstart!==0&&(ke|=32),ke+=31-ke%31,$.status=K,re($,ke),$.strstart!==0&&(re($,B.adler>>>16),re($,65535&B.adler)),B.adler=1}if($.status===69)if($.gzhead.extra){for(ee=$.pending;$.gzindex<(65535&$.gzhead.extra.length)&&($.pending!==$.pending_buf_size||($.gzhead.hcrc&&$.pending>ee&&(B.adler=u(B.adler,$.pending_buf,$.pending-ee,ee)),F(B),ee=$.pending,$.pending!==$.pending_buf_size));)te($,255&$.gzhead.extra[$.gzindex]),$.gzindex++;$.gzhead.hcrc&&$.pending>ee&&(B.adler=u(B.adler,$.pending_buf,$.pending-ee,ee)),$.gzindex===$.gzhead.extra.length&&($.gzindex=0,$.status=73)}else $.status=73;if($.status===73)if($.gzhead.name){ee=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>ee&&(B.adler=u(B.adler,$.pending_buf,$.pending-ee,ee)),F(B),ee=$.pending,$.pending===$.pending_buf_size)){de=1;break}de=$.gzindex<$.gzhead.name.length?255&$.gzhead.name.charCodeAt($.gzindex++):0,te($,de)}while(de!==0);$.gzhead.hcrc&&$.pending>ee&&(B.adler=u(B.adler,$.pending_buf,$.pending-ee,ee)),de===0&&($.gzindex=0,$.status=91)}else $.status=91;if($.status===91)if($.gzhead.comment){ee=$.pending;do{if($.pending===$.pending_buf_size&&($.gzhead.hcrc&&$.pending>ee&&(B.adler=u(B.adler,$.pending_buf,$.pending-ee,ee)),F(B),ee=$.pending,$.pending===$.pending_buf_size)){de=1;break}de=$.gzindex<$.gzhead.comment.length?255&$.gzhead.comment.charCodeAt($.gzindex++):0,te($,de)}while(de!==0);$.gzhead.hcrc&&$.pending>ee&&(B.adler=u(B.adler,$.pending_buf,$.pending-ee,ee)),de===0&&($.status=103)}else $.status=103;if($.status===103&&($.gzhead.hcrc?($.pending+2>$.pending_buf_size&&F(B),$.pending+2<=$.pending_buf_size&&(te($,255&B.adler),te($,B.adler>>8&255),B.adler=0,$.status=K)):$.status=K),$.pending!==0){if(F(B),B.avail_out===0)return $.last_flush=-1,p}else if(B.avail_in===0&&X(H)<=X(le)&&H!==g)return Y(B,-5);if($.status===666&&B.avail_in!==0)return Y(B,-5);if(B.avail_in!==0||$.lookahead!==0||H!==f&&$.status!==666){var we=$.strategy===2?(function(Ee,U){for(var I;;){if(Ee.lookahead===0&&(he(Ee),Ee.lookahead===0)){if(U===f)return P;break}if(Ee.match_length=0,I=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++,I&&(V(Ee,!1),Ee.strm.avail_out===0))return P}return Ee.insert=0,U===g?(V(Ee,!0),Ee.strm.avail_out===0?Z:G):Ee.last_lit&&(V(Ee,!1),Ee.strm.avail_out===0)?P:W})($,H):$.strategy===3?(function(Ee,U){for(var I,se,ye,Se,ve=Ee.window;;){if(Ee.lookahead<=R){if(he(Ee),Ee.lookahead<=R&&U===f)return P;if(Ee.lookahead===0)break}if(Ee.match_length=0,Ee.lookahead>=k&&0<Ee.strstart&&(se=ve[ye=Ee.strstart-1])===ve[++ye]&&se===ve[++ye]&&se===ve[++ye]){Se=Ee.strstart+R;do;while(se===ve[++ye]&&se===ve[++ye]&&se===ve[++ye]&&se===ve[++ye]&&se===ve[++ye]&&se===ve[++ye]&&se===ve[++ye]&&se===ve[++ye]&&ye<Se);Ee.match_length=R-(Se-ye),Ee.match_length>Ee.lookahead&&(Ee.match_length=Ee.lookahead)}if(Ee.match_length>=k?(I=l._tr_tally(Ee,1,Ee.match_length-k),Ee.lookahead-=Ee.match_length,Ee.strstart+=Ee.match_length,Ee.match_length=0):(I=l._tr_tally(Ee,0,Ee.window[Ee.strstart]),Ee.lookahead--,Ee.strstart++),I&&(V(Ee,!1),Ee.strm.avail_out===0))return P}return Ee.insert=0,U===g?(V(Ee,!0),Ee.strm.avail_out===0?Z:G):Ee.last_lit&&(V(Ee,!1),Ee.strm.avail_out===0)?P:W})($,H):a[$.level].func($,H);if(we!==Z&&we!==G||($.status=666),we===P||we===Z)return B.avail_out===0&&($.last_flush=-1),p;if(we===W&&(H===1?l._tr_align($):H!==5&&(l._tr_stored_block($,0,0,!1),H===3&&(q($.head),$.lookahead===0&&($.strstart=0,$.block_start=0,$.insert=0))),F(B),B.avail_out===0))return $.last_flush=-1,p}return H!==g?p:$.wrap<=0?1:($.wrap===2?(te($,255&B.adler),te($,B.adler>>8&255),te($,B.adler>>16&255),te($,B.adler>>24&255),te($,255&B.total_in),te($,B.total_in>>8&255),te($,B.total_in>>16&255),te($,B.total_in>>24&255)):(re($,B.adler>>>16),re($,65535&B.adler)),F(B),0<$.wrap&&($.wrap=-$.wrap),$.pending!==0?p:1)},i.deflateEnd=function(B){var H;return B&&B.state?(H=B.state.status)!==D&&H!==69&&H!==73&&H!==91&&H!==103&&H!==K&&H!==666?Y(B,x):(B.state=null,H===K?Y(B,-3):p):x},i.deflateSetDictionary=function(B,H){var le,$,ee,de,ke,we,Ee,U,I=H.length;if(!B||!B.state||(de=(le=B.state).wrap)===2||de===1&&le.status!==D||le.lookahead)return x;for(de===1&&(B.adler=c(B.adler,H,I,0)),le.wrap=0,I>=le.w_size&&(de===0&&(q(le.head),le.strstart=0,le.block_start=0,le.insert=0),U=new o.Buf8(le.w_size),o.arraySet(U,H,I-le.w_size,le.w_size,0),H=U,I=le.w_size),ke=B.avail_in,we=B.next_in,Ee=B.input,B.avail_in=I,B.next_in=0,B.input=H,he(le);le.lookahead>=k;){for($=le.strstart,ee=le.lookahead-(k-1);le.ins_h=(le.ins_h<<le.hash_shift^le.window[$+k-1])&le.hash_mask,le.prev[$&le.w_mask]=le.head[le.ins_h],le.head[le.ins_h]=$,$++,--ee;);le.strstart=$,le.lookahead=k-1,he(le)}return le.strstart+=le.lookahead,le.block_start=le.strstart,le.insert=le.lookahead,le.lookahead=0,le.match_length=le.prev_length=k-1,le.match_available=0,B.next_in=we,B.input=Ee,B.avail_in=ke,le.wrap=de,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,o){var l,c,u,d,f,g,p,x,y,b,v,E,w,A,N,C,T,O,k,R,z,D,K,P,W;l=a.state,c=a.next_in,P=a.input,u=c+(a.avail_in-5),d=a.next_out,W=a.output,f=d-(o-a.avail_out),g=d+(a.avail_out-257),p=l.dmax,x=l.wsize,y=l.whave,b=l.wnext,v=l.window,E=l.hold,w=l.bits,A=l.lencode,N=l.distcode,C=(1<<l.lenbits)-1,T=(1<<l.distbits)-1;e:do{w<15&&(E+=P[c++]<<w,w+=8,E+=P[c++]<<w,w+=8),O=A[E&C];t:for(;;){if(E>>>=k=O>>>24,w-=k,(k=O>>>16&255)===0)W[d++]=65535&O;else{if(!(16&k)){if((64&k)==0){O=A[(65535&O)+(E&(1<<k)-1)];continue t}if(32&k){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}R=65535&O,(k&=15)&&(w<k&&(E+=P[c++]<<w,w+=8),R+=E&(1<<k)-1,E>>>=k,w-=k),w<15&&(E+=P[c++]<<w,w+=8,E+=P[c++]<<w,w+=8),O=N[E&T];n:for(;;){if(E>>>=k=O>>>24,w-=k,!(16&(k=O>>>16&255))){if((64&k)==0){O=N[(65535&O)+(E&(1<<k)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(z=65535&O,w<(k&=15)&&(E+=P[c++]<<w,(w+=8)<k&&(E+=P[c++]<<w,w+=8)),p<(z+=E&(1<<k)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(E>>>=k,w-=k,(k=d-f)<z){if(y<(k=z-k)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(K=v,(D=0)===b){if(D+=x-k,k<R){for(R-=k;W[d++]=v[D++],--k;);D=d-z,K=W}}else if(b<k){if(D+=x+b-k,(k-=b)<R){for(R-=k;W[d++]=v[D++],--k;);if(D=0,b<R){for(R-=k=b;W[d++]=v[D++],--k;);D=d-z,K=W}}}else if(D+=b-k,k<R){for(R-=k;W[d++]=v[D++],--k;);D=d-z,K=W}for(;2<R;)W[d++]=K[D++],W[d++]=K[D++],W[d++]=K[D++],R-=3;R&&(W[d++]=K[D++],1<R&&(W[d++]=K[D++]))}else{for(D=d-z;W[d++]=W[D++],W[d++]=W[D++],W[d++]=W[D++],2<(R-=3););R&&(W[d++]=W[D++],1<R&&(W[d++]=W[D++]))}break}}break}}while(c<u&&d<g);c-=R=w>>3,E&=(1<<(w-=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<g?g-d+257:257-(d-g),l.hold=E,l.bits=w}},{}],49:[function(n,r,i){var a=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,g=0,p=-2,x=1,y=852,b=592;function v(D){return(D>>>24&255)+(D>>>8&65280)+((65280&D)<<8)+((255&D)<<24)}function E(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(D){var K;return D&&D.state?(K=D.state,D.total_in=D.total_out=K.total=0,D.msg="",K.wrap&&(D.adler=1&K.wrap),K.mode=x,K.last=0,K.havedict=0,K.dmax=32768,K.head=null,K.hold=0,K.bits=0,K.lencode=K.lendyn=new a.Buf32(y),K.distcode=K.distdyn=new a.Buf32(b),K.sane=1,K.back=-1,g):p}function A(D){var K;return D&&D.state?((K=D.state).wsize=0,K.whave=0,K.wnext=0,w(D)):p}function N(D,K){var P,W;return D&&D.state?(W=D.state,K<0?(P=0,K=-K):(P=1+(K>>4),K<48&&(K&=15)),K&&(K<8||15<K)?p:(W.window!==null&&W.wbits!==K&&(W.window=null),W.wrap=P,W.wbits=K,A(D))):p}function C(D,K){var P,W;return D?(W=new E,(D.state=W).window=null,(P=N(D,K))!==g&&(D.state=null),P):p}var T,O,k=!0;function R(D){if(k){var K;for(T=new a.Buf32(512),O=new a.Buf32(32),K=0;K<144;)D.lens[K++]=8;for(;K<256;)D.lens[K++]=9;for(;K<280;)D.lens[K++]=7;for(;K<288;)D.lens[K++]=8;for(u(d,D.lens,0,288,T,0,D.work,{bits:9}),K=0;K<32;)D.lens[K++]=5;u(f,D.lens,0,32,O,0,D.work,{bits:5}),k=!1}D.lencode=T,D.lenbits=9,D.distcode=O,D.distbits=5}function z(D,K,P,W){var Z,G=D.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,K,P-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(W<(Z=G.wsize-G.wnext)&&(Z=W),a.arraySet(G.window,K,P-W,Z,G.wnext),(W-=Z)?(a.arraySet(G.window,K,P-W,W,0),G.wnext=W,G.whave=G.wsize):(G.wnext+=Z,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=Z))),0}i.inflateReset=A,i.inflateReset2=N,i.inflateResetKeep=w,i.inflateInit=function(D){return C(D,15)},i.inflateInit2=C,i.inflate=function(D,K){var P,W,Z,G,Y,X,q,F,V,te,re,ae,he,ue,ce,fe,pe,_e,ne,He,B,H,le,$,ee=0,de=new a.Buf8(4),ke=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!D||!D.state||!D.output||!D.input&&D.avail_in!==0)return p;(P=D.state).mode===12&&(P.mode=13),Y=D.next_out,Z=D.output,q=D.avail_out,G=D.next_in,W=D.input,X=D.avail_in,F=P.hold,V=P.bits,te=X,re=q,H=g;e:for(;;)switch(P.mode){case x:if(P.wrap===0){P.mode=13;break}for(;V<16;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(2&P.wrap&&F===35615){de[P.check=0]=255&F,de[1]=F>>>8&255,P.check=l(P.check,de,2,0),V=F=0,P.mode=2;break}if(P.flags=0,P.head&&(P.head.done=!1),!(1&P.wrap)||(((255&F)<<8)+(F>>8))%31){D.msg="incorrect header check",P.mode=30;break}if((15&F)!=8){D.msg="unknown compression method",P.mode=30;break}if(V-=4,B=8+(15&(F>>>=4)),P.wbits===0)P.wbits=B;else if(B>P.wbits){D.msg="invalid window size",P.mode=30;break}P.dmax=1<<B,D.adler=P.check=1,P.mode=512&F?10:12,V=F=0;break;case 2:for(;V<16;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(P.flags=F,(255&P.flags)!=8){D.msg="unknown compression method",P.mode=30;break}if(57344&P.flags){D.msg="unknown header flags set",P.mode=30;break}P.head&&(P.head.text=F>>8&1),512&P.flags&&(de[0]=255&F,de[1]=F>>>8&255,P.check=l(P.check,de,2,0)),V=F=0,P.mode=3;case 3:for(;V<32;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}P.head&&(P.head.time=F),512&P.flags&&(de[0]=255&F,de[1]=F>>>8&255,de[2]=F>>>16&255,de[3]=F>>>24&255,P.check=l(P.check,de,4,0)),V=F=0,P.mode=4;case 4:for(;V<16;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}P.head&&(P.head.xflags=255&F,P.head.os=F>>8),512&P.flags&&(de[0]=255&F,de[1]=F>>>8&255,P.check=l(P.check,de,2,0)),V=F=0,P.mode=5;case 5:if(1024&P.flags){for(;V<16;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}P.length=F,P.head&&(P.head.extra_len=F),512&P.flags&&(de[0]=255&F,de[1]=F>>>8&255,P.check=l(P.check,de,2,0)),V=F=0}else P.head&&(P.head.extra=null);P.mode=6;case 6:if(1024&P.flags&&(X<(ae=P.length)&&(ae=X),ae&&(P.head&&(B=P.head.extra_len-P.length,P.head.extra||(P.head.extra=new Array(P.head.extra_len)),a.arraySet(P.head.extra,W,G,ae,B)),512&P.flags&&(P.check=l(P.check,W,ae,G)),X-=ae,G+=ae,P.length-=ae),P.length))break e;P.length=0,P.mode=7;case 7:if(2048&P.flags){if(X===0)break e;for(ae=0;B=W[G+ae++],P.head&&B&&P.length<65536&&(P.head.name+=String.fromCharCode(B)),B&&ae<X;);if(512&P.flags&&(P.check=l(P.check,W,ae,G)),X-=ae,G+=ae,B)break e}else P.head&&(P.head.name=null);P.length=0,P.mode=8;case 8:if(4096&P.flags){if(X===0)break e;for(ae=0;B=W[G+ae++],P.head&&B&&P.length<65536&&(P.head.comment+=String.fromCharCode(B)),B&&ae<X;);if(512&P.flags&&(P.check=l(P.check,W,ae,G)),X-=ae,G+=ae,B)break e}else P.head&&(P.head.comment=null);P.mode=9;case 9:if(512&P.flags){for(;V<16;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(F!==(65535&P.check)){D.msg="header crc mismatch",P.mode=30;break}V=F=0}P.head&&(P.head.hcrc=P.flags>>9&1,P.head.done=!0),D.adler=P.check=0,P.mode=12;break;case 10:for(;V<32;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}D.adler=P.check=v(F),V=F=0,P.mode=11;case 11:if(P.havedict===0)return D.next_out=Y,D.avail_out=q,D.next_in=G,D.avail_in=X,P.hold=F,P.bits=V,2;D.adler=P.check=1,P.mode=12;case 12:if(K===5||K===6)break e;case 13:if(P.last){F>>>=7&V,V-=7&V,P.mode=27;break}for(;V<3;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}switch(P.last=1&F,V-=1,3&(F>>>=1)){case 0:P.mode=14;break;case 1:if(R(P),P.mode=20,K!==6)break;F>>>=2,V-=2;break e;case 2:P.mode=17;break;case 3:D.msg="invalid block type",P.mode=30}F>>>=2,V-=2;break;case 14:for(F>>>=7&V,V-=7&V;V<32;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if((65535&F)!=(F>>>16^65535)){D.msg="invalid stored block lengths",P.mode=30;break}if(P.length=65535&F,V=F=0,P.mode=15,K===6)break e;case 15:P.mode=16;case 16:if(ae=P.length){if(X<ae&&(ae=X),q<ae&&(ae=q),ae===0)break e;a.arraySet(Z,W,G,ae,Y),X-=ae,G+=ae,q-=ae,Y+=ae,P.length-=ae;break}P.mode=12;break;case 17:for(;V<14;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(P.nlen=257+(31&F),F>>>=5,V-=5,P.ndist=1+(31&F),F>>>=5,V-=5,P.ncode=4+(15&F),F>>>=4,V-=4,286<P.nlen||30<P.ndist){D.msg="too many length or distance symbols",P.mode=30;break}P.have=0,P.mode=18;case 18:for(;P.have<P.ncode;){for(;V<3;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}P.lens[ke[P.have++]]=7&F,F>>>=3,V-=3}for(;P.have<19;)P.lens[ke[P.have++]]=0;if(P.lencode=P.lendyn,P.lenbits=7,le={bits:P.lenbits},H=u(0,P.lens,0,19,P.lencode,0,P.work,le),P.lenbits=le.bits,H){D.msg="invalid code lengths set",P.mode=30;break}P.have=0,P.mode=19;case 19:for(;P.have<P.nlen+P.ndist;){for(;fe=(ee=P.lencode[F&(1<<P.lenbits)-1])>>>16&255,pe=65535&ee,!((ce=ee>>>24)<=V);){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(pe<16)F>>>=ce,V-=ce,P.lens[P.have++]=pe;else{if(pe===16){for($=ce+2;V<$;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(F>>>=ce,V-=ce,P.have===0){D.msg="invalid bit length repeat",P.mode=30;break}B=P.lens[P.have-1],ae=3+(3&F),F>>>=2,V-=2}else if(pe===17){for($=ce+3;V<$;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}V-=ce,B=0,ae=3+(7&(F>>>=ce)),F>>>=3,V-=3}else{for($=ce+7;V<$;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}V-=ce,B=0,ae=11+(127&(F>>>=ce)),F>>>=7,V-=7}if(P.have+ae>P.nlen+P.ndist){D.msg="invalid bit length repeat",P.mode=30;break}for(;ae--;)P.lens[P.have++]=B}}if(P.mode===30)break;if(P.lens[256]===0){D.msg="invalid code -- missing end-of-block",P.mode=30;break}if(P.lenbits=9,le={bits:P.lenbits},H=u(d,P.lens,0,P.nlen,P.lencode,0,P.work,le),P.lenbits=le.bits,H){D.msg="invalid literal/lengths set",P.mode=30;break}if(P.distbits=6,P.distcode=P.distdyn,le={bits:P.distbits},H=u(f,P.lens,P.nlen,P.ndist,P.distcode,0,P.work,le),P.distbits=le.bits,H){D.msg="invalid distances set",P.mode=30;break}if(P.mode=20,K===6)break e;case 20:P.mode=21;case 21:if(6<=X&&258<=q){D.next_out=Y,D.avail_out=q,D.next_in=G,D.avail_in=X,P.hold=F,P.bits=V,c(D,re),Y=D.next_out,Z=D.output,q=D.avail_out,G=D.next_in,W=D.input,X=D.avail_in,F=P.hold,V=P.bits,P.mode===12&&(P.back=-1);break}for(P.back=0;fe=(ee=P.lencode[F&(1<<P.lenbits)-1])>>>16&255,pe=65535&ee,!((ce=ee>>>24)<=V);){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(fe&&(240&fe)==0){for(_e=ce,ne=fe,He=pe;fe=(ee=P.lencode[He+((F&(1<<_e+ne)-1)>>_e)])>>>16&255,pe=65535&ee,!(_e+(ce=ee>>>24)<=V);){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}F>>>=_e,V-=_e,P.back+=_e}if(F>>>=ce,V-=ce,P.back+=ce,P.length=pe,fe===0){P.mode=26;break}if(32&fe){P.back=-1,P.mode=12;break}if(64&fe){D.msg="invalid literal/length code",P.mode=30;break}P.extra=15&fe,P.mode=22;case 22:if(P.extra){for($=P.extra;V<$;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}P.length+=F&(1<<P.extra)-1,F>>>=P.extra,V-=P.extra,P.back+=P.extra}P.was=P.length,P.mode=23;case 23:for(;fe=(ee=P.distcode[F&(1<<P.distbits)-1])>>>16&255,pe=65535&ee,!((ce=ee>>>24)<=V);){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if((240&fe)==0){for(_e=ce,ne=fe,He=pe;fe=(ee=P.distcode[He+((F&(1<<_e+ne)-1)>>_e)])>>>16&255,pe=65535&ee,!(_e+(ce=ee>>>24)<=V);){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}F>>>=_e,V-=_e,P.back+=_e}if(F>>>=ce,V-=ce,P.back+=ce,64&fe){D.msg="invalid distance code",P.mode=30;break}P.offset=pe,P.extra=15&fe,P.mode=24;case 24:if(P.extra){for($=P.extra;V<$;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}P.offset+=F&(1<<P.extra)-1,F>>>=P.extra,V-=P.extra,P.back+=P.extra}if(P.offset>P.dmax){D.msg="invalid distance too far back",P.mode=30;break}P.mode=25;case 25:if(q===0)break e;if(ae=re-q,P.offset>ae){if((ae=P.offset-ae)>P.whave&&P.sane){D.msg="invalid distance too far back",P.mode=30;break}he=ae>P.wnext?(ae-=P.wnext,P.wsize-ae):P.wnext-ae,ae>P.length&&(ae=P.length),ue=P.window}else ue=Z,he=Y-P.offset,ae=P.length;for(q<ae&&(ae=q),q-=ae,P.length-=ae;Z[Y++]=ue[he++],--ae;);P.length===0&&(P.mode=21);break;case 26:if(q===0)break e;Z[Y++]=P.length,q--,P.mode=21;break;case 27:if(P.wrap){for(;V<32;){if(X===0)break e;X--,F|=W[G++]<<V,V+=8}if(re-=q,D.total_out+=re,P.total+=re,re&&(D.adler=P.check=P.flags?l(P.check,Z,re,Y-re):o(P.check,Z,re,Y-re)),re=q,(P.flags?F:v(F))!==P.check){D.msg="incorrect data check",P.mode=30;break}V=F=0}P.mode=28;case 28:if(P.wrap&&P.flags){for(;V<32;){if(X===0)break e;X--,F+=W[G++]<<V,V+=8}if(F!==(4294967295&P.total)){D.msg="incorrect length check",P.mode=30;break}V=F=0}P.mode=29;case 29:H=1;break e;case 30:H=-3;break e;case 31:return-4;case 32:default:return p}return D.next_out=Y,D.avail_out=q,D.next_in=G,D.avail_in=X,P.hold=F,P.bits=V,(P.wsize||re!==D.avail_out&&P.mode<30&&(P.mode<27||K!==4))&&z(D,D.output,D.next_out,re-D.avail_out)?(P.mode=31,-4):(te-=D.avail_in,re-=D.avail_out,D.total_in+=te,D.total_out+=re,P.total+=re,P.wrap&&re&&(D.adler=P.check=P.flags?l(P.check,Z,re,D.next_out-re):o(P.check,Z,re,D.next_out-re)),D.data_type=P.bits+(P.last?64:0)+(P.mode===12?128:0)+(P.mode===20||P.mode===15?256:0),(te==0&&re===0||K===4)&&H===g&&(H=-5),H)},i.inflateEnd=function(D){if(!D||!D.state)return p;var K=D.state;return K.window&&(K.window=null),D.state=null,g},i.inflateGetHeader=function(D,K){var P;return D&&D.state?(2&(P=D.state).wrap)==0?p:((P.head=K).done=!1,g):p},i.inflateSetDictionary=function(D,K){var P,W=K.length;return D&&D.state?(P=D.state).wrap!==0&&P.mode!==11?p:P.mode===11&&o(1,K,W,0)!==P.check?-3:z(D,K,W,W)?(P.mode=31,-4):(P.havedict=1,g):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,g,p,x,y,b,v){var E,w,A,N,C,T,O,k,R,z=v.bits,D=0,K=0,P=0,W=0,Z=0,G=0,Y=0,X=0,q=0,F=0,V=null,te=0,re=new a.Buf16(16),ae=new a.Buf16(16),he=null,ue=0;for(D=0;D<=15;D++)re[D]=0;for(K=0;K<p;K++)re[f[g+K]]++;for(Z=z,W=15;1<=W&&re[W]===0;W--);if(W<Z&&(Z=W),W===0)return x[y++]=20971520,x[y++]=20971520,v.bits=1,0;for(P=1;P<W&&re[P]===0;P++);for(Z<P&&(Z=P),D=X=1;D<=15;D++)if(X<<=1,(X-=re[D])<0)return-1;if(0<X&&(d===0||W!==1))return-1;for(ae[1]=0,D=1;D<15;D++)ae[D+1]=ae[D]+re[D];for(K=0;K<p;K++)f[g+K]!==0&&(b[ae[f[g+K]]++]=K);if(T=d===0?(V=he=b,19):d===1?(V=o,te-=257,he=l,ue-=257,256):(V=c,he=u,-1),D=P,C=y,Y=K=F=0,A=-1,N=(q=1<<(G=Z))-1,d===1&&852<q||d===2&&592<q)return 1;for(;;){for(O=D-Y,R=b[K]<T?(k=0,b[K]):b[K]>T?(k=he[ue+b[K]],V[te+b[K]]):(k=96,0),E=1<<D-Y,P=w=1<<G;x[C+(F>>Y)+(w-=E)]=O<<24|k<<16|R|0,w!==0;);for(E=1<<D-1;F&E;)E>>=1;if(E!==0?(F&=E-1,F+=E):F=0,K++,--re[D]==0){if(D===W)break;D=f[g+b[K]]}if(Z<D&&(F&N)!==A){for(Y===0&&(Y=Z),C+=P,X=1<<(G=D-Y);G+Y<W&&!((X-=re[G+Y])<=0);)G++,X<<=1;if(q+=1<<G,d===1&&852<q||d===2&&592<q)return 1;x[A=F&N]=Z<<24|G<<16|C-y|0}}return F!==0&&(x[C+F]=D-Y<<24|64<<16|0),v.bits=Z,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(ee){for(var de=ee.length;0<=--de;)ee[de]=0}var u=0,d=29,f=256,g=f+1+d,p=30,x=19,y=2*g+1,b=15,v=16,E=7,w=256,A=16,N=17,C=18,T=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],O=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k=[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],z=new Array(2*(g+2));c(z);var D=new Array(2*p);c(D);var K=new Array(512);c(K);var P=new Array(256);c(P);var W=new Array(d);c(W);var Z,G,Y,X=new Array(p);function q(ee,de,ke,we,Ee){this.static_tree=ee,this.extra_bits=de,this.extra_base=ke,this.elems=we,this.max_length=Ee,this.has_stree=ee&&ee.length}function F(ee,de){this.dyn_tree=ee,this.max_code=0,this.stat_desc=de}function V(ee){return ee<256?K[ee]:K[256+(ee>>>7)]}function te(ee,de){ee.pending_buf[ee.pending++]=255&de,ee.pending_buf[ee.pending++]=de>>>8&255}function re(ee,de,ke){ee.bi_valid>v-ke?(ee.bi_buf|=de<<ee.bi_valid&65535,te(ee,ee.bi_buf),ee.bi_buf=de>>v-ee.bi_valid,ee.bi_valid+=ke-v):(ee.bi_buf|=de<<ee.bi_valid&65535,ee.bi_valid+=ke)}function ae(ee,de,ke){re(ee,ke[2*de],ke[2*de+1])}function he(ee,de){for(var ke=0;ke|=1&ee,ee>>>=1,ke<<=1,0<--de;);return ke>>>1}function ue(ee,de,ke){var we,Ee,U=new Array(b+1),I=0;for(we=1;we<=b;we++)U[we]=I=I+ke[we-1]<<1;for(Ee=0;Ee<=de;Ee++){var se=ee[2*Ee+1];se!==0&&(ee[2*Ee]=he(U[se]++,se))}}function ce(ee){var de;for(de=0;de<g;de++)ee.dyn_ltree[2*de]=0;for(de=0;de<p;de++)ee.dyn_dtree[2*de]=0;for(de=0;de<x;de++)ee.bl_tree[2*de]=0;ee.dyn_ltree[2*w]=1,ee.opt_len=ee.static_len=0,ee.last_lit=ee.matches=0}function fe(ee){8<ee.bi_valid?te(ee,ee.bi_buf):0<ee.bi_valid&&(ee.pending_buf[ee.pending++]=ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0}function pe(ee,de,ke,we){var Ee=2*de,U=2*ke;return ee[Ee]<ee[U]||ee[Ee]===ee[U]&&we[de]<=we[ke]}function _e(ee,de,ke){for(var we=ee.heap[ke],Ee=ke<<1;Ee<=ee.heap_len&&(Ee<ee.heap_len&&pe(de,ee.heap[Ee+1],ee.heap[Ee],ee.depth)&&Ee++,!pe(de,we,ee.heap[Ee],ee.depth));)ee.heap[ke]=ee.heap[Ee],ke=Ee,Ee<<=1;ee.heap[ke]=we}function ne(ee,de,ke){var we,Ee,U,I,se=0;if(ee.last_lit!==0)for(;we=ee.pending_buf[ee.d_buf+2*se]<<8|ee.pending_buf[ee.d_buf+2*se+1],Ee=ee.pending_buf[ee.l_buf+se],se++,we===0?ae(ee,Ee,de):(ae(ee,(U=P[Ee])+f+1,de),(I=T[U])!==0&&re(ee,Ee-=W[U],I),ae(ee,U=V(--we),ke),(I=O[U])!==0&&re(ee,we-=X[U],I)),se<ee.last_lit;);ae(ee,w,de)}function He(ee,de){var ke,we,Ee,U=de.dyn_tree,I=de.stat_desc.static_tree,se=de.stat_desc.has_stree,ye=de.stat_desc.elems,Se=-1;for(ee.heap_len=0,ee.heap_max=y,ke=0;ke<ye;ke++)U[2*ke]!==0?(ee.heap[++ee.heap_len]=Se=ke,ee.depth[ke]=0):U[2*ke+1]=0;for(;ee.heap_len<2;)U[2*(Ee=ee.heap[++ee.heap_len]=Se<2?++Se:0)]=1,ee.depth[Ee]=0,ee.opt_len--,se&&(ee.static_len-=I[2*Ee+1]);for(de.max_code=Se,ke=ee.heap_len>>1;1<=ke;ke--)_e(ee,U,ke);for(Ee=ye;ke=ee.heap[1],ee.heap[1]=ee.heap[ee.heap_len--],_e(ee,U,1),we=ee.heap[1],ee.heap[--ee.heap_max]=ke,ee.heap[--ee.heap_max]=we,U[2*Ee]=U[2*ke]+U[2*we],ee.depth[Ee]=(ee.depth[ke]>=ee.depth[we]?ee.depth[ke]:ee.depth[we])+1,U[2*ke+1]=U[2*we+1]=Ee,ee.heap[1]=Ee++,_e(ee,U,1),2<=ee.heap_len;);ee.heap[--ee.heap_max]=ee.heap[1],(function(ve,Be){var Ge,Ke,ct,$e,ge,Je,qe=Be.dyn_tree,Ze=Be.max_code,lt=Be.stat_desc.static_tree,ie=Be.stat_desc.has_stree,Ie=Be.stat_desc.extra_bits,xe=Be.stat_desc.extra_base,Ue=Be.stat_desc.max_length,Pe=0;for($e=0;$e<=b;$e++)ve.bl_count[$e]=0;for(qe[2*ve.heap[ve.heap_max]+1]=0,Ge=ve.heap_max+1;Ge<y;Ge++)Ue<($e=qe[2*qe[2*(Ke=ve.heap[Ge])+1]+1]+1)&&($e=Ue,Pe++),qe[2*Ke+1]=$e,Ze<Ke||(ve.bl_count[$e]++,ge=0,xe<=Ke&&(ge=Ie[Ke-xe]),Je=qe[2*Ke],ve.opt_len+=Je*($e+ge),ie&&(ve.static_len+=Je*(lt[2*Ke+1]+ge)));if(Pe!==0){do{for($e=Ue-1;ve.bl_count[$e]===0;)$e--;ve.bl_count[$e]--,ve.bl_count[$e+1]+=2,ve.bl_count[Ue]--,Pe-=2}while(0<Pe);for($e=Ue;$e!==0;$e--)for(Ke=ve.bl_count[$e];Ke!==0;)Ze<(ct=ve.heap[--Ge])||(qe[2*ct+1]!==$e&&(ve.opt_len+=($e-qe[2*ct+1])*qe[2*ct],qe[2*ct+1]=$e),Ke--)}})(ee,de),ue(U,Se,ee.bl_count)}function B(ee,de,ke){var we,Ee,U=-1,I=de[1],se=0,ye=7,Se=4;for(I===0&&(ye=138,Se=3),de[2*(ke+1)+1]=65535,we=0;we<=ke;we++)Ee=I,I=de[2*(we+1)+1],++se<ye&&Ee===I||(se<Se?ee.bl_tree[2*Ee]+=se:Ee!==0?(Ee!==U&&ee.bl_tree[2*Ee]++,ee.bl_tree[2*A]++):se<=10?ee.bl_tree[2*N]++:ee.bl_tree[2*C]++,U=Ee,Se=(se=0)===I?(ye=138,3):Ee===I?(ye=6,3):(ye=7,4))}function H(ee,de,ke){var we,Ee,U=-1,I=de[1],se=0,ye=7,Se=4;for(I===0&&(ye=138,Se=3),we=0;we<=ke;we++)if(Ee=I,I=de[2*(we+1)+1],!(++se<ye&&Ee===I)){if(se<Se)for(;ae(ee,Ee,ee.bl_tree),--se!=0;);else Ee!==0?(Ee!==U&&(ae(ee,Ee,ee.bl_tree),se--),ae(ee,A,ee.bl_tree),re(ee,se-3,2)):se<=10?(ae(ee,N,ee.bl_tree),re(ee,se-3,3)):(ae(ee,C,ee.bl_tree),re(ee,se-11,7));U=Ee,Se=(se=0)===I?(ye=138,3):Ee===I?(ye=6,3):(ye=7,4)}}c(X);var le=!1;function $(ee,de,ke,we){re(ee,(u<<1)+(we?1:0),3),(function(Ee,U,I,se){fe(Ee),te(Ee,I),te(Ee,~I),a.arraySet(Ee.pending_buf,Ee.window,U,I,Ee.pending),Ee.pending+=I})(ee,de,ke)}i._tr_init=function(ee){le||((function(){var de,ke,we,Ee,U,I=new Array(b+1);for(Ee=we=0;Ee<d-1;Ee++)for(W[Ee]=we,de=0;de<1<<T[Ee];de++)P[we++]=Ee;for(P[we-1]=Ee,Ee=U=0;Ee<16;Ee++)for(X[Ee]=U,de=0;de<1<<O[Ee];de++)K[U++]=Ee;for(U>>=7;Ee<p;Ee++)for(X[Ee]=U<<7,de=0;de<1<<O[Ee]-7;de++)K[256+U++]=Ee;for(ke=0;ke<=b;ke++)I[ke]=0;for(de=0;de<=143;)z[2*de+1]=8,de++,I[8]++;for(;de<=255;)z[2*de+1]=9,de++,I[9]++;for(;de<=279;)z[2*de+1]=7,de++,I[7]++;for(;de<=287;)z[2*de+1]=8,de++,I[8]++;for(ue(z,g+1,I),de=0;de<p;de++)D[2*de+1]=5,D[2*de]=he(de,5);Z=new q(z,T,f+1,g,b),G=new q(D,O,0,p,b),Y=new q(new Array(0),k,0,x,E)})(),le=!0),ee.l_desc=new F(ee.dyn_ltree,Z),ee.d_desc=new F(ee.dyn_dtree,G),ee.bl_desc=new F(ee.bl_tree,Y),ee.bi_buf=0,ee.bi_valid=0,ce(ee)},i._tr_stored_block=$,i._tr_flush_block=function(ee,de,ke,we){var Ee,U,I=0;0<ee.level?(ee.strm.data_type===2&&(ee.strm.data_type=(function(se){var ye,Se=4093624447;for(ye=0;ye<=31;ye++,Se>>>=1)if(1&Se&&se.dyn_ltree[2*ye]!==0)return o;if(se.dyn_ltree[18]!==0||se.dyn_ltree[20]!==0||se.dyn_ltree[26]!==0)return l;for(ye=32;ye<f;ye++)if(se.dyn_ltree[2*ye]!==0)return l;return o})(ee)),He(ee,ee.l_desc),He(ee,ee.d_desc),I=(function(se){var ye;for(B(se,se.dyn_ltree,se.l_desc.max_code),B(se,se.dyn_dtree,se.d_desc.max_code),He(se,se.bl_desc),ye=x-1;3<=ye&&se.bl_tree[2*R[ye]+1]===0;ye--);return se.opt_len+=3*(ye+1)+5+5+4,ye})(ee),Ee=ee.opt_len+3+7>>>3,(U=ee.static_len+3+7>>>3)<=Ee&&(Ee=U)):Ee=U=ke+5,ke+4<=Ee&&de!==-1?$(ee,de,ke,we):ee.strategy===4||U===Ee?(re(ee,2+(we?1:0),3),ne(ee,z,D)):(re(ee,4+(we?1:0),3),(function(se,ye,Se,ve){var Be;for(re(se,ye-257,5),re(se,Se-1,5),re(se,ve-4,4),Be=0;Be<ve;Be++)re(se,se.bl_tree[2*R[Be]+1],3);H(se,se.dyn_ltree,ye-1),H(se,se.dyn_dtree,Se-1)})(ee,ee.l_desc.max_code+1,ee.d_desc.max_code+1,I+1),ne(ee,ee.dyn_ltree,ee.dyn_dtree)),ce(ee),we&&fe(ee)},i._tr_tally=function(ee,de,ke){return ee.pending_buf[ee.d_buf+2*ee.last_lit]=de>>>8&255,ee.pending_buf[ee.d_buf+2*ee.last_lit+1]=255&de,ee.pending_buf[ee.l_buf+ee.last_lit]=255&ke,ee.last_lit++,de===0?ee.dyn_ltree[2*ke]++:(ee.matches++,de--,ee.dyn_ltree[2*(P[ke]+f+1)]++,ee.dyn_dtree[2*V(de)]++),ee.last_lit===ee.lit_bufsize-1},i._tr_align=function(ee){re(ee,2,3),ae(ee,w,z),(function(de){de.bi_valid===16?(te(de,de.bi_buf),de.bi_buf=0,de.bi_valid=0):8<=de.bi_valid&&(de.pending_buf[de.pending++]=255&de.bi_buf,de.bi_buf>>=8,de.bi_valid-=8)})(ee)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(o,l){if(!o.setImmediate){var c,u,d,f,g=1,p={},x=!1,y=o.document,b=Object.getPrototypeOf&&Object.getPrototypeOf(o);b=b&&b.setTimeout?b:o,c={}.toString.call(o.process)==="[object process]"?function(A){process.nextTick(function(){E(A)})}:(function(){if(o.postMessage&&!o.importScripts){var A=!0,N=o.onmessage;return o.onmessage=function(){A=!1},o.postMessage("","*"),o.onmessage=N,A}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",w,!1):o.attachEvent("onmessage",w),function(A){o.postMessage(f+A,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){E(A.data)},function(A){d.port2.postMessage(A)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(A){var N=y.createElement("script");N.onreadystatechange=function(){E(A),N.onreadystatechange=null,u.removeChild(N),N=null},u.appendChild(N)}):function(A){setTimeout(E,0,A)},b.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var N=new Array(arguments.length-1),C=0;C<N.length;C++)N[C]=arguments[C+1];var T={callback:A,args:N};return p[g]=T,c(g),g++},b.clearImmediate=v}function v(A){delete p[A]}function E(A){if(x)setTimeout(E,0,A);else{var N=p[A];if(N){x=!0;try{(function(C){var T=C.callback,O=C.args;switch(O.length){case 0:T();break;case 1:T(O[0]);break;case 2:T(O[0],O[1]);break;case 3:T(O[0],O[1],O[2]);break;default:T.apply(l,O)}})(N)}finally{v(A),x=!1}}}}function w(A){A.source===o&&typeof A.data=="string"&&A.data.indexOf(f)===0&&E(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Pv<"u"?Pv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(SC)),SC.exports}var bOe=xOe();const yOe=_o(bOe);function vOe(t){const e=new gi;if(!t)return e;const n=t.trim().split(/\s+/).map(parseFloat);return n.length>=12&&e.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),e}const A$=vOe;async function T$(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=a.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function _Oe(t){const e=await yOe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(p){const x=p.startsWith("/")?p.slice(1):p,y=e.files[x];if(!y)return null;const b=await y.async("string");return i.parseFromString(b,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const p=await c.async("string"),y=i.parseFromString(p,"application/xml").getElementsByTagName("object");for(let b=0;b<y.length;b++){const v=y[b],E=v.getAttribute("id");if(!E)continue;const w=Array.from(v.children).filter(N=>N.tagName==="metadata"&&N.getAttribute("key")==="extruder");if(w.length>0){const N=w[0].getAttribute("value");N&&o.set(E,Math.max(0,parseInt(N,10)-1))}const A=v.getElementsByTagName("part");for(let N=0;N<A.length;N++){const C=A[N],T=C.getAttribute("id");if(!T)continue;const O=Array.from(C.children).filter(k=>k.tagName==="metadata"&&k.getAttribute("key")==="extruder");if(O.length>0){const k=O[0].getAttribute("value");k&&l.set(`${E}:${T}`,Math.max(0,parseInt(k,10)-1))}}}}catch{}const u=Object.keys(e.files).find(p=>p==="3D/3dmodel.model"||p.endsWith("/3dmodel.model"));if(!u){const p=Object.keys(e.files).find(x=>x.endsWith(".model"));if(p){const x=await a(p);if(x){const y=await T$(x,0);y.length>0&&n.set("1",{id:"1",meshes:y,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let p=0;p<f.length;p++){const x=f[p],y=x.getAttribute("id");if(!y)continue;let b=o.get(y)??-1;if(b<0){const A=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";b=Math.max(0,parseInt(A,10)-1)}const v=[],E=x.getElementsByTagName("mesh");for(let A=0;A<E.length;A++){const N=E[A],C=[],T=[],O=N.getElementsByTagName("vertex");for(let R=0;R<O.length;R++){const z=O[R];C.push(parseFloat(z.getAttribute("x")||"0"),parseFloat(z.getAttribute("y")||"0"),parseFloat(z.getAttribute("z")||"0"))}const k=N.getElementsByTagName("triangle");for(let R=0;R<k.length;R++){const z=k[R];T.push(parseInt(z.getAttribute("v1")||"0"),parseInt(z.getAttribute("v2")||"0"),parseInt(z.getAttribute("v3")||"0"))}C.length>0&&T.length>0&&v.push({vertices:C,triangles:T,extruder:b})}const w=x.getElementsByTagName("component");for(let A=0;A<w.length;A++){const N=w[A],C=N.getAttribute("p:path")||N.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),T=N.getAttribute("objectid");if(C){const O=await a(C);if(O){const k=T?`${y}:${T}`:null,R=k?l.get(k)??b:b,z=await T$(O,R),D=N.getAttribute("transform"),K=A$(D);for(const P of z)if(D){const W=[];for(let Z=0;Z<P.vertices.length;Z+=3){const G=new it(P.vertices[Z],P.vertices[Z+1],P.vertices[Z+2]);G.applyMatrix4(K),W.push(G.x,G.y,G.z)}v.push({vertices:W,triangles:P.triangles,extruder:P.extruder})}else v.push(P)}}}v.length>0&&n.set(y,{id:y,meshes:v,defaultExtruder:b})}const g=d.getElementsByTagName("build");if(g.length>0){const p=g[0].getElementsByTagName("item");for(let x=0;x<p.length;x++){const y=p[x],b=y.getAttribute("objectid");if(!b)continue;const v=A$(y.getAttribute("transform"));r.push({objectId:b,transform:v})}}return{objects:n,buildItems:r}}function C$(t){const e=new Ul,n=new Float32Array(t.vertices.length);for(let r=0;r<t.vertices.length;r+=3)n[r]=t.vertices[r],n[r+1]=t.vertices[r+2],n[r+2]=t.vertices[r+1];return e.setAttribute("position",new mo(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function wOe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=S.useRef(null),a=S.useRef(null),o=S.useRef(null),l=S.useRef(null),c=S.useRef(null),[u,d]=S.useState(!0),[f,g]=S.useState(null);S.useEffect(()=>{if(!i.current)return;const y=i.current,b=y.clientWidth,v=y.clientHeight,E=new Jke;E.background=new Tn(1710618),o.current=E;const w=new ao(45,b/v,.1,1e4);w.position.set(150,150,150),l.current=w;const A=new tOe({antialias:!0});A.setSize(b,v),A.setPixelRatio(window.devicePixelRatio),y.appendChild(A.domElement),a.current=A;const N=new rOe(w,A.domElement);N.enableDamping=!0,N.dampingFactor=.05,c.current=N;const C=new d3e(16777215,.6);E.add(C);const T=new ZH(16777215,.8);T.position.set(100,100,100),E.add(T);const O=new ZH(16777215,.4);O.position.set(-100,50,-100),E.add(O);const k=Math.max(e.x,e.y),R=Math.ceil(k/16),z=new f3e(k,R,4473924,3355443);E.add(z);const D=new GO(e.x,e.y),K=new HO({color:44610,transparent:!0,opacity:.15,side:ml}),P=new kl(D,K);P.rotation.x=-Math.PI/2,P.position.y=-.5,E.add(P);let W;const Z=()=>{W=requestAnimationFrame(Z),N.update(),A.render(E,w)};Z(),fetch(t).then(Y=>{if(!Y.ok)throw new Error("Failed to load file");return Y.arrayBuffer()}).then(_Oe).then(({objects:Y,buildItems:X})=>{if(Y.size===0)throw new Error("No meshes found in 3MF file");const q=pe=>{const ne=n?.[pe]||"#00ae42",He=new Tn(ne);return new s3e({color:He,shininess:30,flatShading:!1})},F=new n0,V=new Map;if(X.length>0)for(const pe of X){const _e=Y.get(pe.objectId);if(_e)for(const ne of _e.meshes){const He=pe.extruder??ne.extruder,B=[];for(let le=0;le<ne.vertices.length;le+=3){const $=new it(ne.vertices[le],ne.vertices[le+1],ne.vertices[le+2]);$.applyMatrix4(pe.transform),B.push($.x,$.y,$.z)}const H=C$({vertices:B,triangles:ne.triangles});V.has(He)||V.set(He,[]),V.get(He).push(H)}}else for(const pe of Y.values())for(const _e of pe.meshes){const ne=_e.extruder,He=C$(_e);V.has(ne)||V.set(ne,[]),V.get(ne).push(He)}for(const[pe,_e]of V){if(_e.length===0)continue;const ne=_e.length===1?_e[0]:gOe(_e,!1);if(ne){const He=q(pe),B=new kl(ne,He);F.add(B)}if(_e.length>1)for(const He of _e)He.dispose()}const te=new Sf().setFromObject(F),re=te.getCenter(new it);F.position.y=-te.min.y,X.length===0&&(F.position.x=-re.x,F.position.z=-re.z),E.add(F);const ae=new Sf().setFromObject(F),he=ae.getCenter(new it),ue=ae.getSize(new it),fe=Math.max(ue.x,ue.y,ue.z)*1.8;w.position.set(he.x+fe*.7,he.y+fe*.5,he.z+fe*.7),N.target.copy(he),N.update(),d(!1)}).catch(Y=>{g(Y.message),d(!1)});const G=()=>{if(!y)return;const Y=y.clientWidth,X=y.clientHeight;w.aspect=Y/X,w.updateProjectionMatrix(),A.setSize(Y,X)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),cancelAnimationFrame(W),N.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())},x=y=>{l.current&&l.current.position.multiplyScalar(y)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(gt,{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(Te,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(Zde,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(ehe,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:p,children:s.jsx(fg,{className:"w-4 h-4"})})]})]})}const p2="159",Dm={ROTATE:0,DOLLY:1,PAN:2},Om={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},SOe=0,k$=1,MOe=2,fQ=1,EOe=2,yc=3,Od=0,ls=1,Nc=2,gd=0,Mp=1,j$=2,P$=3,R$=4,NOe=5,Ch=100,AOe=101,TOe=102,D$=103,O$=104,COe=200,kOe=201,jOe=202,POe=203,oP=204,lP=205,ROe=206,DOe=207,OOe=208,LOe=209,IOe=210,FOe=211,UOe=212,zOe=213,BOe=214,HOe=0,$Oe=1,VOe=2,aS=3,GOe=4,WOe=5,qOe=6,KOe=7,qO=0,XOe=1,YOe=2,xd=0,ZOe=1,QOe=2,JOe=3,e4e=4,t4e=5,mQ=300,Yp=301,Zp=302,cP=303,uP=304,g2=306,dP=1e3,Io=1001,hP=1002,oa=1003,L$=1004,MC=1005,so=1006,n4e=1007,hb=1008,bd=1009,r4e=1010,i4e=1011,KO=1012,pQ=1013,od=1014,Rc=1015,fb=1016,gQ=1017,xQ=1018,Xh=1020,a4e=1021,oo=1023,s4e=1024,o4e=1025,Yh=1026,Qp=1027,l4e=1028,bQ=1029,c4e=1030,yQ=1031,vQ=1033,EC=33776,NC=33777,AC=33778,TC=33779,I$=35840,F$=35841,U$=35842,z$=35843,_Q=36196,B$=37492,H$=37496,$$=37808,V$=37809,G$=37810,W$=37811,q$=37812,K$=37813,X$=37814,Y$=37815,Z$=37816,Q$=37817,J$=37818,eV=37819,tV=37820,nV=37821,CC=36492,rV=36494,iV=36495,u4e=36283,aV=36284,sV=36285,oV=36286,wQ=3e3,Zh=3001,d4e=3200,h4e=3201,SQ=0,f4e=1,lo="",la="srgb",tu="srgb-linear",XO="display-p3",x2="display-p3-linear",sS="linear",Sr="srgb",oS="rec709",lS="p3",Lm=7680,lV=519,m4e=512,p4e=513,g4e=514,MQ=515,x4e=516,b4e=517,y4e=518,v4e=519,fP=35044,cV="300 es",mP=1035,yl=2e3,mb=2001;class Of{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}}const xa=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let uV=1234567;const g0=Math.PI/180,pb=180/Math.PI;function zc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(xa[t&255]+xa[t>>8&255]+xa[t>>16&255]+xa[t>>24&255]+"-"+xa[e&255]+xa[e>>8&255]+"-"+xa[e>>16&15|64]+xa[e>>24&255]+"-"+xa[n&63|128]+xa[n>>8&255]+"-"+xa[n>>16&255]+xa[n>>24&255]+xa[r&255]+xa[r>>8&255]+xa[r>>16&255]+xa[r>>24&255]).toLowerCase()}function ca(t,e,n){return Math.max(e,Math.min(n,t))}function YO(t,e){return(t%e+e)%e}function _4e(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function w4e(t,e,n){return t!==e?(n-t)/(e-t):0}function x0(t,e,n){return(1-n)*t+n*e}function S4e(t,e,n,r){return x0(t,e,1-Math.exp(-n*r))}function M4e(t,e=1){return e-Math.abs(YO(t,e*2)-e)}function E4e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function N4e(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function A4e(t,e){return t+Math.floor(Math.random()*(e-t+1))}function T4e(t,e){return t+Math.random()*(e-t)}function C4e(t){return t*(.5-Math.random())}function k4e(t){t!==void 0&&(uV=t);let e=uV+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function j4e(t){return t*g0}function P4e(t){return t*pb}function pP(t){return(t&t-1)===0&&t!==0}function R4e(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function cS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function D4e(t,e,n,r,i){const a=Math.cos,o=Math.sin,l=a(n/2),c=o(n/2),u=a((e+r)/2),d=o((e+r)/2),f=a((e-r)/2),g=o((e-r)/2),p=a((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*g,l*u);break;case"YZY":t.set(c*g,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*g,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*p,l*u);break;case"YXY":t.set(c*p,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*p,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function pl(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function sr(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 EQ={DEG2RAD:g0,RAD2DEG:pb,generateUUID:zc,clamp:ca,euclideanModulo:YO,mapLinear:_4e,inverseLerp:w4e,lerp:x0,damp:S4e,pingpong:M4e,smoothstep:E4e,smootherstep:N4e,randInt:A4e,randFloat:T4e,randFloatSpread:C4e,seededRandom:k4e,degToRad:j4e,radToDeg:P4e,isPowerOfTwo:pP,ceilPowerOfTwo:R4e,floorPowerOfTwo:cS,setQuaternionFromProperEuler:D4e,normalize:sr,denormalize:pl};class an{constructor(e=0,n=0){an.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(ca(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class wn{constructor(e,n,r,i,a,o,l,c,u){wn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],g=r[2],p=r[5],x=r[8],y=i[0],b=i[3],v=i[6],E=i[1],w=i[4],A=i[7],N=i[2],C=i[5],T=i[8];return a[0]=o*y+l*E+c*N,a[3]=o*b+l*w+c*C,a[6]=o*v+l*A+c*T,a[1]=u*y+d*E+f*N,a[4]=u*b+d*w+f*C,a[7]=u*v+d*A+f*T,a[2]=g*y+p*E+x*N,a[5]=g*b+p*w+x*C,a[8]=g*v+p*A+x*T,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,g=l*c-d*a,p=u*a-o*c,x=n*f+r*g+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=f*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=g*y,e[4]=(d*n-i*c)*y,e[5]=(i*a-l*n)*y,e[6]=p*y,e[7]=(r*c-u*n)*y,e[8]=(o*n-r*a)*y,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(kC.makeScale(e,n)),this}rotate(e){return this.premultiply(kC.makeRotation(-e)),this}translate(e,n){return this.premultiply(kC.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 kC=new wn;function NQ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function uS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function O4e(){const t=uS("canvas");return t.style.display="block",t}const dV={};function b0(t){t in dV||(dV[t]=!0,console.warn(t))}const hV=new wn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),fV=new wn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),E_={[tu]:{transfer:sS,primaries:oS,toReference:t=>t,fromReference:t=>t},[la]:{transfer:Sr,primaries:oS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[x2]:{transfer:sS,primaries:lS,toReference:t=>t.applyMatrix3(fV),fromReference:t=>t.applyMatrix3(hV)},[XO]:{transfer:Sr,primaries:lS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(fV),fromReference:t=>t.applyMatrix3(hV).convertLinearToSRGB()}},L4e=new Set([tu,x2]),or={enabled:!0,_workingColorSpace:tu,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(!L4e.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=E_[e].toReference,i=E_[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 E_[t].primaries},getTransfer:function(t){return t===lo?sS:E_[t].transfer}};function Ep(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function jC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Im;class AQ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Im===void 0&&(Im=uS("canvas")),Im.width=e.width,Im.height=e.height;const r=Im.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Im}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=uS("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]=Ep(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(Ep(n[r]/255)*255):n[r]=Ep(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 I4e=0;class TQ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:I4e++}),this.uuid=zc(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(PC(i[o].image)):a.push(PC(i[o]))}else a=PC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function PC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?AQ.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 F4e=0;class cs extends Of{constructor(e=cs.DEFAULT_IMAGE,n=cs.DEFAULT_MAPPING,r=Io,i=Io,a=so,o=hb,l=oo,c=bd,u=cs.DEFAULT_ANISOTROPY,d=lo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:F4e++}),this.uuid=zc(),this.name="",this.source=new TQ(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 an(0,0),this.repeat=new an(1,1),this.center=new an(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new wn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(b0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Zh?la:lo),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==mQ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case dP:e.x=e.x-Math.floor(e.x);break;case Io:e.x=e.x<0?0:1;break;case hP: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 dP:e.y=e.y-Math.floor(e.y);break;case Io:e.y=e.y<0?0:1;break;case hP: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 b0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===la?Zh:wQ}set encoding(e){b0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Zh?la:lo}}cs.DEFAULT_IMAGE=null;cs.DEFAULT_MAPPING=mQ;cs.DEFAULT_ANISOTROPY=1;class cr{constructor(e=0,n=0,r=0,i=1){cr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],g=c[1],p=c[5],x=c[9],y=c[2],b=c[6],v=c[10];if(Math.abs(d-g)<.01&&Math.abs(f-y)<.01&&Math.abs(x-b)<.01){if(Math.abs(d+g)<.1&&Math.abs(f+y)<.1&&Math.abs(x+b)<.1&&Math.abs(u+p+v-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(p+1)/2,N=(v+1)/2,C=(d+g)/4,T=(f+y)/4,O=(x+b)/4;return w>A&&w>N?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=T/r):A>N?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=O/i):N<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(N),r=T/a,i=O/a),this.set(r,i,a,n),this}let E=Math.sqrt((b-x)*(b-x)+(f-y)*(f-y)+(g-d)*(g-d));return Math.abs(E)<.001&&(E=1),this.x=(b-x)/E,this.y=(f-y)/E,this.z=(g-d)/E,this.w=Math.acos((u+p+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class U4e extends Of{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new cr(0,0,e,n),this.scissorTest=!1,this.viewport=new cr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(b0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Zh?la:lo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:so,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new cs(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps,this.texture.internalFormat=r.internalFormat,this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}setSize(e,n,r=1){(this.width!==e||this.height!==n||this.depth!==r)&&(this.width=e,this.height=n,this.depth=r,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new TQ(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 Mf extends U4e{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class CQ extends cs{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=oa,this.minFilter=oa,this.wrapR=Io,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class z4e extends cs{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=oa,this.minFilter=oa,this.wrapR=Io,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ef{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const g=a[o+0],p=a[o+1],x=a[o+2],y=a[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=g,e[n+1]=p,e[n+2]=x,e[n+3]=y;return}if(f!==y||c!==g||u!==p||d!==x){let b=1-l;const v=c*g+u*p+d*x+f*y,E=v>=0?1:-1,w=1-v*v;if(w>Number.EPSILON){const N=Math.sqrt(w),C=Math.atan2(N,v*E);b=Math.sin(b*C)/N,l=Math.sin(l*C)/N}const A=l*E;if(c=c*b+g*A,u=u*b+p*A,d=d*b+x*A,f=f*b+y*A,b===1-l){const N=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=N,u*=N,d*=N,f*=N}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],g=a[o+1],p=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*p-u*g,e[n+1]=c*x+d*g+u*f-l*p,e[n+2]=u*x+d*p+l*g-c*f,e[n+3]=d*x-l*f-c*g-u*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),g=c(r/2),p=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"YXZ":this._x=g*d*f+u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"ZXY":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f-g*p*x;break;case"ZYX":this._x=g*d*f-u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f+g*p*x;break;case"YZX":this._x=g*d*f+u*p*x,this._y=u*p*f+g*d*x,this._z=u*d*x-g*p*f,this._w=u*d*f-g*p*x;break;case"XZY":this._x=g*d*f-u*p*x,this._y=u*p*f-g*d*x,this._z=u*d*x+g*p*f,this._w=u*d*f+g*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],g=r+l+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(d-c)*p,this._y=(a-u)*p,this._z=(o-i)*p}else if(r>l&&r>f){const p=2*Math.sqrt(1+r-l-f);this._w=(d-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(a+u)/p}else if(l>f){const p=2*Math.sqrt(1+l-r-f);this._w=(a-u)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+d)/p}else{const p=2*Math.sqrt(1+f-r-l);this._w=(o-i)/p,this._x=(a+u)/p,this._y=(c+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ca(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=a,this;const c=1-l*l;if(c<=Number.EPSILON){const p=1-n;return this._w=p*o+n*this._w,this._x=p*r+n*this._x,this._y=p*i+n*this._y,this._z=p*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,g=Math.sin(n*d)/u;return this._w=o*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=a*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Le{constructor(e=0,n=0,r=0){Le.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(mV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(mV.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return RC.copy(this).projectOnVector(e),this.sub(RC)}reflect(e){return this.sub(RC.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(ca(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const RC=new Le,mV=new Ef;class po{constructor(e=new Le(1/0,1/0,1/0),n=new Le(-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(),N_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),N_.copy(r.boundingBox)),N_.applyMatrix4(e.matrixWorld),this.union(N_)}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($x),A_.subVectors(this.max,$x),Fm.subVectors(e.a,$x),Um.subVectors(e.b,$x),zm.subVectors(e.c,$x),Iu.subVectors(Um,Fm),Fu.subVectors(zm,Um),gh.subVectors(Fm,zm);let n=[0,-Iu.z,Iu.y,0,-Fu.z,Fu.y,0,-gh.z,gh.y,Iu.z,0,-Iu.x,Fu.z,0,-Fu.x,gh.z,0,-gh.x,-Iu.y,Iu.x,0,-Fu.y,Fu.x,0,-gh.y,gh.x,0];return!DC(n,Fm,Um,zm,A_)||(n=[1,0,0,0,1,0,0,0,1],!DC(n,Fm,Um,zm,A_))?!1:(T_.crossVectors(Iu,Fu),n=[T_.x,T_.y,T_.z],DC(n,Fm,Um,zm,A_))}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:(uc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),uc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),uc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),uc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),uc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),uc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),uc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),uc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(uc),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const uc=[new Le,new Le,new Le,new Le,new Le,new Le,new Le,new Le],ko=new Le,N_=new po,Fm=new Le,Um=new Le,zm=new Le,Iu=new Le,Fu=new Le,gh=new Le,$x=new Le,A_=new Le,T_=new Le,xh=new Le;function DC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){xh.fromArray(t,a);const l=i.x*Math.abs(xh.x)+i.y*Math.abs(xh.y)+i.z*Math.abs(xh.z),c=e.dot(xh),u=n.dot(xh),d=r.dot(xh);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const B4e=new po,Vx=new Le,OC=new Le;class wl{constructor(e=new Le,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):B4e.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;Vx.subVectors(e,this.center);const n=Vx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Vx,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):(OC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Vx.copy(e.center).add(OC)),this.expandByPoint(Vx.copy(e.center).sub(OC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const dc=new Le,LC=new Le,C_=new Le,Uu=new Le,IC=new Le,k_=new Le,FC=new Le;class ZO{constructor(e=new Le,n=new Le(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,dc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=dc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(dc.copy(this.origin).addScaledVector(this.direction,n),dc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){LC.copy(e).add(n).multiplyScalar(.5),C_.copy(n).sub(e).normalize(),Uu.copy(this.origin).sub(LC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(C_),l=Uu.dot(this.direction),c=-Uu.dot(C_),u=Uu.lengthSq(),d=Math.abs(1-o*o);let f,g,p,x;if(d>0)if(f=o*c-l,g=o*l-c,x=a*d,f>=0)if(g>=-x)if(g<=x){const y=1/d;f*=y,g*=y,p=f*(f+o*g+2*l)+g*(o*f+g+2*c)+u}else g=a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g=-a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;else g<=-x?(f=Math.max(0,-(-o*a+l)),g=f>0?-a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u):g<=x?(f=0,g=Math.min(Math.max(-a,-c),a),p=g*(g+2*c)+u):(f=Math.max(0,-(o*a+l)),g=f>0?a:Math.min(Math.max(-a,-c),a),p=-f*f+g*(g+2*c)+u);else g=o>0?-a:a,f=Math.max(0,-(o*g+l)),p=-f*f+g*(g+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(LC).addScaledVector(C_,g),p}intersectSphere(e,n){dc.subVectors(e.center,this.origin);const r=dc.dot(this.direction),i=dc.dot(dc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,g=this.origin;return u>=0?(r=(e.min.x-g.x)*u,i=(e.max.x-g.x)*u):(r=(e.max.x-g.x)*u,i=(e.min.x-g.x)*u),d>=0?(a=(e.min.y-g.y)*d,o=(e.max.y-g.y)*d):(a=(e.max.y-g.y)*d,o=(e.min.y-g.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-g.z)*f,c=(e.max.z-g.z)*f):(l=(e.max.z-g.z)*f,c=(e.min.z-g.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,dc)!==null}intersectTriangle(e,n,r,i,a){IC.subVectors(n,e),k_.subVectors(r,e),FC.crossVectors(IC,k_);let o=this.direction.dot(FC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Uu.subVectors(this.origin,e);const c=l*this.direction.dot(k_.crossVectors(Uu,k_));if(c<0)return null;const u=l*this.direction.dot(IC.cross(Uu));if(u<0||c+u>o)return null;const d=-l*Uu.dot(FC);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 yr{constructor(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){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,g,p,x,y,b)}set(e,n,r,i,a,o,l,c,u,d,f,g,p,x,y,b){const v=this.elements;return v[0]=e,v[4]=n,v[8]=r,v[12]=i,v[1]=a,v[5]=o,v[9]=l,v[13]=c,v[2]=u,v[6]=d,v[10]=f,v[14]=g,v[3]=p,v[7]=x,v[11]=y,v[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new 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 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/Bm.setFromMatrixColumn(e,0).length(),a=1/Bm.setFromMatrixColumn(e,1).length(),o=1/Bm.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const g=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=p+x*u,n[5]=g-y*u,n[9]=-l*c,n[2]=y-g*u,n[6]=x+p*u,n[10]=o*c}else if(e.order==="YXZ"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g+y*l,n[4]=x*l-p,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=p*l-x,n[6]=y+g*l,n[10]=o*c}else if(e.order==="ZXY"){const g=c*d,p=c*f,x=u*d,y=u*f;n[0]=g-y*l,n[4]=-o*f,n[8]=x+p*l,n[1]=p+x*l,n[5]=o*d,n[9]=y-g*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const g=o*d,p=o*f,x=l*d,y=l*f;n[0]=c*d,n[4]=x*u-p,n[8]=g*u+y,n[1]=c*f,n[5]=y*u+g,n[9]=p*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-g*f,n[8]=x*f+p,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=p*f+x,n[10]=g-y*f}else if(e.order==="XZY"){const g=o*c,p=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=g*f+y,n[5]=o*d,n[9]=p*f-x,n[2]=x*f-p,n[6]=l*d,n[10]=y*f+g}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(H4e,e,$4e)}lookAt(e,n,r){const i=this.elements;return Es.subVectors(e,n),Es.lengthSq()===0&&(Es.z=1),Es.normalize(),zu.crossVectors(r,Es),zu.lengthSq()===0&&(Math.abs(r.z)===1?Es.x+=1e-4:Es.z+=1e-4,Es.normalize(),zu.crossVectors(r,Es)),zu.normalize(),j_.crossVectors(Es,zu),i[0]=zu.x,i[4]=j_.x,i[8]=Es.x,i[1]=zu.y,i[5]=j_.y,i[9]=Es.y,i[2]=zu.z,i[6]=j_.z,i[10]=Es.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],g=r[9],p=r[13],x=r[2],y=r[6],b=r[10],v=r[14],E=r[3],w=r[7],A=r[11],N=r[15],C=i[0],T=i[4],O=i[8],k=i[12],R=i[1],z=i[5],D=i[9],K=i[13],P=i[2],W=i[6],Z=i[10],G=i[14],Y=i[3],X=i[7],q=i[11],F=i[15];return a[0]=o*C+l*R+c*P+u*Y,a[4]=o*T+l*z+c*W+u*X,a[8]=o*O+l*D+c*Z+u*q,a[12]=o*k+l*K+c*G+u*F,a[1]=d*C+f*R+g*P+p*Y,a[5]=d*T+f*z+g*W+p*X,a[9]=d*O+f*D+g*Z+p*q,a[13]=d*k+f*K+g*G+p*F,a[2]=x*C+y*R+b*P+v*Y,a[6]=x*T+y*z+b*W+v*X,a[10]=x*O+y*D+b*Z+v*q,a[14]=x*k+y*K+b*G+v*F,a[3]=E*C+w*R+A*P+N*Y,a[7]=E*T+w*z+A*W+N*X,a[11]=E*O+w*D+A*Z+N*q,a[15]=E*k+w*K+A*G+N*F,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],g=e[10],p=e[14],x=e[3],y=e[7],b=e[11],v=e[15];return x*(+a*c*f-i*u*f-a*l*g+r*u*g+i*l*p-r*c*p)+y*(+n*c*p-n*u*g+a*o*g-i*o*p+i*u*d-a*c*d)+b*(+n*u*f-n*l*p-a*o*f+r*o*p+a*l*d-r*u*d)+v*(-i*l*d-n*c*f+n*l*g+i*o*f-r*o*g+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],p=e[11],x=e[12],y=e[13],b=e[14],v=e[15],E=f*b*u-y*g*u+y*c*p-l*b*p-f*c*v+l*g*v,w=x*g*u-d*b*u-x*c*p+o*b*p+d*c*v-o*g*v,A=d*y*u-x*f*u+x*l*p-o*y*p-d*l*v+o*f*v,N=x*f*c-d*y*c-x*l*g+o*y*g+d*l*b-o*f*b,C=n*E+r*w+i*A+a*N;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/C;return e[0]=E*T,e[1]=(y*g*a-f*b*a-y*i*p+r*b*p+f*i*v-r*g*v)*T,e[2]=(l*b*a-y*c*a+y*i*u-r*b*u-l*i*v+r*c*v)*T,e[3]=(f*c*a-l*g*a-f*i*u+r*g*u+l*i*p-r*c*p)*T,e[4]=w*T,e[5]=(d*b*a-x*g*a+x*i*p-n*b*p-d*i*v+n*g*v)*T,e[6]=(x*c*a-o*b*a-x*i*u+n*b*u+o*i*v-n*c*v)*T,e[7]=(o*g*a-d*c*a+d*i*u-n*g*u-o*i*p+n*c*p)*T,e[8]=A*T,e[9]=(x*f*a-d*y*a-x*r*p+n*y*p+d*r*v-n*f*v)*T,e[10]=(o*y*a-x*l*a+x*r*u-n*y*u-o*r*v+n*l*v)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*p-n*l*p)*T,e[12]=N*T,e[13]=(d*y*i-x*f*i+x*r*g-n*y*g-d*r*b+n*f*b)*T,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*b-n*l*b)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*g+n*l*g)*T,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,g=a*u,p=a*d,x=a*f,y=o*d,b=o*f,v=l*f,E=c*u,w=c*d,A=c*f,N=r.x,C=r.y,T=r.z;return i[0]=(1-(y+v))*N,i[1]=(p+A)*N,i[2]=(x-w)*N,i[3]=0,i[4]=(p-A)*C,i[5]=(1-(g+v))*C,i[6]=(b+E)*C,i[7]=0,i[8]=(x+w)*T,i[9]=(b-E)*T,i[10]=(1-(g+y))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Bm.set(i[0],i[1],i[2]).length();const o=Bm.set(i[4],i[5],i[6]).length(),l=Bm.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],jo.copy(this);const u=1/a,d=1/o,f=1/l;return jo.elements[0]*=u,jo.elements[1]*=u,jo.elements[2]*=u,jo.elements[4]*=d,jo.elements[5]*=d,jo.elements[6]*=d,jo.elements[8]*=f,jo.elements[9]*=f,jo.elements[10]*=f,n.setFromRotationMatrix(jo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=yl){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),g=(r+i)/(r-i);let p,x;if(l===yl)p=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===mb)p=-o/(o-a),x=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=yl){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),g=(n+e)*u,p=(r+i)*d;let x,y;if(l===yl)x=(o+a)*f,y=-2*f;else if(l===mb)x=a*f,y=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-g,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=y,c[14]=-x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const Bm=new Le,jo=new yr,H4e=new Le(0,0,0),$4e=new Le(1,1,1),zu=new Le,j_=new Le,Es=new Le,pV=new yr,gV=new Ef;class fy{constructor(e=0,n=0,r=0,i=fy.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],g=i[6],p=i[10];switch(n){case"XYZ":this._y=Math.asin(ca(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(g,u),this._z=0);break;case"YXZ":this._x=Math.asin(-ca(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,p),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(ca(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-ca(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(ca(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,p));break;case"XZY":this._z=Math.asin(-ca(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return pV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(pV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return gV.setFromEuler(this),this.setFromQuaternion(gV,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fy.DEFAULT_ORDER="XYZ";class kQ{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 V4e=0;const xV=new Le,Hm=new Ef,hc=new yr,P_=new Le,Gx=new Le,G4e=new Le,W4e=new Ef,bV=new Le(1,0,0),yV=new Le(0,1,0),vV=new Le(0,0,1),q4e={type:"added"},K4e={type:"removed"};class Ua extends Of{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:V4e++}),this.uuid=zc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ua.DEFAULT_UP.clone();const e=new Le,n=new fy,r=new Ef,i=new Le(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 yr},normalMatrix:{value:new wn}}),this.matrix=new yr,this.matrixWorld=new yr,this.matrixAutoUpdate=Ua.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ua.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new kQ,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 Hm.setFromAxisAngle(e,n),this.quaternion.multiply(Hm),this}rotateOnWorldAxis(e,n){return Hm.setFromAxisAngle(e,n),this.quaternion.premultiply(Hm),this}rotateX(e){return this.rotateOnAxis(bV,e)}rotateY(e){return this.rotateOnAxis(yV,e)}rotateZ(e){return this.rotateOnAxis(vV,e)}translateOnAxis(e,n){return xV.copy(e).applyQuaternion(this.quaternion),this.position.add(xV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(bV,e)}translateY(e){return this.translateOnAxis(yV,e)}translateZ(e){return this.translateOnAxis(vV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(hc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?P_.copy(e):P_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Gx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?hc.lookAt(Gx,P_,this.up):hc.lookAt(P_,Gx,this.up),this.quaternion.setFromRotationMatrix(hc),i&&(hc.extractRotation(i.matrixWorld),Hm.setFromRotationMatrix(hc),this.quaternion.premultiply(Hm.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(q4e)):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(K4e)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),hc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),hc.multiply(e.parent.matrixWorld)),e.applyMatrix4(hc),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gx,e,G4e),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gx,W4e,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++){const l=i[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),g=o(e.skeletons),p=o(e.animations),x=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),x.length>0&&(r.nodes=x)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}Ua.DEFAULT_UP=new Le(0,1,0);Ua.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ua.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Po=new Le,fc=new Le,UC=new Le,mc=new Le,$m=new Le,Vm=new Le,_V=new Le,zC=new Le,BC=new Le,HC=new Le;let R_=!1;class Ro{constructor(e=new Le,n=new Le,r=new Le){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Po.subVectors(e,n),i.cross(Po);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){Po.subVectors(i,n),fc.subVectors(r,n),UC.subVectors(e,n);const o=Po.dot(Po),l=Po.dot(fc),c=Po.dot(UC),u=fc.dot(fc),d=fc.dot(UC),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const g=1/f,p=(u*c-l*d)*g,x=(o*d-l*c)*g;return a.set(1-p-x,x,p)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,mc),mc.x>=0&&mc.y>=0&&mc.x+mc.y<=1}static getUV(e,n,r,i,a,o,l,c){return R_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),R_=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,mc),c.setScalar(0),c.addScaledVector(a,mc.x),c.addScaledVector(o,mc.y),c.addScaledVector(l,mc.z),c}static isFrontFacing(e,n,r,i){return Po.subVectors(r,n),fc.subVectors(e,n),Po.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 Po.subVectors(this.c,this.b),fc.subVectors(this.a,this.b),Po.cross(fc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Ro.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Ro.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return R_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),R_=!0),Ro.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Ro.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Ro.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Ro.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;$m.subVectors(i,r),Vm.subVectors(a,r),zC.subVectors(e,r);const c=$m.dot(zC),u=Vm.dot(zC);if(c<=0&&u<=0)return n.copy(r);BC.subVectors(e,i);const d=$m.dot(BC),f=Vm.dot(BC);if(d>=0&&f<=d)return n.copy(i);const g=c*f-d*u;if(g<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector($m,o);HC.subVectors(e,a);const p=$m.dot(HC),x=Vm.dot(HC);if(x>=0&&p<=x)return n.copy(a);const y=p*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Vm,l);const b=d*x-p*f;if(b<=0&&f-d>=0&&p-x>=0)return _V.subVectors(a,i),l=(f-d)/(f-d+(p-x)),n.copy(i).addScaledVector(_V,l);const v=1/(b+y+g);return o=y*v,l=g*v,n.copy(r).addScaledVector($m,o).addScaledVector(Vm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const jQ={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},Bu={h:0,s:0,l:0},D_={h:0,s:0,l:0};function $C(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 Xt=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=la){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,or.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=or.workingColorSpace){return this.r=e,this.g=n,this.b=r,or.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=or.workingColorSpace){if(e=YO(e,1),n=ca(n,0,1),r=ca(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=$C(o,a,e+1/3),this.g=$C(o,a,e),this.b=$C(o,a,e-1/3)}return or.toWorkingColorSpace(this,i),this}setStyle(e,n=la){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=la){const r=jQ[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=Ep(e.r),this.g=Ep(e.g),this.b=Ep(e.b),this}copyLinearToSRGB(e){return this.r=jC(e.r),this.g=jC(e.g),this.b=jC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=la){return or.fromWorkingColorSpace(ba.copy(this),e),Math.round(ca(ba.r*255,0,255))*65536+Math.round(ca(ba.g*255,0,255))*256+Math.round(ca(ba.b*255,0,255))}getHexString(e=la){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=or.workingColorSpace){or.fromWorkingColorSpace(ba.copy(this),n);const r=ba.r,i=ba.g,a=ba.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=or.workingColorSpace){return or.fromWorkingColorSpace(ba.copy(this),n),e.r=ba.r,e.g=ba.g,e.b=ba.b,e}getStyle(e=la){or.fromWorkingColorSpace(ba.copy(this),e);const n=ba.r,r=ba.g,i=ba.b;return e!==la?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(Bu),this.setHSL(Bu.h+e,Bu.s+n,Bu.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(Bu),e.getHSL(D_);const r=x0(Bu.h,D_.h,n),i=x0(Bu.s,D_.s,n),a=x0(Bu.l,D_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const ba=new Xt;Xt.NAMES=jQ;let X4e=0;class Cg extends Of{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:X4e++}),this.uuid=zc(),this.name="",this.type="Material",this.blending=Mp,this.side=Od,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=oP,this.blendDst=lP,this.blendEquation=Ch,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Xt(0,0,0),this.blendAlpha=0,this.depthFunc=aS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lm,this.stencilZFail=Lm,this.stencilZPass=Lm,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!==Mp&&(r.blending=this.blending),this.side!==Od&&(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!==oP&&(r.blendSrc=this.blendSrc),this.blendDst!==lP&&(r.blendDst=this.blendDst),this.blendEquation!==Ch&&(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!==aS&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==lV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Lm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Lm&&(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 PQ extends Cg{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Xt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=qO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const li=new Le,O_=new an;class Os{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=fP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Rc,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)O_.fromBufferAttribute(this,n),O_.applyMatrix3(e),this.setXY(n,O_.x,O_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.applyMatrix3(e),this.setXYZ(n,li.x,li.y,li.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.applyMatrix4(e),this.setXYZ(n,li.x,li.y,li.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.applyNormalMatrix(e),this.setXYZ(n,li.x,li.y,li.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)li.fromBufferAttribute(this,n),li.transformDirection(e),this.setXYZ(n,li.x,li.y,li.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=pl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=sr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=pl(n,this.array)),n}setX(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=pl(n,this.array)),n}setY(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=pl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=pl(n,this.array)),n}setW(e,n){return this.normalized&&(n=sr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=sr(n,this.array),r=sr(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=sr(n,this.array),r=sr(r,this.array),i=sr(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=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array),a=sr(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!==fP&&(e.usage=this.usage),e}}class RQ extends Os{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class DQ extends Os{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class ni extends Os{constructor(e,n,r){super(new Float32Array(e),n,r)}}let Y4e=0;const Ys=new yr,VC=new Ua,Gm=new Le,Ns=new po,Wx=new po,zi=new Le;class Ca extends Of{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Y4e++}),this.uuid=zc(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(NQ(e)?DQ:RQ)(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 wn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ys.makeRotationFromQuaternion(e),this.applyMatrix4(Ys),this}rotateX(e){return Ys.makeRotationX(e),this.applyMatrix4(Ys),this}rotateY(e){return Ys.makeRotationY(e),this.applyMatrix4(Ys),this}rotateZ(e){return Ys.makeRotationZ(e),this.applyMatrix4(Ys),this}translate(e,n,r){return Ys.makeTranslation(e,n,r),this.applyMatrix4(Ys),this}scale(e,n,r){return Ys.makeScale(e,n,r),this.applyMatrix4(Ys),this}lookAt(e){return VC.lookAt(e),VC.updateMatrix(),this.applyMatrix4(VC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gm).negate(),this.translate(Gm.x,Gm.y,Gm.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new ni(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new po);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 Le(-1/0,-1/0,-1/0),new Le(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];Ns.setFromBufferAttribute(a),this.morphTargetsRelative?(zi.addVectors(this.boundingBox.min,Ns.min),this.boundingBox.expandByPoint(zi),zi.addVectors(this.boundingBox.max,Ns.max),this.boundingBox.expandByPoint(zi)):(this.boundingBox.expandByPoint(Ns.min),this.boundingBox.expandByPoint(Ns.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new wl);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Le,1/0);return}if(e){const r=this.boundingSphere.center;if(Ns.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Wx.setFromBufferAttribute(l),this.morphTargetsRelative?(zi.addVectors(Ns.min,Wx.min),Ns.expandByPoint(zi),zi.addVectors(Ns.max,Wx.max),Ns.expandByPoint(zi)):(Ns.expandByPoint(Wx.min),Ns.expandByPoint(Wx.max))}Ns.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)zi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(zi));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)zi.fromBufferAttribute(l,u),c&&(Gm.fromBufferAttribute(e,u),zi.add(Gm)),i=Math.max(i,r.distanceToSquared(zi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Os(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let R=0;R<l;R++)u[R]=new Le,d[R]=new Le;const f=new Le,g=new Le,p=new Le,x=new an,y=new an,b=new an,v=new Le,E=new Le;function w(R,z,D){f.fromArray(i,R*3),g.fromArray(i,z*3),p.fromArray(i,D*3),x.fromArray(o,R*2),y.fromArray(o,z*2),b.fromArray(o,D*2),g.sub(f),p.sub(f),y.sub(x),b.sub(x);const K=1/(y.x*b.y-b.x*y.y);isFinite(K)&&(v.copy(g).multiplyScalar(b.y).addScaledVector(p,-y.y).multiplyScalar(K),E.copy(p).multiplyScalar(y.x).addScaledVector(g,-b.x).multiplyScalar(K),u[R].add(v),u[z].add(v),u[D].add(v),d[R].add(E),d[z].add(E),d[D].add(E))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let R=0,z=A.length;R<z;++R){const D=A[R],K=D.start,P=D.count;for(let W=K,Z=K+P;W<Z;W+=3)w(r[W+0],r[W+1],r[W+2])}const N=new Le,C=new Le,T=new Le,O=new Le;function k(R){T.fromArray(a,R*3),O.copy(T);const z=u[R];N.copy(z),N.sub(T.multiplyScalar(T.dot(z))).normalize(),C.crossVectors(O,z);const K=C.dot(d[R])<0?-1:1;c[R*4]=N.x,c[R*4+1]=N.y,c[R*4+2]=N.z,c[R*4+3]=K}for(let R=0,z=A.length;R<z;++R){const D=A[R],K=D.start,P=D.count;for(let W=K,Z=K+P;W<Z;W+=3)k(r[W+0]),k(r[W+1]),k(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 Os(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new Le,a=new Le,o=new Le,l=new Le,c=new Le,u=new Le,d=new Le,f=new Le;if(e)for(let g=0,p=e.count;g<p;g+=3){const x=e.getX(g+0),y=e.getX(g+1),b=e.getX(g+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,y),o.fromBufferAttribute(n,b),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,b),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(y,c.x,c.y,c.z),r.setXYZ(b,u.x,u.y,u.z)}else for(let g=0,p=n.count;g<p;g+=3)i.fromBufferAttribute(n,g+0),a.fromBufferAttribute(n,g+1),o.fromBufferAttribute(n,g+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(g+0,d.x,d.y,d.z),r.setXYZ(g+1,d.x,d.y,d.z),r.setXYZ(g+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)zi.fromBufferAttribute(e,n),zi.normalize(),e.setXYZ(n,zi.x,zi.y,zi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,g=new u.constructor(c.length*d);let p=0,x=0;for(let y=0,b=c.length;y<b;y++){l.isInterleavedBufferAttribute?p=c[y]*l.data.stride+l.offset:p=c[y]*d;for(let v=0;v<d;v++)g[x++]=u[p++]}return new Os(g,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new Ca,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const g=u[d],p=e(g,r);c.push(p)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,g=u.length;f<g;f++){const p=u[f];d.push(p.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let g=0,p=f.length;g<p;g++)d.push(f[g].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const wV=new yr,bh=new ZO,L_=new wl,SV=new Le,Wm=new Le,qm=new Le,Km=new Le,GC=new Le,I_=new Le,F_=new an,U_=new an,z_=new an,MV=new Le,EV=new Le,NV=new Le,B_=new Le,H_=new Le;class zo extends Ua{constructor(e=new Ca,n=new PQ){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){I_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(GC.fromBufferAttribute(f,e),o?I_.addScaledVector(GC,d):I_.addScaledVector(GC.sub(n),d))}n.add(I_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),L_.copy(r.boundingSphere),L_.applyMatrix4(a),bh.copy(e.ray).recast(e.near),!(L_.containsPoint(bh.origin)===!1&&(bh.intersectSphere(L_,SV)===null||bh.origin.distanceToSquared(SV)>(e.far-e.near)**2))&&(wV.copy(a).invert(),bh.copy(e.ray).applyMatrix4(wV),!(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,g=a.groups,p=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(l.count,Math.min(b.start+b.count,p.start+p.count));for(let A=E,N=w;A<N;A+=3){const C=l.getX(A),T=l.getX(A+1),O=l.getX(A+2);i=$_(this,v,e,r,u,d,f,C,T,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(l.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=l.getX(b),w=l.getX(b+1),A=l.getX(b+2);i=$_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=g.length;x<y;x++){const b=g[x],v=o[b.materialIndex],E=Math.max(b.start,p.start),w=Math.min(c.count,Math.min(b.start+b.count,p.start+p.count));for(let A=E,N=w;A<N;A+=3){const C=A,T=A+1,O=A+2;i=$_(this,v,e,r,u,d,f,C,T,O),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=b.materialIndex,n.push(i))}}else{const x=Math.max(0,p.start),y=Math.min(c.count,p.start+p.count);for(let b=x,v=y;b<v;b+=3){const E=b,w=b+1,A=b+2;i=$_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(b/3),n.push(i))}}}}function Z4e(t,e,n,r,i,a,o,l){let c;if(e.side===ls?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Od,l),c===null)return null;H_.copy(l),H_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(H_);return u<n.near||u>n.far?null:{distance:u,point:H_.clone(),object:t}}function $_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,Wm),t.getVertexPosition(c,qm),t.getVertexPosition(u,Km);const d=Z4e(t,e,n,r,Wm,qm,Km,B_);if(d){i&&(F_.fromBufferAttribute(i,l),U_.fromBufferAttribute(i,c),z_.fromBufferAttribute(i,u),d.uv=Ro.getInterpolation(B_,Wm,qm,Km,F_,U_,z_,new an)),a&&(F_.fromBufferAttribute(a,l),U_.fromBufferAttribute(a,c),z_.fromBufferAttribute(a,u),d.uv1=Ro.getInterpolation(B_,Wm,qm,Km,F_,U_,z_,new an),d.uv2=d.uv1),o&&(MV.fromBufferAttribute(o,l),EV.fromBufferAttribute(o,c),NV.fromBufferAttribute(o,u),d.normal=Ro.getInterpolation(B_,Wm,qm,Km,MV,EV,NV,new Le),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new Le,materialIndex:0};Ro.getNormal(Wm,qm,Km,f.normal),d.face=f}return d}class my extends Ca{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let g=0,p=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,1),x("x","z","y",1,1,e,r,n,i,o,2),x("x","z","y",1,-1,e,r,-n,i,o,3),x("x","y","z",1,-1,e,n,r,i,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new ni(u,3)),this.setAttribute("normal",new ni(d,3)),this.setAttribute("uv",new ni(f,2));function x(y,b,v,E,w,A,N,C,T,O,k){const R=A/T,z=N/O,D=A/2,K=N/2,P=C/2,W=T+1,Z=O+1;let G=0,Y=0;const X=new Le;for(let q=0;q<Z;q++){const F=q*z-K;for(let V=0;V<W;V++){const te=V*R-D;X[y]=te*E,X[b]=F*w,X[v]=P,u.push(X.x,X.y,X.z),X[y]=0,X[b]=0,X[v]=C>0?1:-1,d.push(X.x,X.y,X.z),f.push(V/T),f.push(1-q/O),G+=1}}for(let q=0;q<O;q++)for(let F=0;F<T;F++){const V=g+F+W*q,te=g+F+W*(q+1),re=g+(F+1)+W*(q+1),ae=g+(F+1)+W*q;c.push(V,te,ae),c.push(te,re,ae),Y+=6}l.addGroup(p,Y,k),p+=Y,g+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new my(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Jp(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 Da(t){const e={};for(let n=0;n<t.length;n++){const r=Jp(t[n]);for(const i in r)e[i]=r[i]}return e}function Q4e(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function OQ(t){return t.getRenderTarget()===null?t.outputColorSpace:or.workingColorSpace}const QO={clone:Jp,merge:Da};var J4e=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,eLe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Ld extends Cg{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=J4e,this.fragmentShader=eLe,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=Jp(e.uniforms),this.uniformsGroups=Q4e(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 LQ extends Ua{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yr,this.projectionMatrix=new yr,this.projectionMatrixInverse=new yr,this.coordinateSystem=yl}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Ts extends LQ{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=pb*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(g0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return pb*2*Math.atan(Math.tan(g0*.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(g0*.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 Xm=-90,Ym=1;class tLe extends Ua{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ts(Xm,Ym,e,n);i.layers=this.layers,this.add(i);const a=new Ts(Xm,Ym,e,n);a.layers=this.layers,this.add(a);const o=new Ts(Xm,Ym,e,n);o.layers=this.layers,this.add(o);const l=new Ts(Xm,Ym,e,n);l.layers=this.layers,this.add(l);const c=new Ts(Xm,Ym,e,n);c.layers=this.layers,this.add(c);const u=new Ts(Xm,Ym,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===yl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===mb)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),g=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=y,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,g,p),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class IQ extends cs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Yp,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 nLe extends Mf{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&&(b0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Zh?la:lo),this.texture=new IQ(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:so}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- 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 my(5,5,5),a=new Ld({name:"CubemapFromEquirect",uniforms:Jp(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ls,blending:gd});a.uniforms.tEquirect.value=n;const o=new zo(i,a),l=n.minFilter;return n.minFilter===hb&&(n.minFilter=so),new tLe(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 WC=new Le,rLe=new Le,iLe=new wn;class Yu{constructor(e=new Le(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=WC.subVectors(r,n).cross(rLe.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(WC),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||iLe.getNormalMatrix(e),i=this.coplanarPoint(WC).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 yh=new wl,V_=new Le;class b2{constructor(e=new Yu,n=new Yu,r=new Yu,i=new Yu,a=new Yu,o=new Yu){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=yl){const r=this.planes,i=e.elements,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],g=i[7],p=i[8],x=i[9],y=i[10],b=i[11],v=i[12],E=i[13],w=i[14],A=i[15];if(r[0].setComponents(c-a,g-u,b-p,A-v).normalize(),r[1].setComponents(c+a,g+u,b+p,A+v).normalize(),r[2].setComponents(c+o,g+d,b+x,A+E).normalize(),r[3].setComponents(c-o,g-d,b-x,A-E).normalize(),r[4].setComponents(c-l,g-f,b-y,A-w).normalize(),n===yl)r[5].setComponents(c+l,g+f,b+y,A+w).normalize();else if(n===mb)r[5].setComponents(l,f,y,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),yh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),yh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(yh)}intersectsSprite(e){return yh.center.set(0,0,0),yh.radius=.7071067811865476,yh.applyMatrix4(e.matrixWorld),this.intersectsSphere(yh)}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(V_.x=i.normal.x>0?e.max.x:e.min.x,V_.y=i.normal.y>0?e.max.y:e.min.y,V_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(V_)<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 FQ(){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 aLe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,g=u.usage,p=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,g),u.onUploadCallback();let y;if(f instanceof Float32Array)y=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)y=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else y=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)y=t.SHORT;else if(f instanceof Uint32Array)y=t.UNSIGNED_INT;else if(f instanceof Int32Array)y=t.INT;else if(f instanceof Int8Array)y=t.BYTE;else if(f instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:y,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:p}}function a(u,d,f){const g=d.array,p=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),p.count===-1&&x.length===0&&t.bufferSubData(f,0,g),x.length!==0){for(let y=0,b=x.length;y<b;y++){const v=x[y];n?t.bufferSubData(f,v.start*g.BYTES_PER_ELEMENT,g,v.start,v.count):t.bufferSubData(f,v.start*g.BYTES_PER_ELEMENT,g.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}p.count!==-1&&(n?t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g,p.offset,p.count):t.bufferSubData(f,p.offset*g.BYTES_PER_ELEMENT,g.subarray(p.offset,p.offset+p.count)),p.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const g=r.get(u);(!g||g.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:o,remove:l,update:c}}class JO extends Ca{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,g=n/c,p=[],x=[],y=[],b=[];for(let v=0;v<d;v++){const E=v*g-o;for(let w=0;w<u;w++){const A=w*f-a;x.push(A,-E,0),y.push(0,0,1),b.push(w/l),b.push(1-v/c)}}for(let v=0;v<c;v++)for(let E=0;E<l;E++){const w=E+u*v,A=E+u*(v+1),N=E+1+u*(v+1),C=E+1+u*v;p.push(w,A,C),p.push(A,N,C)}this.setIndex(p),this.setAttribute("position",new ni(x,3)),this.setAttribute("normal",new ni(y,3)),this.setAttribute("uv",new ni(b,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new JO(e.width,e.height,e.widthSegments,e.heightSegments)}}var sLe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,oLe=`#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`,lLe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,cLe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,uLe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,dLe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,hLe=`#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`,fLe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,mLe=`#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`,pLe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,gLe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,xLe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,bLe=`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`,yLe=`#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`,vLe=`#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`,_Le=`#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`,wLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,SLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,MLe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,ELe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,NLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,ALe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,TLe=`#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`,CLe=`#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`,kLe=`#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`,jLe=`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`,PLe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,RLe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,DLe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,OLe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,LLe="gl_FragColor = linearToOutputTexel( gl_FragColor );",ILe=`
- 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 );
- }`,FLe=`#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`,ULe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,zLe=`#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`,BLe=`#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`,HLe=`#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`,$Le=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,VLe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,GLe=`#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`,WLe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,qLe=`#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
- }`,KLe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,XLe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,YLe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,ZLe=`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`,QLe=`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`,JLe=`#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`,eIe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,tIe=`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`,nIe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,rIe=`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`,iIe=`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`,aIe=`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 );
- }`,sIe=`
- 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`,oIe=`#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`,lIe=`#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`,cIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,uIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,dIe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,hIe=`#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`,fIe=`#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`,mIe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,pIe=`#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`,gIe=`#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`,xIe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,bIe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,yIe=`#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`,vIe=`#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`,_Ie=`#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`,wIe=`#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`,SIe=`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;`,MIe=`#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`,EIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,NIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,AIe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,TIe=`#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`,CIe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,kIe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,jIe=`#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`,PIe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,RIe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,DIe=`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 );
- }`,OIe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,LIe=`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;`,IIe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,FIe=`#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`,UIe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,zIe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,BIe=`#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`,HIe=`#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`,$Ie=`#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`,VIe=`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;
- }`,GIe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,WIe=`#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`,qIe=`#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`,KIe=`#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`,XIe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,YIe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,ZIe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,QIe=`#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; }`,JIe=`#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`,e5e=`#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`,t5e=`#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`,n5e=`#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`,r5e=`#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`,i5e=`#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 a5e=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,s5e=`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>
- }`,o5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,l5e=`#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>
- }`,c5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,u5e=`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>
- }`,d5e=`#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;
- }`,h5e=`#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
- }`,f5e=`#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;
- }`,m5e=`#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 );
- }`,p5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,g5e=`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>
- }`,x5e=`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>
- }`,b5e=`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>
- }`,y5e=`#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>
- }`,v5e=`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>
- }`,_5e=`#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>
- }`,w5e=`#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>
- }`,S5e=`#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;
- }`,M5e=`#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>
- }`,E5e=`#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
- }`,N5e=`#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
- }`,A5e=`#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>
- }`,T5e=`#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>
- }`,C5e=`#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
- }`,k5e=`#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>
- }`,j5e=`#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>
- }`,P5e=`#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>
- }`,R5e=`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>
- }`,D5e=`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>
- }`,O5e=`#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>
- }`,L5e=`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>
- }`,I5e=`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>
- }`,F5e=`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>
- }`,gn={alphahash_fragment:sLe,alphahash_pars_fragment:oLe,alphamap_fragment:lLe,alphamap_pars_fragment:cLe,alphatest_fragment:uLe,alphatest_pars_fragment:dLe,aomap_fragment:hLe,aomap_pars_fragment:fLe,batching_pars_vertex:mLe,batching_vertex:pLe,begin_vertex:gLe,beginnormal_vertex:xLe,bsdfs:bLe,iridescence_fragment:yLe,bumpmap_pars_fragment:vLe,clipping_planes_fragment:_Le,clipping_planes_pars_fragment:wLe,clipping_planes_pars_vertex:SLe,clipping_planes_vertex:MLe,color_fragment:ELe,color_pars_fragment:NLe,color_pars_vertex:ALe,color_vertex:TLe,common:CLe,cube_uv_reflection_fragment:kLe,defaultnormal_vertex:jLe,displacementmap_pars_vertex:PLe,displacementmap_vertex:RLe,emissivemap_fragment:DLe,emissivemap_pars_fragment:OLe,colorspace_fragment:LLe,colorspace_pars_fragment:ILe,envmap_fragment:FLe,envmap_common_pars_fragment:ULe,envmap_pars_fragment:zLe,envmap_pars_vertex:BLe,envmap_physical_pars_fragment:JLe,envmap_vertex:HLe,fog_vertex:$Le,fog_pars_vertex:VLe,fog_fragment:GLe,fog_pars_fragment:WLe,gradientmap_pars_fragment:qLe,lightmap_fragment:KLe,lightmap_pars_fragment:XLe,lights_lambert_fragment:YLe,lights_lambert_pars_fragment:ZLe,lights_pars_begin:QLe,lights_toon_fragment:eIe,lights_toon_pars_fragment:tIe,lights_phong_fragment:nIe,lights_phong_pars_fragment:rIe,lights_physical_fragment:iIe,lights_physical_pars_fragment:aIe,lights_fragment_begin:sIe,lights_fragment_maps:oIe,lights_fragment_end:lIe,logdepthbuf_fragment:cIe,logdepthbuf_pars_fragment:uIe,logdepthbuf_pars_vertex:dIe,logdepthbuf_vertex:hIe,map_fragment:fIe,map_pars_fragment:mIe,map_particle_fragment:pIe,map_particle_pars_fragment:gIe,metalnessmap_fragment:xIe,metalnessmap_pars_fragment:bIe,morphcolor_vertex:yIe,morphnormal_vertex:vIe,morphtarget_pars_vertex:_Ie,morphtarget_vertex:wIe,normal_fragment_begin:SIe,normal_fragment_maps:MIe,normal_pars_fragment:EIe,normal_pars_vertex:NIe,normal_vertex:AIe,normalmap_pars_fragment:TIe,clearcoat_normal_fragment_begin:CIe,clearcoat_normal_fragment_maps:kIe,clearcoat_pars_fragment:jIe,iridescence_pars_fragment:PIe,opaque_fragment:RIe,packing:DIe,premultiplied_alpha_fragment:OIe,project_vertex:LIe,dithering_fragment:IIe,dithering_pars_fragment:FIe,roughnessmap_fragment:UIe,roughnessmap_pars_fragment:zIe,shadowmap_pars_fragment:BIe,shadowmap_pars_vertex:HIe,shadowmap_vertex:$Ie,shadowmask_pars_fragment:VIe,skinbase_vertex:GIe,skinning_pars_vertex:WIe,skinning_vertex:qIe,skinnormal_vertex:KIe,specularmap_fragment:XIe,specularmap_pars_fragment:YIe,tonemapping_fragment:ZIe,tonemapping_pars_fragment:QIe,transmission_fragment:JIe,transmission_pars_fragment:e5e,uv_pars_fragment:t5e,uv_pars_vertex:n5e,uv_vertex:r5e,worldpos_vertex:i5e,background_vert:a5e,background_frag:s5e,backgroundCube_vert:o5e,backgroundCube_frag:l5e,cube_vert:c5e,cube_frag:u5e,depth_vert:d5e,depth_frag:h5e,distanceRGBA_vert:f5e,distanceRGBA_frag:m5e,equirect_vert:p5e,equirect_frag:g5e,linedashed_vert:x5e,linedashed_frag:b5e,meshbasic_vert:y5e,meshbasic_frag:v5e,meshlambert_vert:_5e,meshlambert_frag:w5e,meshmatcap_vert:S5e,meshmatcap_frag:M5e,meshnormal_vert:E5e,meshnormal_frag:N5e,meshphong_vert:A5e,meshphong_frag:T5e,meshphysical_vert:C5e,meshphysical_frag:k5e,meshtoon_vert:j5e,meshtoon_frag:P5e,points_vert:R5e,points_frag:D5e,shadow_vert:O5e,shadow_frag:L5e,sprite_vert:I5e,sprite_frag:F5e},Ct={common:{diffuse:{value:new Xt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new wn},alphaMap:{value:null},alphaMapTransform:{value:new wn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new wn}},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 wn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new wn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new wn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new wn},normalScale:{value:new an(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new wn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new wn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new wn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new wn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Xt(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 Xt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new wn},alphaTest:{value:0},uvTransform:{value:new wn}},sprite:{diffuse:{value:new Xt(16777215)},opacity:{value:1},center:{value:new an(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new wn},alphaMap:{value:null},alphaMapTransform:{value:new wn},alphaTest:{value:0}}},ns={basic:{uniforms:Da([Ct.common,Ct.specularmap,Ct.envmap,Ct.aomap,Ct.lightmap,Ct.fog]),vertexShader:gn.meshbasic_vert,fragmentShader:gn.meshbasic_frag},lambert:{uniforms:Da([Ct.common,Ct.specularmap,Ct.envmap,Ct.aomap,Ct.lightmap,Ct.emissivemap,Ct.bumpmap,Ct.normalmap,Ct.displacementmap,Ct.fog,Ct.lights,{emissive:{value:new Xt(0)}}]),vertexShader:gn.meshlambert_vert,fragmentShader:gn.meshlambert_frag},phong:{uniforms:Da([Ct.common,Ct.specularmap,Ct.envmap,Ct.aomap,Ct.lightmap,Ct.emissivemap,Ct.bumpmap,Ct.normalmap,Ct.displacementmap,Ct.fog,Ct.lights,{emissive:{value:new Xt(0)},specular:{value:new Xt(1118481)},shininess:{value:30}}]),vertexShader:gn.meshphong_vert,fragmentShader:gn.meshphong_frag},standard:{uniforms:Da([Ct.common,Ct.envmap,Ct.aomap,Ct.lightmap,Ct.emissivemap,Ct.bumpmap,Ct.normalmap,Ct.displacementmap,Ct.roughnessmap,Ct.metalnessmap,Ct.fog,Ct.lights,{emissive:{value:new Xt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag},toon:{uniforms:Da([Ct.common,Ct.aomap,Ct.lightmap,Ct.emissivemap,Ct.bumpmap,Ct.normalmap,Ct.displacementmap,Ct.gradientmap,Ct.fog,Ct.lights,{emissive:{value:new Xt(0)}}]),vertexShader:gn.meshtoon_vert,fragmentShader:gn.meshtoon_frag},matcap:{uniforms:Da([Ct.common,Ct.bumpmap,Ct.normalmap,Ct.displacementmap,Ct.fog,{matcap:{value:null}}]),vertexShader:gn.meshmatcap_vert,fragmentShader:gn.meshmatcap_frag},points:{uniforms:Da([Ct.points,Ct.fog]),vertexShader:gn.points_vert,fragmentShader:gn.points_frag},dashed:{uniforms:Da([Ct.common,Ct.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gn.linedashed_vert,fragmentShader:gn.linedashed_frag},depth:{uniforms:Da([Ct.common,Ct.displacementmap]),vertexShader:gn.depth_vert,fragmentShader:gn.depth_frag},normal:{uniforms:Da([Ct.common,Ct.bumpmap,Ct.normalmap,Ct.displacementmap,{opacity:{value:1}}]),vertexShader:gn.meshnormal_vert,fragmentShader:gn.meshnormal_frag},sprite:{uniforms:Da([Ct.sprite,Ct.fog]),vertexShader:gn.sprite_vert,fragmentShader:gn.sprite_frag},background:{uniforms:{uvTransform:{value:new wn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:gn.background_vert,fragmentShader:gn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:gn.backgroundCube_vert,fragmentShader:gn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:gn.cube_vert,fragmentShader:gn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:gn.equirect_vert,fragmentShader:gn.equirect_frag},distanceRGBA:{uniforms:Da([Ct.common,Ct.displacementmap,{referencePosition:{value:new Le},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gn.distanceRGBA_vert,fragmentShader:gn.distanceRGBA_frag},shadow:{uniforms:Da([Ct.lights,Ct.fog,{color:{value:new Xt(0)},opacity:{value:1}}]),vertexShader:gn.shadow_vert,fragmentShader:gn.shadow_frag}};ns.physical={uniforms:Da([ns.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new wn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new wn},clearcoatNormalScale:{value:new an(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new wn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new wn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new wn},sheen:{value:0},sheenColor:{value:new Xt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new wn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new wn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new wn},transmissionSamplerSize:{value:new an},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new wn},attenuationDistance:{value:0},attenuationColor:{value:new Xt(0)},specularColor:{value:new Xt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new wn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new wn},anisotropyVector:{value:new an},anisotropyMap:{value:null},anisotropyMapTransform:{value:new wn}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag};const G_={r:0,b:0,g:0};function U5e(t,e,n,r,i,a,o){const l=new Xt(0);let c=a===!0?0:1,u,d,f=null,g=0,p=null;function x(b,v){let E=!1,w=v.isScene===!0?v.background:null;w&&w.isTexture&&(w=(v.backgroundBlurriness>0?n:e).get(w)),w===null?y(l,c):w&&w.isColor&&(y(w,1),E=!0);const 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||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===g2)?(d===void 0&&(d=new zo(new my(1,1,1),new Ld({name:"BackgroundCubeMaterial",uniforms:Jp(ns.backgroundCube.uniforms),vertexShader:ns.backgroundCube.vertexShader,fragmentShader:ns.backgroundCube.fragmentShader,side:ls,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(N,C,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=w,d.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=or.getTransfer(w.colorSpace)!==Sr,(f!==w||g!==w.version||p!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),d.layers.enableAll(),b.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new zo(new JO(2,2),new Ld({name:"BackgroundMaterial",uniforms:Jp(ns.background.uniforms),vertexShader:ns.background.vertexShader,fragmentShader:ns.background.fragmentShader,side:Od,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=w,u.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,u.material.toneMapped=or.getTransfer(w.colorSpace)!==Sr,w.matrixAutoUpdate===!0&&w.updateMatrix(),u.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||g!==w.version||p!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,g=w.version,p=t.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null))}function y(b,v){b.getRGB(G_,OQ(t)),r.buffers.color.setClear(G_.r,G_.g,G_.b,v,o)}return{getClearColor:function(){return l},setClearColor:function(b,v=1){l.set(b),c=v,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,y(l,c)},render:x}}function z5e(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||a!==null,l={},c=b(null);let u=c,d=!1;function f(P,W,Z,G,Y){let X=!1;if(o){const q=y(G,Z,W);u!==q&&(u=q,p(u.object)),X=v(P,G,Z,Y),X&&E(P,G,Z,Y)}else{const q=W.wireframe===!0;(u.geometry!==G.id||u.program!==Z.id||u.wireframe!==q)&&(u.geometry=G.id,u.program=Z.id,u.wireframe=q,X=!0)}Y!==null&&n.update(Y,t.ELEMENT_ARRAY_BUFFER),(X||d)&&(d=!1,O(P,W,Z,G),Y!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Y).buffer))}function g(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function p(P){return r.isWebGL2?t.bindVertexArray(P):a.bindVertexArrayOES(P)}function x(P){return r.isWebGL2?t.deleteVertexArray(P):a.deleteVertexArrayOES(P)}function y(P,W,Z){const G=Z.wireframe===!0;let Y=l[P.id];Y===void 0&&(Y={},l[P.id]=Y);let X=Y[W.id];X===void 0&&(X={},Y[W.id]=X);let q=X[G];return q===void 0&&(q=b(g()),X[G]=q),q}function b(P){const W=[],Z=[],G=[];for(let Y=0;Y<i;Y++)W[Y]=0,Z[Y]=0,G[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:W,enabledAttributes:Z,attributeDivisors:G,object:P,attributes:{},index:null}}function v(P,W,Z,G){const Y=u.attributes,X=W.attributes;let q=0;const F=Z.getAttributes();for(const V in F)if(F[V].location>=0){const re=Y[V];let ae=X[V];if(ae===void 0&&(V==="instanceMatrix"&&P.instanceMatrix&&(ae=P.instanceMatrix),V==="instanceColor"&&P.instanceColor&&(ae=P.instanceColor)),re===void 0||re.attribute!==ae||ae&&re.data!==ae.data)return!0;q++}return u.attributesNum!==q||u.index!==G}function E(P,W,Z,G){const Y={},X=W.attributes;let q=0;const F=Z.getAttributes();for(const V in F)if(F[V].location>=0){let re=X[V];re===void 0&&(V==="instanceMatrix"&&P.instanceMatrix&&(re=P.instanceMatrix),V==="instanceColor"&&P.instanceColor&&(re=P.instanceColor));const ae={};ae.attribute=re,re&&re.data&&(ae.data=re.data),Y[V]=ae,q++}u.attributes=Y,u.attributesNum=q,u.index=G}function w(){const P=u.newAttributes;for(let W=0,Z=P.length;W<Z;W++)P[W]=0}function A(P){N(P,0)}function N(P,W){const Z=u.newAttributes,G=u.enabledAttributes,Y=u.attributeDivisors;Z[P]=1,G[P]===0&&(t.enableVertexAttribArray(P),G[P]=1),Y[P]!==W&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](P,W),Y[P]=W)}function C(){const P=u.newAttributes,W=u.enabledAttributes;for(let Z=0,G=W.length;Z<G;Z++)W[Z]!==P[Z]&&(t.disableVertexAttribArray(Z),W[Z]=0)}function T(P,W,Z,G,Y,X,q){q===!0?t.vertexAttribIPointer(P,W,Z,Y,X):t.vertexAttribPointer(P,W,Z,G,Y,X)}function O(P,W,Z,G){if(r.isWebGL2===!1&&(P.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const Y=G.attributes,X=Z.getAttributes(),q=W.defaultAttributeValues;for(const F in X){const V=X[F];if(V.location>=0){let te=Y[F];if(te===void 0&&(F==="instanceMatrix"&&P.instanceMatrix&&(te=P.instanceMatrix),F==="instanceColor"&&P.instanceColor&&(te=P.instanceColor)),te!==void 0){const re=te.normalized,ae=te.itemSize,he=n.get(te);if(he===void 0)continue;const ue=he.buffer,ce=he.type,fe=he.bytesPerElement,pe=r.isWebGL2===!0&&(ce===t.INT||ce===t.UNSIGNED_INT||te.gpuType===pQ);if(te.isInterleavedBufferAttribute){const _e=te.data,ne=_e.stride,He=te.offset;if(_e.isInstancedInterleavedBuffer){for(let B=0;B<V.locationSize;B++)N(V.location+B,_e.meshPerAttribute);P.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=_e.meshPerAttribute*_e.count)}else for(let B=0;B<V.locationSize;B++)A(V.location+B);t.bindBuffer(t.ARRAY_BUFFER,ue);for(let B=0;B<V.locationSize;B++)T(V.location+B,ae/V.locationSize,ce,re,ne*fe,(He+ae/V.locationSize*B)*fe,pe)}else{if(te.isInstancedBufferAttribute){for(let _e=0;_e<V.locationSize;_e++)N(V.location+_e,te.meshPerAttribute);P.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=te.meshPerAttribute*te.count)}else for(let _e=0;_e<V.locationSize;_e++)A(V.location+_e);t.bindBuffer(t.ARRAY_BUFFER,ue);for(let _e=0;_e<V.locationSize;_e++)T(V.location+_e,ae/V.locationSize,ce,re,ae*fe,ae/V.locationSize*_e*fe,pe)}}else if(q!==void 0){const re=q[F];if(re!==void 0)switch(re.length){case 2:t.vertexAttrib2fv(V.location,re);break;case 3:t.vertexAttrib3fv(V.location,re);break;case 4:t.vertexAttrib4fv(V.location,re);break;default:t.vertexAttrib1fv(V.location,re)}}}}C()}function k(){D();for(const P in l){const W=l[P];for(const Z in W){const G=W[Z];for(const Y in G)x(G[Y].object),delete G[Y];delete W[Z]}delete l[P]}}function R(P){if(l[P.id]===void 0)return;const W=l[P.id];for(const Z in W){const G=W[Z];for(const Y in G)x(G[Y].object),delete G[Y];delete W[Z]}delete l[P.id]}function z(P){for(const W in l){const Z=l[W];if(Z[P.id]===void 0)continue;const G=Z[P.id];for(const Y in G)x(G[Y].object),delete G[Y];delete Z[P.id]}}function D(){K(),d=!0,u!==c&&(u=c,p(u.object))}function K(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:D,resetDefaultState:K,dispose:k,releaseStatesOfGeometry:R,releaseStatesOfProgram:z,initAttributes:w,enableAttribute:A,disableUnusedAttributes:C}}function B5e(t,e,n,r){const i=r.isWebGL2;let a;function o(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,g){if(g===0)return;let p,x;if(i)p=t,x="drawArraysInstanced";else if(p=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",p===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[x](a,d,f,g),n.update(f,a,g)}function u(d,f,g){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<g;x++)this.render(d[x],f[x]);else{p.multiDrawArraysWEBGL(a,d,0,f,0,g);let x=0;for(let y=0;y<g;y++)x+=f[y];n.update(x,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function H5e(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),b=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),v=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=g>0,A=o||e.has("OES_texture_float"),N=w&&A,C=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:p,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:b,maxVaryings:v,maxFragmentUniforms:E,vertexTextures:w,floatFragmentTextures:A,floatVertexTextures:N,maxSamples:C}}function $5e(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Yu,l=new wn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,g){const p=f.length!==0||g||r!==0||i;return i=g,r=f.length,p},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,g){n=d(f,g,0)},this.setState=function(f,g,p){const x=f.clippingPlanes,y=f.clipIntersection,b=f.clipShadows,v=t.get(f);if(!i||x===null||x.length===0||a&&!b)a?d(null):u();else{const E=a?0:r,w=E*4;let A=v.clippingState||null;c.value=A,A=d(x,g,w,p);for(let N=0;N!==w;++N)A[N]=n[N];v.clippingState=A,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,g,p,x){const y=f!==null?f.length:0;let b=null;if(y!==0){if(b=c.value,x!==!0||b===null){const v=p+y*4,E=g.matrixWorldInverse;l.getNormalMatrix(E),(b===null||b.length<v)&&(b=new Float32Array(v));for(let w=0,A=p;w!==y;++w,A+=4)o.copy(f[w]).applyMatrix4(E,l),o.normal.toArray(b,A),b[A+3]=o.constant}c.value=b,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,b}}function V5e(t){let e=new WeakMap;function n(o,l){return l===cP?o.mapping=Yp:l===uP&&(o.mapping=Zp),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===cP||l===uP)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 nLe(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 G5e extends LQ{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 mp=4,AV=[.125,.215,.35,.446,.526,.582],kh=20,qC=new G5e,TV=new Xt;let KC=null,XC=0,YC=0;const Nh=(1+Math.sqrt(5))/2,Zm=1/Nh,CV=[new Le(1,1,1),new Le(-1,1,1),new Le(1,1,-1),new Le(-1,1,-1),new Le(0,Nh,Zm),new Le(0,Nh,-Zm),new Le(Zm,0,Nh),new Le(-Zm,0,Nh),new Le(Nh,Zm,0),new Le(-Nh,Zm,0)];class kV{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,r=.1,i=100){KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=RV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=PV(),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(KC,XC,YC),e.scissorTest=!1,W_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Yp||e.mapping===Zp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=this._renderer.getActiveMipmapLevel();const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:so,minFilter:so,generateMipmaps:!1,type:fb,format:oo,colorSpace:tu,depthBuffer:!1},i=jV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=jV(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=W5e(a)),this._blurMaterial=q5e(a,e,n)}return i}_compileMaterial(e){const n=new zo(this._lodPlanes[0],e);this._renderer.compile(n,qC)}_sceneToCubeUV(e,n,r,i){const l=new Ts(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,g=d.toneMapping;d.getClearColor(TV),d.toneMapping=xd,d.autoClear=!1;const p=new PQ({name:"PMREM.Background",side:ls,depthWrite:!1,depthTest:!1}),x=new zo(new my,p);let y=!1;const b=e.background;b?b.isColor&&(p.color.copy(b),e.background=null,y=!0):(p.color.copy(TV),y=!0);for(let v=0;v<6;v++){const E=v%3;E===0?(l.up.set(0,c[v],0),l.lookAt(u[v],0,0)):E===1?(l.up.set(0,0,c[v]),l.lookAt(0,u[v],0)):(l.up.set(0,c[v],0),l.lookAt(0,0,u[v]));const w=this._cubeSize;W_(i,E*w,v>2?w:0,w,w),d.setRenderTarget(i),y&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=g,d.autoClear=f,e.background=b}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Yp||e.mapping===Zp;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=RV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=PV());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new zo(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;W_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,qC)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=CV[(i-1)%CV.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new zo(this._lodPlanes[i],u),g=u.uniforms,p=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*p):2*Math.PI/(2*kh-1),y=a/x,b=isFinite(a)?1+Math.floor(d*y):kh;b>kh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${kh}`);const v=[];let E=0;for(let T=0;T<kh;++T){const O=T/y,k=Math.exp(-O*O/2);v.push(k),T===0?E+=k:T<b&&(E+=2*k)}for(let T=0;T<v.length;T++)v[T]=v[T]/E;g.envMap.value=e.texture,g.samples.value=b,g.weights.value=v,g.latitudinal.value=o==="latitudinal",l&&(g.poleAxis.value=l);const{_lodMax:w}=this;g.dTheta.value=x,g.mipInt.value=w-r;const A=this._sizeLods[i],N=3*A*(i>w-mp?i-w+mp:0),C=4*(this._cubeSize-A);W_(n,N,C,3*A,2*A),c.setRenderTarget(n),c.render(f,qC)}}function W5e(t){const e=[],n=[],r=[];let i=t;const a=t-mp+1+AV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-mp?c=AV[o-t+mp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,g=[d,d,f,d,f,f,d,d,f,f,d,f],p=6,x=6,y=3,b=2,v=1,E=new Float32Array(y*x*p),w=new Float32Array(b*x*p),A=new Float32Array(v*x*p);for(let C=0;C<p;C++){const T=C%3*2/3-1,O=C>2?0:-1,k=[T,O,0,T+2/3,O,0,T+2/3,O+1,0,T,O,0,T+2/3,O+1,0,T,O+1,0];E.set(k,y*x*C),w.set(g,b*x*C);const R=[C,C,C,C,C,C];A.set(R,v*x*C)}const N=new Ca;N.setAttribute("position",new Os(E,y)),N.setAttribute("uv",new Os(w,b)),N.setAttribute("faceIndex",new Os(A,v)),e.push(N),i>mp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function jV(t,e,n){const r=new Mf(t,e,n);return r.texture.mapping=g2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function W_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function q5e(t,e,n){const r=new Float32Array(kh),i=new Le(0,1,0);return new Ld({name:"SphericalGaussianBlur",defines:{n:kh,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:e4(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:gd,depthTest:!1,depthWrite:!1})}function PV(){return new Ld({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:e4(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:gd,depthTest:!1,depthWrite:!1})}function RV(){return new Ld({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:e4(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:gd,depthTest:!1,depthWrite:!1})}function e4(){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 K5e(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===cP||c===uP,d=c===Yp||c===Zp;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new kV(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new kV(t));const g=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,g),l.addEventListener("dispose",a),g.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function X5e(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 Y5e(t,e,n,r){const i={},a=new WeakMap;function o(f){const g=f.target;g.index!==null&&e.remove(g.index);for(const x in g.attributes)e.remove(g.attributes[x]);for(const x in g.morphAttributes){const y=g.morphAttributes[x];for(let b=0,v=y.length;b<v;b++)e.remove(y[b])}g.removeEventListener("dispose",o),delete i[g.id];const p=a.get(g);p&&(e.remove(p),a.delete(g)),r.releaseStatesOfGeometry(g),g.isInstancedBufferGeometry===!0&&delete g._maxInstanceCount,n.memory.geometries--}function l(f,g){return i[g.id]===!0||(g.addEventListener("dispose",o),i[g.id]=!0,n.memory.geometries++),g}function c(f){const g=f.attributes;for(const x in g)e.update(g[x],t.ARRAY_BUFFER);const p=f.morphAttributes;for(const x in p){const y=p[x];for(let b=0,v=y.length;b<v;b++)e.update(y[b],t.ARRAY_BUFFER)}}function u(f){const g=[],p=f.index,x=f.attributes.position;let y=0;if(p!==null){const E=p.array;y=p.version;for(let w=0,A=E.length;w<A;w+=3){const N=E[w+0],C=E[w+1],T=E[w+2];g.push(N,C,C,T,T,N)}}else if(x!==void 0){const E=x.array;y=x.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const N=w+0,C=w+1,T=w+2;g.push(N,C,C,T,T,N)}}else return;const b=new(NQ(g)?DQ:RQ)(g,1);b.version=y;const v=a.get(f);v&&e.remove(v),a.set(f,b)}function d(f){const g=a.get(f);if(g){const p=f.index;p!==null&&g.version<p.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function Z5e(t,e,n,r){const i=r.isWebGL2;let a;function o(p){a=p}let l,c;function u(p){l=p.type,c=p.bytesPerElement}function d(p,x){t.drawElements(a,x,l,p*c),n.update(x,a,1)}function f(p,x,y){if(y===0)return;let b,v;if(i)b=t,v="drawElementsInstanced";else if(b=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",b===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}b[v](a,x,l,p*c,y),n.update(x,a,y)}function g(p,x,y){if(y===0)return;const b=e.get("WEBGL_multi_draw");if(b===null)for(let v=0;v<y;v++)this.render(p[v]/c,x[v]);else{b.multiDrawElementsWEBGL(a,x,0,l,p,0,y);let v=0;for(let E=0;E<y;E++)v+=x[E];n.update(v,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=g}function Q5e(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 J5e(t,e){return t[0]-e[0]}function eFe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function tFe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new cr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const g=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,y=x!==void 0?x.length:0;let b=a.get(d);if(b===void 0||b.count!==y){let W=function(){K.dispose(),a.delete(d),d.removeEventListener("dispose",W)};var p=W;b!==void 0&&b.texture.dispose();const w=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,N=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],T=d.morphAttributes.normal||[],O=d.morphAttributes.color||[];let k=0;w===!0&&(k=1),A===!0&&(k=2),N===!0&&(k=3);let R=d.attributes.position.count*k,z=1;R>e.maxTextureSize&&(z=Math.ceil(R/e.maxTextureSize),R=e.maxTextureSize);const D=new Float32Array(R*z*4*y),K=new CQ(D,R,z,y);K.type=Rc,K.needsUpdate=!0;const P=k*4;for(let Z=0;Z<y;Z++){const G=C[Z],Y=T[Z],X=O[Z],q=R*z*4*Z;for(let F=0;F<G.count;F++){const V=F*P;w===!0&&(o.fromBufferAttribute(G,F),D[q+V+0]=o.x,D[q+V+1]=o.y,D[q+V+2]=o.z,D[q+V+3]=0),A===!0&&(o.fromBufferAttribute(Y,F),D[q+V+4]=o.x,D[q+V+5]=o.y,D[q+V+6]=o.z,D[q+V+7]=0),N===!0&&(o.fromBufferAttribute(X,F),D[q+V+8]=o.x,D[q+V+9]=o.y,D[q+V+10]=o.z,D[q+V+11]=X.itemSize===4?o.w:1)}}b={count:y,texture:K,size:new an(R,z)},a.set(d,b),d.addEventListener("dispose",W)}let v=0;for(let w=0;w<g.length;w++)v+=g[w];const E=d.morphTargetsRelative?1:1-v;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",g),f.getUniforms().setValue(t,"morphTargetsTexture",b.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",b.size)}else{const x=g===void 0?0:g.length;let y=r[d.id];if(y===void 0||y.length!==x){y=[];for(let A=0;A<x;A++)y[A]=[A,0];r[d.id]=y}for(let A=0;A<x;A++){const N=y[A];N[0]=A,N[1]=g[A]}y.sort(eFe);for(let A=0;A<8;A++)A<x&&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(J5e);const b=d.morphAttributes.position,v=d.morphAttributes.normal;let E=0;for(let A=0;A<8;A++){const N=l[A],C=N[0],T=N[1];C!==Number.MAX_SAFE_INTEGER&&T?(b&&d.getAttribute("morphTarget"+A)!==b[C]&&d.setAttribute("morphTarget"+A,b[C]),v&&d.getAttribute("morphNormal"+A)!==v[C]&&d.setAttribute("morphNormal"+A,v[C]),i[A]=T,E+=T):(b&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),v&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const w=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function nFe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const g=c.skeleton;i.get(g)!==u&&(g.update(),i.set(g,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}class UQ extends cs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Yh,d!==Yh&&d!==Qp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Yh&&(r=od),r===void 0&&d===Qp&&(r=Xh),super(null,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:oa,this.minFilter=c!==void 0?c:oa,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}const zQ=new cs,BQ=new UQ(1,1);BQ.compareFunction=MQ;const HQ=new CQ,$Q=new z4e,VQ=new IQ,DV=[],OV=[],LV=new Float32Array(16),IV=new Float32Array(9),FV=new Float32Array(4);function kg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=DV[i];if(a===void 0&&(a=new Float32Array(i),DV[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ti(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Ci(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function y2(t,e){let n=OV[e];n===void 0&&(n=new Int32Array(e),OV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function rFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function iFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Ti(n,e))return;t.uniform2fv(this.addr,e),Ci(n,e)}}function aFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Ti(n,e))return;t.uniform3fv(this.addr,e),Ci(n,e)}}function sFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Ti(n,e))return;t.uniform4fv(this.addr,e),Ci(n,e)}}function oFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;FV.set(r),t.uniformMatrix2fv(this.addr,!1,FV),Ci(n,r)}}function lFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;IV.set(r),t.uniformMatrix3fv(this.addr,!1,IV),Ci(n,r)}}function cFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ti(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ci(n,e)}else{if(Ti(n,r))return;LV.set(r),t.uniformMatrix4fv(this.addr,!1,LV),Ci(n,r)}}function uFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function dFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Ti(n,e))return;t.uniform2iv(this.addr,e),Ci(n,e)}}function hFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Ti(n,e))return;t.uniform3iv(this.addr,e),Ci(n,e)}}function fFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Ti(n,e))return;t.uniform4iv(this.addr,e),Ci(n,e)}}function mFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function pFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Ti(n,e))return;t.uniform2uiv(this.addr,e),Ci(n,e)}}function gFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Ti(n,e))return;t.uniform3uiv(this.addr,e),Ci(n,e)}}function xFe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Ti(n,e))return;t.uniform4uiv(this.addr,e),Ci(n,e)}}function bFe(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?BQ:zQ;n.setTexture2D(e||a,i)}function yFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||$Q,i)}function vFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||VQ,i)}function _Fe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||HQ,i)}function wFe(t){switch(t){case 5126:return rFe;case 35664:return iFe;case 35665:return aFe;case 35666:return sFe;case 35674:return oFe;case 35675:return lFe;case 35676:return cFe;case 5124:case 35670:return uFe;case 35667:case 35671:return dFe;case 35668:case 35672:return hFe;case 35669:case 35673:return fFe;case 5125:return mFe;case 36294:return pFe;case 36295:return gFe;case 36296:return xFe;case 35678:case 36198:case 36298:case 36306:case 35682:return bFe;case 35679:case 36299:case 36307:return yFe;case 35680:case 36300:case 36308:case 36293:return vFe;case 36289:case 36303:case 36311:case 36292:return _Fe}}function SFe(t,e){t.uniform1fv(this.addr,e)}function MFe(t,e){const n=kg(e,this.size,2);t.uniform2fv(this.addr,n)}function EFe(t,e){const n=kg(e,this.size,3);t.uniform3fv(this.addr,n)}function NFe(t,e){const n=kg(e,this.size,4);t.uniform4fv(this.addr,n)}function AFe(t,e){const n=kg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function TFe(t,e){const n=kg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function CFe(t,e){const n=kg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function kFe(t,e){t.uniform1iv(this.addr,e)}function jFe(t,e){t.uniform2iv(this.addr,e)}function PFe(t,e){t.uniform3iv(this.addr,e)}function RFe(t,e){t.uniform4iv(this.addr,e)}function DFe(t,e){t.uniform1uiv(this.addr,e)}function OFe(t,e){t.uniform2uiv(this.addr,e)}function LFe(t,e){t.uniform3uiv(this.addr,e)}function IFe(t,e){t.uniform4uiv(this.addr,e)}function FFe(t,e,n){const r=this.cache,i=e.length,a=y2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||zQ,a[o])}function UFe(t,e,n){const r=this.cache,i=e.length,a=y2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||$Q,a[o])}function zFe(t,e,n){const r=this.cache,i=e.length,a=y2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||VQ,a[o])}function BFe(t,e,n){const r=this.cache,i=e.length,a=y2(n,i);Ti(r,a)||(t.uniform1iv(this.addr,a),Ci(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||HQ,a[o])}function HFe(t){switch(t){case 5126:return SFe;case 35664:return MFe;case 35665:return EFe;case 35666:return NFe;case 35674:return AFe;case 35675:return TFe;case 35676:return CFe;case 5124:case 35670:return kFe;case 35667:case 35671:return jFe;case 35668:case 35672:return PFe;case 35669:case 35673:return RFe;case 5125:return DFe;case 36294:return OFe;case 36295:return LFe;case 36296:return IFe;case 35678:case 36198:case 36298:case 36306:case 35682:return FFe;case 35679:case 36299:case 36307:return UFe;case 35680:case 36300:case 36308:case 36293:return zFe;case 36289:case 36303:case 36311:case 36292:return BFe}}class $Fe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=wFe(n.type)}}class VFe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=HFe(n.type)}}class GFe{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 ZC=/(\w+)(\])?(\[|\.)?/g;function UV(t,e){t.seq.push(e),t.map[e.id]=e}function WFe(t,e,n){const r=t.name,i=r.length;for(ZC.lastIndex=0;;){const a=ZC.exec(r),o=ZC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){UV(n,u===void 0?new $Fe(l,t,e):new VFe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new GFe(l),UV(n,f)),n=f}}}class I1{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);WFe(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function zV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const qFe=37297;let KFe=0;function XFe(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 YFe(t){const e=or.getPrimaries(or.workingColorSpace),n=or.getPrimaries(t);let r;switch(e===n?r="":e===lS&&n===oS?r="LinearDisplayP3ToLinearSRGB":e===oS&&n===lS&&(r="LinearSRGBToLinearDisplayP3"),t){case tu:case x2:return[r,"LinearTransferOETF"];case la:case XO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function BV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+XFe(t.getShaderSource(e),o)}else return i}function ZFe(t,e){const n=YFe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function QFe(t,e){let n;switch(e){case ZOe:n="Linear";break;case QOe:n="Reinhard";break;case JOe:n="OptimizedCineon";break;case e4e:n="ACESFilmic";break;case t4e:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function JFe(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(i0).join(`
- `)}function eUe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function tUe(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 i0(t){return t!==""}function HV(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function $V(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const nUe=/^[ \t]*#include +<([\w\d./]+)>/gm;function gP(t){return t.replace(nUe,iUe)}const rUe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function iUe(t,e){let n=gn[e];if(n===void 0){const r=rUe.get(e);if(r!==void 0)n=gn[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 gP(n)}const aUe=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function VV(t){return t.replace(aUe,sUe)}function sUe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function GV(t){let e="precision "+t.precision+` float;
- 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 oUe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===fQ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===EOe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===yc&&(e="SHADOWMAP_TYPE_VSM"),e}function lUe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Yp:case Zp:e="ENVMAP_TYPE_CUBE";break;case g2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function cUe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Zp:e="ENVMAP_MODE_REFRACTION";break}return e}function uUe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case qO:e="ENVMAP_BLENDING_MULTIPLY";break;case XOe:e="ENVMAP_BLENDING_MIX";break;case YOe:e="ENVMAP_BLENDING_ADD";break}return e}function dUe(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 hUe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=oUe(n),u=lUe(n),d=cUe(n),f=uUe(n),g=dUe(n),p=n.isWebGL2?"":JFe(n),x=eUe(a),y=i.createProgram();let b,v,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(i0).join(`
- `),b.length>0&&(b+=`
- `),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(i0).join(`
- `),v.length>0&&(v+=`
- `)):(b=[GV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(i0).join(`
- `),v=[p,GV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==xd?"#define TONE_MAPPING":"",n.toneMapping!==xd?gn.tonemapping_pars_fragment:"",n.toneMapping!==xd?QFe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",gn.colorspace_pars_fragment,ZFe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(i0).join(`
- `)),o=gP(o),o=HV(o,n),o=$V(o,n),l=gP(l),l=HV(l,n),l=$V(l,n),o=VV(o),l=VV(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+b,v=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===cV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===cV?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+v);const w=E+b+o,A=E+v+l,N=zV(i,i.VERTEX_SHADER,w),C=zV(i,i.FRAGMENT_SHADER,A);i.attachShader(y,N),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function T(z){if(t.debug.checkShaderErrors){const D=i.getProgramInfoLog(y).trim(),K=i.getShaderInfoLog(N).trim(),P=i.getShaderInfoLog(C).trim();let W=!0,Z=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,N,C);else{const G=BV(i,N,"vertex"),Y=BV(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
- Program Info Log: `+D+`
- `+G+`
- `+Y)}else D!==""?console.warn("THREE.WebGLProgram: Program Info Log:",D):(K===""||P==="")&&(Z=!1);Z&&(z.diagnostics={runnable:W,programLog:D,vertexShader:{log:K,prefix:b},fragmentShader:{log:P,prefix:v}})}i.deleteShader(N),i.deleteShader(C),O=new I1(i,y),k=tUe(i,y)}let O;this.getUniforms=function(){return O===void 0&&T(this),O};let k;this.getAttributes=function(){return k===void 0&&T(this),k};let R=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return R===!1&&(R=i.getProgramParameter(y,qFe)),R},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=KFe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=N,this.fragmentShader=C,this}let fUe=0;class mUe{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 pUe(e),n.set(e,r)),r}}class pUe{constructor(e){this.id=fUe++,this.code=e,this.usedTimes=0}}function gUe(t,e,n,r,i,a,o){const l=new kQ,c=new mUe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,g=i.vertexTextures;let p=i.precision;const x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function y(k){return k===0?"uv":`uv${k}`}function b(k,R,z,D,K){const P=D.fog,W=K.geometry,Z=k.isMeshStandardMaterial?D.environment:null,G=(k.isMeshStandardMaterial?n:e).get(k.envMap||Z),Y=G&&G.mapping===g2?G.image.height:null,X=x[k.type];k.precision!==null&&(p=i.getMaxPrecision(k.precision),p!==k.precision&&console.warn("THREE.WebGLProgram.getParameters:",k.precision,"not supported, using",p,"instead."));const q=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,F=q!==void 0?q.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 te,re,ae,he;if(X){const Yt=ns[X];te=Yt.vertexShader,re=Yt.fragmentShader}else te=k.vertexShader,re=k.fragmentShader,c.update(k),ae=c.getVertexShaderID(k),he=c.getFragmentShaderID(k);const ue=t.getRenderTarget(),ce=K.isInstancedMesh===!0,fe=K.isBatchedMesh===!0,pe=!!k.map,_e=!!k.matcap,ne=!!G,He=!!k.aoMap,B=!!k.lightMap,H=!!k.bumpMap,le=!!k.normalMap,$=!!k.displacementMap,ee=!!k.emissiveMap,de=!!k.metalnessMap,ke=!!k.roughnessMap,we=k.anisotropy>0,Ee=k.clearcoat>0,U=k.iridescence>0,I=k.sheen>0,se=k.transmission>0,ye=we&&!!k.anisotropyMap,Se=Ee&&!!k.clearcoatMap,ve=Ee&&!!k.clearcoatNormalMap,Be=Ee&&!!k.clearcoatRoughnessMap,Ge=U&&!!k.iridescenceMap,Ke=U&&!!k.iridescenceThicknessMap,ct=I&&!!k.sheenColorMap,$e=I&&!!k.sheenRoughnessMap,ge=!!k.specularMap,Je=!!k.specularColorMap,qe=!!k.specularIntensityMap,Ze=se&&!!k.transmissionMap,lt=se&&!!k.thicknessMap,ie=!!k.gradientMap,Ie=!!k.alphaMap,xe=k.alphaTest>0,Ue=!!k.alphaHash,Pe=!!k.extensions,Me=!!W.attributes.uv1,Xe=!!W.attributes.uv2,ut=!!W.attributes.uv3;let At=xd;return k.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(At=t.toneMapping),{isWebGL2:d,shaderID:X,shaderType:k.type,shaderName:k.name,vertexShader:te,fragmentShader:re,defines:k.defines,customVertexShaderID:ae,customFragmentShaderID:he,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:p,batching:fe,instancing:ce,instancingColor:ce&&K.instanceColor!==null,supportsVertexTextures:g,outputColorSpace:ue===null?t.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:tu,map:pe,matcap:_e,envMap:ne,envMapMode:ne&&G.mapping,envMapCubeUVHeight:Y,aoMap:He,lightMap:B,bumpMap:H,normalMap:le,displacementMap:g&&$,emissiveMap:ee,normalMapObjectSpace:le&&k.normalMapType===f4e,normalMapTangentSpace:le&&k.normalMapType===SQ,metalnessMap:de,roughnessMap:ke,anisotropy:we,anisotropyMap:ye,clearcoat:Ee,clearcoatMap:Se,clearcoatNormalMap:ve,clearcoatRoughnessMap:Be,iridescence:U,iridescenceMap:Ge,iridescenceThicknessMap:Ke,sheen:I,sheenColorMap:ct,sheenRoughnessMap:$e,specularMap:ge,specularColorMap:Je,specularIntensityMap:qe,transmission:se,transmissionMap:Ze,thicknessMap:lt,gradientMap:ie,opaque:k.transparent===!1&&k.blending===Mp,alphaMap:Ie,alphaTest:xe,alphaHash:Ue,combine:k.combine,mapUv:pe&&y(k.map.channel),aoMapUv:He&&y(k.aoMap.channel),lightMapUv:B&&y(k.lightMap.channel),bumpMapUv:H&&y(k.bumpMap.channel),normalMapUv:le&&y(k.normalMap.channel),displacementMapUv:$&&y(k.displacementMap.channel),emissiveMapUv:ee&&y(k.emissiveMap.channel),metalnessMapUv:de&&y(k.metalnessMap.channel),roughnessMapUv:ke&&y(k.roughnessMap.channel),anisotropyMapUv:ye&&y(k.anisotropyMap.channel),clearcoatMapUv:Se&&y(k.clearcoatMap.channel),clearcoatNormalMapUv:ve&&y(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Be&&y(k.clearcoatRoughnessMap.channel),iridescenceMapUv:Ge&&y(k.iridescenceMap.channel),iridescenceThicknessMapUv:Ke&&y(k.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&y(k.sheenColorMap.channel),sheenRoughnessMapUv:$e&&y(k.sheenRoughnessMap.channel),specularMapUv:ge&&y(k.specularMap.channel),specularColorMapUv:Je&&y(k.specularColorMap.channel),specularIntensityMapUv:qe&&y(k.specularIntensityMap.channel),transmissionMapUv:Ze&&y(k.transmissionMap.channel),thicknessMapUv:lt&&y(k.thicknessMap.channel),alphaMapUv:Ie&&y(k.alphaMap.channel),vertexTangents:!!W.attributes.tangent&&(le||we),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,vertexUv1s:Me,vertexUv2s:Xe,vertexUv3s:ut,pointsUvs:K.isPoints===!0&&!!W.attributes.uv&&(pe||Ie),fog:!!P,useFog:k.fog===!0,fogExp2:P&&P.isFogExp2,flatShading:k.flatShading===!0,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:K.isSkinnedMesh===!0,morphTargets:W.morphAttributes.position!==void 0,morphNormals:W.morphAttributes.normal!==void 0,morphColors:W.morphAttributes.color!==void 0,morphTargetsCount:F,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:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:At,useLegacyLights:t._useLegacyLights,decodeVideoTexture:pe&&k.map.isVideoTexture===!0&&or.getTransfer(k.map.colorSpace)===Sr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===Nc,flipSided:k.side===ls,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionDerivatives:Pe&&k.extensions.derivatives===!0,extensionFragDepth:Pe&&k.extensions.fragDepth===!0,extensionDrawBuffers:Pe&&k.extensions.drawBuffers===!0,extensionShaderTextureLOD:Pe&&k.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()}}function v(k){const R=[];if(k.shaderID?R.push(k.shaderID):(R.push(k.customVertexShaderID),R.push(k.customFragmentShaderID)),k.defines!==void 0)for(const z in k.defines)R.push(z),R.push(k.defines[z]);return k.isRawShaderMaterial===!1&&(E(R,k),w(R,k),R.push(t.outputColorSpace)),R.push(k.customProgramCacheKey),R.join()}function E(k,R){k.push(R.precision),k.push(R.outputColorSpace),k.push(R.envMapMode),k.push(R.envMapCubeUVHeight),k.push(R.mapUv),k.push(R.alphaMapUv),k.push(R.lightMapUv),k.push(R.aoMapUv),k.push(R.bumpMapUv),k.push(R.normalMapUv),k.push(R.displacementMapUv),k.push(R.emissiveMapUv),k.push(R.metalnessMapUv),k.push(R.roughnessMapUv),k.push(R.anisotropyMapUv),k.push(R.clearcoatMapUv),k.push(R.clearcoatNormalMapUv),k.push(R.clearcoatRoughnessMapUv),k.push(R.iridescenceMapUv),k.push(R.iridescenceThicknessMapUv),k.push(R.sheenColorMapUv),k.push(R.sheenRoughnessMapUv),k.push(R.specularMapUv),k.push(R.specularColorMapUv),k.push(R.specularIntensityMapUv),k.push(R.transmissionMapUv),k.push(R.thicknessMapUv),k.push(R.combine),k.push(R.fogExp2),k.push(R.sizeAttenuation),k.push(R.morphTargetsCount),k.push(R.morphAttributeCount),k.push(R.numDirLights),k.push(R.numPointLights),k.push(R.numSpotLights),k.push(R.numSpotLightMaps),k.push(R.numHemiLights),k.push(R.numRectAreaLights),k.push(R.numDirLightShadows),k.push(R.numPointLightShadows),k.push(R.numSpotLightShadows),k.push(R.numSpotLightShadowsWithMaps),k.push(R.numLightProbes),k.push(R.shadowMapType),k.push(R.toneMapping),k.push(R.numClippingPlanes),k.push(R.numClipIntersection),k.push(R.depthPacking)}function w(k,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),k.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),k.push(l.mask)}function A(k){const R=x[k.type];let z;if(R){const D=ns[R];z=QO.clone(D.uniforms)}else z=k.uniforms;return z}function N(k,R){let z;for(let D=0,K=u.length;D<K;D++){const P=u[D];if(P.cacheKey===R){z=P,++z.usedTimes;break}}return z===void 0&&(z=new hUe(t,R,k,a),u.push(z)),z}function C(k){if(--k.usedTimes===0){const R=u.indexOf(k);u[R]=u[u.length-1],u.pop(),k.destroy()}}function T(k){c.remove(k)}function O(){c.dispose()}return{getParameters:b,getProgramCacheKey:v,getUniforms:A,acquireProgram:N,releaseProgram:C,releaseShaderCache:T,programs:u,dispose:O}}function xUe(){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 bUe(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function WV(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function qV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,g,p,x,y,b){let v=t[e];return v===void 0?(v={id:f.id,object:f,geometry:g,material:p,groupOrder:x,renderOrder:f.renderOrder,z:y,group:b},t[e]=v):(v.id=f.id,v.object=f,v.geometry=g,v.material=p,v.groupOrder=x,v.renderOrder=f.renderOrder,v.z=y,v.group=b),e++,v}function l(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.push(v):p.transparent===!0?i.push(v):n.push(v)}function c(f,g,p,x,y,b){const v=o(f,g,p,x,y,b);p.transmission>0?r.unshift(v):p.transparent===!0?i.unshift(v):n.unshift(v)}function u(f,g){n.length>1&&n.sort(f||bUe),r.length>1&&r.sort(g||WV),i.length>1&&i.sort(g||WV)}function d(){for(let f=e,g=t.length;f<g;f++){const p=t[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function yUe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new qV,t.set(r,[o])):i>=a.length?(o=new qV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function vUe(){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 Le,color:new Xt};break;case"SpotLight":n={position:new Le,direction:new Le,color:new Xt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Le,color:new Xt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Le,skyColor:new Xt,groundColor:new Xt};break;case"RectAreaLight":n={color:new Xt,position:new Le,halfWidth:new Le,halfHeight:new Le};break}return t[e.id]=n,n}}}function _Ue(){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 an};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new an};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new an,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let wUe=0;function SUe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function MUe(t,e){const n=new vUe,r=_Ue(),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 Le);const a=new Le,o=new yr,l=new yr;function c(d,f){let g=0,p=0,x=0;for(let D=0;D<9;D++)i.probe[D].set(0,0,0);let y=0,b=0,v=0,E=0,w=0,A=0,N=0,C=0,T=0,O=0,k=0;d.sort(SUe);const R=f===!0?Math.PI:1;for(let D=0,K=d.length;D<K;D++){const P=d[D],W=P.color,Z=P.intensity,G=P.distance,Y=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)g+=W.r*Z*R,p+=W.g*Z*R,x+=W.b*Z*R;else if(P.isLightProbe){for(let X=0;X<9;X++)i.probe[X].addScaledVector(P.sh.coefficients[X],Z);k++}else if(P.isDirectionalLight){const X=n.get(P);if(X.color.copy(P.color).multiplyScalar(P.intensity*R),P.castShadow){const q=P.shadow,F=r.get(P);F.shadowBias=q.bias,F.shadowNormalBias=q.normalBias,F.shadowRadius=q.radius,F.shadowMapSize=q.mapSize,i.directionalShadow[y]=F,i.directionalShadowMap[y]=Y,i.directionalShadowMatrix[y]=P.shadow.matrix,A++}i.directional[y]=X,y++}else if(P.isSpotLight){const X=n.get(P);X.position.setFromMatrixPosition(P.matrixWorld),X.color.copy(W).multiplyScalar(Z*R),X.distance=G,X.coneCos=Math.cos(P.angle),X.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),X.decay=P.decay,i.spot[v]=X;const q=P.shadow;if(P.map&&(i.spotLightMap[T]=P.map,T++,q.updateMatrices(P),P.castShadow&&O++),i.spotLightMatrix[v]=q.matrix,P.castShadow){const F=r.get(P);F.shadowBias=q.bias,F.shadowNormalBias=q.normalBias,F.shadowRadius=q.radius,F.shadowMapSize=q.mapSize,i.spotShadow[v]=F,i.spotShadowMap[v]=Y,C++}v++}else if(P.isRectAreaLight){const X=n.get(P);X.color.copy(W).multiplyScalar(Z),X.halfWidth.set(P.width*.5,0,0),X.halfHeight.set(0,P.height*.5,0),i.rectArea[E]=X,E++}else if(P.isPointLight){const X=n.get(P);if(X.color.copy(P.color).multiplyScalar(P.intensity*R),X.distance=P.distance,X.decay=P.decay,P.castShadow){const q=P.shadow,F=r.get(P);F.shadowBias=q.bias,F.shadowNormalBias=q.normalBias,F.shadowRadius=q.radius,F.shadowMapSize=q.mapSize,F.shadowCameraNear=q.camera.near,F.shadowCameraFar=q.camera.far,i.pointShadow[b]=F,i.pointShadowMap[b]=Y,i.pointShadowMatrix[b]=P.shadow.matrix,N++}i.point[b]=X,b++}else if(P.isHemisphereLight){const X=n.get(P);X.skyColor.copy(P.color).multiplyScalar(Z*R),X.groundColor.copy(P.groundColor).multiplyScalar(Z*R),i.hemi[w]=X,w++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ct.LTC_FLOAT_1,i.rectAreaLTC2=Ct.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ct.LTC_HALF_1,i.rectAreaLTC2=Ct.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=g,i.ambient[1]=p,i.ambient[2]=x;const z=i.hash;(z.directionalLength!==y||z.pointLength!==b||z.spotLength!==v||z.rectAreaLength!==E||z.hemiLength!==w||z.numDirectionalShadows!==A||z.numPointShadows!==N||z.numSpotShadows!==C||z.numSpotMaps!==T||z.numLightProbes!==k)&&(i.directional.length=y,i.spot.length=v,i.rectArea.length=E,i.point.length=b,i.hemi.length=w,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=N,i.pointShadowMap.length=N,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=N,i.spotLightMatrix.length=C+T-O,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=O,i.numLightProbes=k,z.directionalLength=y,z.pointLength=b,z.spotLength=v,z.rectAreaLength=E,z.hemiLength=w,z.numDirectionalShadows=A,z.numPointShadows=N,z.numSpotShadows=C,z.numSpotMaps=T,z.numLightProbes=k,i.version=wUe++)}function u(d,f){let g=0,p=0,x=0,y=0,b=0;const v=f.matrixWorldInverse;for(let E=0,w=d.length;E<w;E++){const A=d[E];if(A.isDirectionalLight){const N=i.directional[g];N.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),N.direction.sub(a),N.direction.transformDirection(v),g++}else if(A.isSpotLight){const N=i.spot[x];N.position.setFromMatrixPosition(A.matrixWorld),N.position.applyMatrix4(v),N.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),N.direction.sub(a),N.direction.transformDirection(v),x++}else if(A.isRectAreaLight){const N=i.rectArea[y];N.position.setFromMatrixPosition(A.matrixWorld),N.position.applyMatrix4(v),l.identity(),o.copy(A.matrixWorld),o.premultiply(v),l.extractRotation(o),N.halfWidth.set(A.width*.5,0,0),N.halfHeight.set(0,A.height*.5,0),N.halfWidth.applyMatrix4(l),N.halfHeight.applyMatrix4(l),y++}else if(A.isPointLight){const N=i.point[p];N.position.setFromMatrixPosition(A.matrixWorld),N.position.applyMatrix4(v),p++}else if(A.isHemisphereLight){const N=i.hemi[b];N.direction.setFromMatrixPosition(A.matrixWorld),N.direction.transformDirection(v),b++}}}return{setup:c,setupView:u,state:i}}function KV(t,e){const n=new MUe(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 EUe(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new KV(t,e),n.set(a,[c])):o>=l.length?(c=new KV(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class NUe extends Cg{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=d4e,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 AUe extends Cg{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 TUe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,CUe=`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 kUe(t,e,n){let r=new b2;const i=new an,a=new an,o=new cr,l=new NUe({depthPacking:h4e}),c=new AUe,u={},d=n.maxTextureSize,f={[Od]:ls,[ls]:Od,[Nc]:Nc},g=new Ld({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new an},radius:{value:4}},vertexShader:TUe,fragmentShader:CUe}),p=g.clone();p.defines.HORIZONTAL_PASS=1;const x=new Ca;x.setAttribute("position",new Os(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new zo(x,g),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=fQ;let v=this.type;this.render=function(N,C,T){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||N.length===0)return;const O=t.getRenderTarget(),k=t.getActiveCubeFace(),R=t.getActiveMipmapLevel(),z=t.state;z.setBlending(gd),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const D=v!==yc&&this.type===yc,K=v===yc&&this.type!==yc;for(let P=0,W=N.length;P<W;P++){const Z=N[P],G=Z.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",Z,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Y=G.getFrameExtents();if(i.multiply(Y),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Y.x),i.x=a.x*Y.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Y.y),i.y=a.y*Y.y,G.mapSize.y=a.y)),G.map===null||D===!0||K===!0){const q=this.type!==yc?{minFilter:oa,magFilter:oa}:{};G.map!==null&&G.map.dispose(),G.map=new Mf(i.x,i.y,q),G.map.texture.name=Z.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const X=G.getViewportCount();for(let q=0;q<X;q++){const F=G.getViewport(q);o.set(a.x*F.x,a.y*F.y,a.x*F.z,a.y*F.w),z.viewport(o),G.updateMatrices(Z,q),r=G.getFrustum(),A(C,T,G.camera,Z,this.type)}G.isPointLightShadow!==!0&&this.type===yc&&E(G,T),G.needsUpdate=!1}v=this.type,b.needsUpdate=!1,t.setRenderTarget(O,k,R)};function E(N,C){const T=e.update(y);g.defines.VSM_SAMPLES!==N.blurSamples&&(g.defines.VSM_SAMPLES=N.blurSamples,p.defines.VSM_SAMPLES=N.blurSamples,g.needsUpdate=!0,p.needsUpdate=!0),N.mapPass===null&&(N.mapPass=new Mf(i.x,i.y)),g.uniforms.shadow_pass.value=N.map.texture,g.uniforms.resolution.value=N.mapSize,g.uniforms.radius.value=N.radius,t.setRenderTarget(N.mapPass),t.clear(),t.renderBufferDirect(C,null,T,g,y,null),p.uniforms.shadow_pass.value=N.mapPass.texture,p.uniforms.resolution.value=N.mapSize,p.uniforms.radius.value=N.radius,t.setRenderTarget(N.map),t.clear(),t.renderBufferDirect(C,null,T,p,y,null)}function w(N,C,T,O){let k=null;const R=T.isPointLight===!0?N.customDistanceMaterial:N.customDepthMaterial;if(R!==void 0)k=R;else if(k=T.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const z=k.uuid,D=C.uuid;let K=u[z];K===void 0&&(K={},u[z]=K);let P=K[D];P===void 0&&(P=k.clone(),K[D]=P),k=P}if(k.visible=C.visible,k.wireframe=C.wireframe,O===yc?k.side=C.shadowSide!==null?C.shadowSide:C.side:k.side=C.shadowSide!==null?C.shadowSide:f[C.side],k.alphaMap=C.alphaMap,k.alphaTest=C.alphaTest,k.map=C.map,k.clipShadows=C.clipShadows,k.clippingPlanes=C.clippingPlanes,k.clipIntersection=C.clipIntersection,k.displacementMap=C.displacementMap,k.displacementScale=C.displacementScale,k.displacementBias=C.displacementBias,k.wireframeLinewidth=C.wireframeLinewidth,k.linewidth=C.linewidth,T.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const z=t.properties.get(k);z.light=T}return k}function A(N,C,T,O,k){if(N.visible===!1)return;if(N.layers.test(C.layers)&&(N.isMesh||N.isLine||N.isPoints)&&(N.castShadow||N.receiveShadow&&k===yc)&&(!N.frustumCulled||r.intersectsObject(N))){N.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,N.matrixWorld);const D=e.update(N),K=N.material;if(Array.isArray(K)){const P=D.groups;for(let W=0,Z=P.length;W<Z;W++){const G=P[W],Y=K[G.materialIndex];if(Y&&Y.visible){const X=w(N,Y,O,k);N.onBeforeShadow(t,N,C,T,D,X,G),t.renderBufferDirect(T,null,D,X,N,G),N.onAfterShadow(t,N,C,T,D,X,G)}}}else if(K.visible){const P=w(N,K,O,k);N.onBeforeShadow(t,N,C,T,D,P,null),t.renderBufferDirect(T,null,D,P,N,null),N.onAfterShadow(t,N,C,T,D,P,null)}}const z=N.children;for(let D=0,K=z.length;D<K;D++)A(z[D],C,T,O,k)}}function jUe(t,e,n){const r=n.isWebGL2;function i(){let xe=!1;const Ue=new cr;let Pe=null;const Me=new cr(0,0,0,0);return{setMask:function(Xe){Pe!==Xe&&!xe&&(t.colorMask(Xe,Xe,Xe,Xe),Pe=Xe)},setLocked:function(Xe){xe=Xe},setClear:function(Xe,ut,At,St,Yt){Yt===!0&&(Xe*=St,ut*=St,At*=St),Ue.set(Xe,ut,At,St),Me.equals(Ue)===!1&&(t.clearColor(Xe,ut,At,St),Me.copy(Ue))},reset:function(){xe=!1,Pe=null,Me.set(-1,0,0,0)}}}function a(){let xe=!1,Ue=null,Pe=null,Me=null;return{setTest:function(Xe){Xe?fe(t.DEPTH_TEST):pe(t.DEPTH_TEST)},setMask:function(Xe){Ue!==Xe&&!xe&&(t.depthMask(Xe),Ue=Xe)},setFunc:function(Xe){if(Pe!==Xe){switch(Xe){case HOe:t.depthFunc(t.NEVER);break;case $Oe:t.depthFunc(t.ALWAYS);break;case VOe:t.depthFunc(t.LESS);break;case aS:t.depthFunc(t.LEQUAL);break;case GOe:t.depthFunc(t.EQUAL);break;case WOe:t.depthFunc(t.GEQUAL);break;case qOe:t.depthFunc(t.GREATER);break;case KOe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Pe=Xe}},setLocked:function(Xe){xe=Xe},setClear:function(Xe){Me!==Xe&&(t.clearDepth(Xe),Me=Xe)},reset:function(){xe=!1,Ue=null,Pe=null,Me=null}}}function o(){let xe=!1,Ue=null,Pe=null,Me=null,Xe=null,ut=null,At=null,St=null,Yt=null;return{setTest:function(Pt){xe||(Pt?fe(t.STENCIL_TEST):pe(t.STENCIL_TEST))},setMask:function(Pt){Ue!==Pt&&!xe&&(t.stencilMask(Pt),Ue=Pt)},setFunc:function(Pt,Jt,Fn){(Pe!==Pt||Me!==Jt||Xe!==Fn)&&(t.stencilFunc(Pt,Jt,Fn),Pe=Pt,Me=Jt,Xe=Fn)},setOp:function(Pt,Jt,Fn){(ut!==Pt||At!==Jt||St!==Fn)&&(t.stencilOp(Pt,Jt,Fn),ut=Pt,At=Jt,St=Fn)},setLocked:function(Pt){xe=Pt},setClear:function(Pt){Yt!==Pt&&(t.clearStencil(Pt),Yt=Pt)},reset:function(){xe=!1,Ue=null,Pe=null,Me=null,Xe=null,ut=null,At=null,St=null,Yt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let g={},p={},x=new WeakMap,y=[],b=null,v=!1,E=null,w=null,A=null,N=null,C=null,T=null,O=null,k=new Xt(0,0,0),R=0,z=!1,D=null,K=null,P=null,W=null,Z=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Y=!1,X=0;const q=t.getParameter(t.VERSION);q.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(q)[1]),Y=X>=1):q.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),Y=X>=2);let F=null,V={};const te=t.getParameter(t.SCISSOR_BOX),re=t.getParameter(t.VIEWPORT),ae=new cr().fromArray(te),he=new cr().fromArray(re);function ue(xe,Ue,Pe,Me){const Xe=new Uint8Array(4),ut=t.createTexture();t.bindTexture(xe,ut),t.texParameteri(xe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(xe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let At=0;At<Pe;At++)r&&(xe===t.TEXTURE_3D||xe===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ue,0,t.RGBA,1,1,Me,0,t.RGBA,t.UNSIGNED_BYTE,Xe):t.texImage2D(Ue+At,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Xe);return ut}const ce={};ce[t.TEXTURE_2D]=ue(t.TEXTURE_2D,t.TEXTURE_2D,1),ce[t.TEXTURE_CUBE_MAP]=ue(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(ce[t.TEXTURE_2D_ARRAY]=ue(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ce[t.TEXTURE_3D]=ue(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),fe(t.DEPTH_TEST),c.setFunc(aS),ee(!1),de(k$),fe(t.CULL_FACE),le(gd);function fe(xe){g[xe]!==!0&&(t.enable(xe),g[xe]=!0)}function pe(xe){g[xe]!==!1&&(t.disable(xe),g[xe]=!1)}function _e(xe,Ue){return p[xe]!==Ue?(t.bindFramebuffer(xe,Ue),p[xe]=Ue,r&&(xe===t.DRAW_FRAMEBUFFER&&(p[t.FRAMEBUFFER]=Ue),xe===t.FRAMEBUFFER&&(p[t.DRAW_FRAMEBUFFER]=Ue)),!0):!1}function ne(xe,Ue){let Pe=y,Me=!1;if(xe)if(Pe=x.get(Ue),Pe===void 0&&(Pe=[],x.set(Ue,Pe)),xe.isWebGLMultipleRenderTargets){const Xe=xe.texture;if(Pe.length!==Xe.length||Pe[0]!==t.COLOR_ATTACHMENT0){for(let ut=0,At=Xe.length;ut<At;ut++)Pe[ut]=t.COLOR_ATTACHMENT0+ut;Pe.length=Xe.length,Me=!0}}else Pe[0]!==t.COLOR_ATTACHMENT0&&(Pe[0]=t.COLOR_ATTACHMENT0,Me=!0);else Pe[0]!==t.BACK&&(Pe[0]=t.BACK,Me=!0);Me&&(n.isWebGL2?t.drawBuffers(Pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Pe))}function He(xe){return b!==xe?(t.useProgram(xe),b=xe,!0):!1}const B={[Ch]:t.FUNC_ADD,[AOe]:t.FUNC_SUBTRACT,[TOe]:t.FUNC_REVERSE_SUBTRACT};if(r)B[D$]=t.MIN,B[O$]=t.MAX;else{const xe=e.get("EXT_blend_minmax");xe!==null&&(B[D$]=xe.MIN_EXT,B[O$]=xe.MAX_EXT)}const H={[COe]:t.ZERO,[kOe]:t.ONE,[jOe]:t.SRC_COLOR,[oP]:t.SRC_ALPHA,[IOe]:t.SRC_ALPHA_SATURATE,[OOe]:t.DST_COLOR,[ROe]:t.DST_ALPHA,[POe]:t.ONE_MINUS_SRC_COLOR,[lP]:t.ONE_MINUS_SRC_ALPHA,[LOe]:t.ONE_MINUS_DST_COLOR,[DOe]:t.ONE_MINUS_DST_ALPHA,[FOe]:t.CONSTANT_COLOR,[UOe]:t.ONE_MINUS_CONSTANT_COLOR,[zOe]:t.CONSTANT_ALPHA,[BOe]:t.ONE_MINUS_CONSTANT_ALPHA};function le(xe,Ue,Pe,Me,Xe,ut,At,St,Yt,Pt){if(xe===gd){v===!0&&(pe(t.BLEND),v=!1);return}if(v===!1&&(fe(t.BLEND),v=!0),xe!==NOe){if(xe!==E||Pt!==z){if((w!==Ch||C!==Ch)&&(t.blendEquation(t.FUNC_ADD),w=Ch,C=Ch),Pt)switch(xe){case Mp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case j$:t.blendFunc(t.ONE,t.ONE);break;case P$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case R$:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",xe);break}else switch(xe){case Mp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case j$:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case P$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case R$:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",xe);break}A=null,N=null,T=null,O=null,k.set(0,0,0),R=0,E=xe,z=Pt}return}Xe=Xe||Ue,ut=ut||Pe,At=At||Me,(Ue!==w||Xe!==C)&&(t.blendEquationSeparate(B[Ue],B[Xe]),w=Ue,C=Xe),(Pe!==A||Me!==N||ut!==T||At!==O)&&(t.blendFuncSeparate(H[Pe],H[Me],H[ut],H[At]),A=Pe,N=Me,T=ut,O=At),(St.equals(k)===!1||Yt!==R)&&(t.blendColor(St.r,St.g,St.b,Yt),k.copy(St),R=Yt),E=xe,z=!1}function $(xe,Ue){xe.side===Nc?pe(t.CULL_FACE):fe(t.CULL_FACE);let Pe=xe.side===ls;Ue&&(Pe=!Pe),ee(Pe),xe.blending===Mp&&xe.transparent===!1?le(gd):le(xe.blending,xe.blendEquation,xe.blendSrc,xe.blendDst,xe.blendEquationAlpha,xe.blendSrcAlpha,xe.blendDstAlpha,xe.blendColor,xe.blendAlpha,xe.premultipliedAlpha),c.setFunc(xe.depthFunc),c.setTest(xe.depthTest),c.setMask(xe.depthWrite),l.setMask(xe.colorWrite);const Me=xe.stencilWrite;u.setTest(Me),Me&&(u.setMask(xe.stencilWriteMask),u.setFunc(xe.stencilFunc,xe.stencilRef,xe.stencilFuncMask),u.setOp(xe.stencilFail,xe.stencilZFail,xe.stencilZPass)),we(xe.polygonOffset,xe.polygonOffsetFactor,xe.polygonOffsetUnits),xe.alphaToCoverage===!0?fe(t.SAMPLE_ALPHA_TO_COVERAGE):pe(t.SAMPLE_ALPHA_TO_COVERAGE)}function ee(xe){D!==xe&&(xe?t.frontFace(t.CW):t.frontFace(t.CCW),D=xe)}function de(xe){xe!==SOe?(fe(t.CULL_FACE),xe!==K&&(xe===k$?t.cullFace(t.BACK):xe===MOe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):pe(t.CULL_FACE),K=xe}function ke(xe){xe!==P&&(Y&&t.lineWidth(xe),P=xe)}function we(xe,Ue,Pe){xe?(fe(t.POLYGON_OFFSET_FILL),(W!==Ue||Z!==Pe)&&(t.polygonOffset(Ue,Pe),W=Ue,Z=Pe)):pe(t.POLYGON_OFFSET_FILL)}function Ee(xe){xe?fe(t.SCISSOR_TEST):pe(t.SCISSOR_TEST)}function U(xe){xe===void 0&&(xe=t.TEXTURE0+G-1),F!==xe&&(t.activeTexture(xe),F=xe)}function I(xe,Ue,Pe){Pe===void 0&&(F===null?Pe=t.TEXTURE0+G-1:Pe=F);let Me=V[Pe];Me===void 0&&(Me={type:void 0,texture:void 0},V[Pe]=Me),(Me.type!==xe||Me.texture!==Ue)&&(F!==Pe&&(t.activeTexture(Pe),F=Pe),t.bindTexture(xe,Ue||ce[xe]),Me.type=xe,Me.texture=Ue)}function se(){const xe=V[F];xe!==void 0&&xe.type!==void 0&&(t.bindTexture(xe.type,null),xe.type=void 0,xe.texture=void 0)}function ye(){try{t.compressedTexImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Se(){try{t.compressedTexImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ve(){try{t.texSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Be(){try{t.texSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ge(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Ke(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ct(){try{t.texStorage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function $e(){try{t.texStorage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function ge(){try{t.texImage2D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function Je(){try{t.texImage3D.apply(t,arguments)}catch(xe){console.error("THREE.WebGLState:",xe)}}function qe(xe){ae.equals(xe)===!1&&(t.scissor(xe.x,xe.y,xe.z,xe.w),ae.copy(xe))}function Ze(xe){he.equals(xe)===!1&&(t.viewport(xe.x,xe.y,xe.z,xe.w),he.copy(xe))}function lt(xe,Ue){let Pe=f.get(Ue);Pe===void 0&&(Pe=new WeakMap,f.set(Ue,Pe));let Me=Pe.get(xe);Me===void 0&&(Me=t.getUniformBlockIndex(Ue,xe.name),Pe.set(xe,Me))}function ie(xe,Ue){const Me=f.get(Ue).get(xe);d.get(Ue)!==Me&&(t.uniformBlockBinding(Ue,Me,xe.__bindingPointIndex),d.set(Ue,Me))}function Ie(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),g={},F=null,V={},p={},x=new WeakMap,y=[],b=null,v=!1,E=null,w=null,A=null,N=null,C=null,T=null,O=null,k=new Xt(0,0,0),R=0,z=!1,D=null,K=null,P=null,W=null,Z=null,ae.set(0,0,t.canvas.width,t.canvas.height),he.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:fe,disable:pe,bindFramebuffer:_e,drawBuffers:ne,useProgram:He,setBlending:le,setMaterial:$,setFlipSided:ee,setCullFace:de,setLineWidth:ke,setPolygonOffset:we,setScissorTest:Ee,activeTexture:U,bindTexture:I,unbindTexture:se,compressedTexImage2D:ye,compressedTexImage3D:Se,texImage2D:ge,texImage3D:Je,updateUBOMapping:lt,uniformBlockBinding:ie,texStorage2D:ct,texStorage3D:$e,texSubImage2D:ve,texSubImage3D:Be,compressedTexSubImage2D:Ge,compressedTexSubImage3D:Ke,scissor:qe,viewport:Ze,reset:Ie}}function PUe(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,g=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let y;const b=new WeakMap;let v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(U,I){return v?new OffscreenCanvas(U,I):uS("canvas")}function w(U,I,se,ye){let Se=1;if((U.width>ye||U.height>ye)&&(Se=ye/Math.max(U.width,U.height)),Se<1||I===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const ve=I?cS:Math.floor,Be=ve(Se*U.width),Ge=ve(Se*U.height);y===void 0&&(y=E(Be,Ge));const Ke=se?E(Be,Ge):y;return Ke.width=Be,Ke.height=Ge,Ke.getContext("2d").drawImage(U,0,0,Be,Ge),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+Be+"x"+Ge+")."),Ke}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function A(U){return pP(U.width)&&pP(U.height)}function N(U){return l?!1:U.wrapS!==Io||U.wrapT!==Io||U.minFilter!==oa&&U.minFilter!==so}function C(U,I){return U.generateMipmaps&&I&&U.minFilter!==oa&&U.minFilter!==so}function T(U){t.generateMipmap(U)}function O(U,I,se,ye,Se=!1){if(l===!1)return I;if(U!==null){if(t[U]!==void 0)return t[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let ve=I;if(I===t.RED&&(se===t.FLOAT&&(ve=t.R32F),se===t.HALF_FLOAT&&(ve=t.R16F),se===t.UNSIGNED_BYTE&&(ve=t.R8)),I===t.RED_INTEGER&&(se===t.UNSIGNED_BYTE&&(ve=t.R8UI),se===t.UNSIGNED_SHORT&&(ve=t.R16UI),se===t.UNSIGNED_INT&&(ve=t.R32UI),se===t.BYTE&&(ve=t.R8I),se===t.SHORT&&(ve=t.R16I),se===t.INT&&(ve=t.R32I)),I===t.RG&&(se===t.FLOAT&&(ve=t.RG32F),se===t.HALF_FLOAT&&(ve=t.RG16F),se===t.UNSIGNED_BYTE&&(ve=t.RG8)),I===t.RGBA){const Be=Se?sS:or.getTransfer(ye);se===t.FLOAT&&(ve=t.RGBA32F),se===t.HALF_FLOAT&&(ve=t.RGBA16F),se===t.UNSIGNED_BYTE&&(ve=Be===Sr?t.SRGB8_ALPHA8:t.RGBA8),se===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),se===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function k(U,I,se){return C(U,se)===!0||U.isFramebufferTexture&&U.minFilter!==oa&&U.minFilter!==so?Math.log2(Math.max(I.width,I.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?I.mipmaps.length:1}function R(U){return U===oa||U===L$||U===MC?t.NEAREST:t.LINEAR}function z(U){const I=U.target;I.removeEventListener("dispose",z),K(I),I.isVideoTexture&&x.delete(I)}function D(U){const I=U.target;I.removeEventListener("dispose",D),W(I)}function K(U){const I=r.get(U);if(I.__webglInit===void 0)return;const se=U.source,ye=b.get(se);if(ye){const Se=ye[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&P(U),Object.keys(ye).length===0&&b.delete(se)}r.remove(U)}function P(U){const I=r.get(U);t.deleteTexture(I.__webglTexture);const se=U.source,ye=b.get(se);delete ye[I.__cacheKey],o.memory.textures--}function W(U){const I=U.texture,se=r.get(U),ye=r.get(I);if(ye.__webglTexture!==void 0&&(t.deleteTexture(ye.__webglTexture),o.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(se.__webglFramebuffer[Se]))for(let ve=0;ve<se.__webglFramebuffer[Se].length;ve++)t.deleteFramebuffer(se.__webglFramebuffer[Se][ve]);else t.deleteFramebuffer(se.__webglFramebuffer[Se]);se.__webglDepthbuffer&&t.deleteRenderbuffer(se.__webglDepthbuffer[Se])}else{if(Array.isArray(se.__webglFramebuffer))for(let Se=0;Se<se.__webglFramebuffer.length;Se++)t.deleteFramebuffer(se.__webglFramebuffer[Se]);else t.deleteFramebuffer(se.__webglFramebuffer);if(se.__webglDepthbuffer&&t.deleteRenderbuffer(se.__webglDepthbuffer),se.__webglMultisampledFramebuffer&&t.deleteFramebuffer(se.__webglMultisampledFramebuffer),se.__webglColorRenderbuffer)for(let Se=0;Se<se.__webglColorRenderbuffer.length;Se++)se.__webglColorRenderbuffer[Se]&&t.deleteRenderbuffer(se.__webglColorRenderbuffer[Se]);se.__webglDepthRenderbuffer&&t.deleteRenderbuffer(se.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let Se=0,ve=I.length;Se<ve;Se++){const Be=r.get(I[Se]);Be.__webglTexture&&(t.deleteTexture(Be.__webglTexture),o.memory.textures--),r.remove(I[Se])}r.remove(I),r.remove(U)}let Z=0;function G(){Z=0}function Y(){const U=Z;return U>=c&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+c),Z+=1,U}function X(U){const I=[];return I.push(U.wrapS),I.push(U.wrapT),I.push(U.wrapR||0),I.push(U.magFilter),I.push(U.minFilter),I.push(U.anisotropy),I.push(U.internalFormat),I.push(U.format),I.push(U.type),I.push(U.generateMipmaps),I.push(U.premultiplyAlpha),I.push(U.flipY),I.push(U.unpackAlignment),I.push(U.colorSpace),I.join()}function q(U,I){const se=r.get(U);if(U.isVideoTexture&&we(U),U.isRenderTargetTexture===!1&&U.version>0&&se.__version!==U.version){const ye=U.image;if(ye===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ye.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{fe(se,U,I);return}}n.bindTexture(t.TEXTURE_2D,se.__webglTexture,t.TEXTURE0+I)}function F(U,I){const se=r.get(U);if(U.version>0&&se.__version!==U.version){fe(se,U,I);return}n.bindTexture(t.TEXTURE_2D_ARRAY,se.__webglTexture,t.TEXTURE0+I)}function V(U,I){const se=r.get(U);if(U.version>0&&se.__version!==U.version){fe(se,U,I);return}n.bindTexture(t.TEXTURE_3D,se.__webglTexture,t.TEXTURE0+I)}function te(U,I){const se=r.get(U);if(U.version>0&&se.__version!==U.version){pe(se,U,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,se.__webglTexture,t.TEXTURE0+I)}const re={[dP]:t.REPEAT,[Io]:t.CLAMP_TO_EDGE,[hP]:t.MIRRORED_REPEAT},ae={[oa]:t.NEAREST,[L$]:t.NEAREST_MIPMAP_NEAREST,[MC]:t.NEAREST_MIPMAP_LINEAR,[so]:t.LINEAR,[n4e]:t.LINEAR_MIPMAP_NEAREST,[hb]:t.LINEAR_MIPMAP_LINEAR},he={[m4e]:t.NEVER,[v4e]:t.ALWAYS,[p4e]:t.LESS,[MQ]:t.LEQUAL,[g4e]:t.EQUAL,[y4e]:t.GEQUAL,[x4e]:t.GREATER,[b4e]:t.NOTEQUAL};function ue(U,I,se){if(se?(t.texParameteri(U,t.TEXTURE_WRAP_S,re[I.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,re[I.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,re[I.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,ae[I.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,ae[I.minFilter])):(t.texParameteri(U,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(U,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(I.wrapS!==Io||I.wrapT!==Io)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(U,t.TEXTURE_MAG_FILTER,R(I.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,R(I.minFilter)),I.minFilter!==oa&&I.minFilter!==so&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),I.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,he[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ye=e.get("EXT_texture_filter_anisotropic");if(I.magFilter===oa||I.minFilter!==MC&&I.minFilter!==hb||I.type===Rc&&e.has("OES_texture_float_linear")===!1||l===!1&&I.type===fb&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(t.texParameterf(U,ye.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function ce(U,I){let se=!1;U.__webglInit===void 0&&(U.__webglInit=!0,I.addEventListener("dispose",z));const ye=I.source;let Se=b.get(ye);Se===void 0&&(Se={},b.set(ye,Se));const ve=X(I);if(ve!==U.__cacheKey){Se[ve]===void 0&&(Se[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,se=!0),Se[ve].usedTimes++;const Be=Se[U.__cacheKey];Be!==void 0&&(Se[U.__cacheKey].usedTimes--,Be.usedTimes===0&&P(I)),U.__cacheKey=ve,U.__webglTexture=Se[ve].texture}return se}function fe(U,I,se){let ye=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ye=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(ye=t.TEXTURE_3D);const Se=ce(U,I),ve=I.source;n.bindTexture(ye,U.__webglTexture,t.TEXTURE0+se);const Be=r.get(ve);if(ve.version!==Be.__version||Se===!0){n.activeTexture(t.TEXTURE0+se);const Ge=or.getPrimaries(or.workingColorSpace),Ke=I.colorSpace===lo?null:or.getPrimaries(I.colorSpace),ct=I.colorSpace===lo||Ge===Ke?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ct);const $e=N(I)&&A(I.image)===!1;let ge=w(I.image,$e,!1,d);ge=Ee(I,ge);const Je=A(ge)||l,qe=a.convert(I.format,I.colorSpace);let Ze=a.convert(I.type),lt=O(I.internalFormat,qe,Ze,I.colorSpace,I.isVideoTexture);ue(ye,I,Je);let ie;const Ie=I.mipmaps,xe=l&&I.isVideoTexture!==!0&<!==_Q,Ue=Be.__version===void 0||Se===!0,Pe=k(I,ge,Je);if(I.isDepthTexture)lt=t.DEPTH_COMPONENT,l?I.type===Rc?lt=t.DEPTH_COMPONENT32F:I.type===od?lt=t.DEPTH_COMPONENT24:I.type===Xh?lt=t.DEPTH24_STENCIL8:lt=t.DEPTH_COMPONENT16:I.type===Rc&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Yh&<===t.DEPTH_COMPONENT&&I.type!==KO&&I.type!==od&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=od,Ze=a.convert(I.type)),I.format===Qp&<===t.DEPTH_COMPONENT&&(lt=t.DEPTH_STENCIL,I.type!==Xh&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Xh,Ze=a.convert(I.type))),Ue&&(xe?n.texStorage2D(t.TEXTURE_2D,1,lt,ge.width,ge.height):n.texImage2D(t.TEXTURE_2D,0,lt,ge.width,ge.height,0,qe,Ze,null));else if(I.isDataTexture)if(Ie.length>0&&Je){xe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Pe,lt,Ie[0].width,Ie[0].height);for(let Me=0,Xe=Ie.length;Me<Xe;Me++)ie=Ie[Me],xe?n.texSubImage2D(t.TEXTURE_2D,Me,0,0,ie.width,ie.height,qe,Ze,ie.data):n.texImage2D(t.TEXTURE_2D,Me,lt,ie.width,ie.height,0,qe,Ze,ie.data);I.generateMipmaps=!1}else xe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Pe,lt,ge.width,ge.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ge.width,ge.height,qe,Ze,ge.data)):n.texImage2D(t.TEXTURE_2D,0,lt,ge.width,ge.height,0,qe,Ze,ge.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){xe&&Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Pe,lt,Ie[0].width,Ie[0].height,ge.depth);for(let Me=0,Xe=Ie.length;Me<Xe;Me++)ie=Ie[Me],I.format!==oo?qe!==null?xe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,0,ie.width,ie.height,ge.depth,qe,ie.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Me,lt,ie.width,ie.height,ge.depth,0,ie.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,0,ie.width,ie.height,ge.depth,qe,Ze,ie.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Me,lt,ie.width,ie.height,ge.depth,0,qe,Ze,ie.data)}else{xe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Pe,lt,Ie[0].width,Ie[0].height);for(let Me=0,Xe=Ie.length;Me<Xe;Me++)ie=Ie[Me],I.format!==oo?qe!==null?xe?n.compressedTexSubImage2D(t.TEXTURE_2D,Me,0,0,ie.width,ie.height,qe,ie.data):n.compressedTexImage2D(t.TEXTURE_2D,Me,lt,ie.width,ie.height,0,ie.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?n.texSubImage2D(t.TEXTURE_2D,Me,0,0,ie.width,ie.height,qe,Ze,ie.data):n.texImage2D(t.TEXTURE_2D,Me,lt,ie.width,ie.height,0,qe,Ze,ie.data)}else if(I.isDataArrayTexture)xe?(Ue&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Pe,lt,ge.width,ge.height,ge.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,ge.width,ge.height,ge.depth,qe,Ze,ge.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,lt,ge.width,ge.height,ge.depth,0,qe,Ze,ge.data);else if(I.isData3DTexture)xe?(Ue&&n.texStorage3D(t.TEXTURE_3D,Pe,lt,ge.width,ge.height,ge.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,ge.width,ge.height,ge.depth,qe,Ze,ge.data)):n.texImage3D(t.TEXTURE_3D,0,lt,ge.width,ge.height,ge.depth,0,qe,Ze,ge.data);else if(I.isFramebufferTexture){if(Ue)if(xe)n.texStorage2D(t.TEXTURE_2D,Pe,lt,ge.width,ge.height);else{let Me=ge.width,Xe=ge.height;for(let ut=0;ut<Pe;ut++)n.texImage2D(t.TEXTURE_2D,ut,lt,Me,Xe,0,qe,Ze,null),Me>>=1,Xe>>=1}}else if(Ie.length>0&&Je){xe&&Ue&&n.texStorage2D(t.TEXTURE_2D,Pe,lt,Ie[0].width,Ie[0].height);for(let Me=0,Xe=Ie.length;Me<Xe;Me++)ie=Ie[Me],xe?n.texSubImage2D(t.TEXTURE_2D,Me,0,0,qe,Ze,ie):n.texImage2D(t.TEXTURE_2D,Me,lt,qe,Ze,ie);I.generateMipmaps=!1}else xe?(Ue&&n.texStorage2D(t.TEXTURE_2D,Pe,lt,ge.width,ge.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,qe,Ze,ge)):n.texImage2D(t.TEXTURE_2D,0,lt,qe,Ze,ge);C(I,Je)&&T(ye),Be.__version=ve.version,I.onUpdate&&I.onUpdate(I)}U.__version=I.version}function pe(U,I,se){if(I.image.length!==6)return;const ye=ce(U,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+se);const ve=r.get(Se);if(Se.version!==ve.__version||ye===!0){n.activeTexture(t.TEXTURE0+se);const Be=or.getPrimaries(or.workingColorSpace),Ge=I.colorSpace===lo?null:or.getPrimaries(I.colorSpace),Ke=I.colorSpace===lo||Be===Ge?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ke);const ct=I.isCompressedTexture||I.image[0].isCompressedTexture,$e=I.image[0]&&I.image[0].isDataTexture,ge=[];for(let Me=0;Me<6;Me++)!ct&&!$e?ge[Me]=w(I.image[Me],!1,!0,u):ge[Me]=$e?I.image[Me].image:I.image[Me],ge[Me]=Ee(I,ge[Me]);const Je=ge[0],qe=A(Je)||l,Ze=a.convert(I.format,I.colorSpace),lt=a.convert(I.type),ie=O(I.internalFormat,Ze,lt,I.colorSpace),Ie=l&&I.isVideoTexture!==!0,xe=ve.__version===void 0||ye===!0;let Ue=k(I,Je,qe);ue(t.TEXTURE_CUBE_MAP,I,qe);let Pe;if(ct){Ie&&xe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,ie,Je.width,Je.height);for(let Me=0;Me<6;Me++){Pe=ge[Me].mipmaps;for(let Xe=0;Xe<Pe.length;Xe++){const ut=Pe[Xe];I.format!==oo?Ze!==null?Ie?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,0,0,ut.width,ut.height,Ze,ut.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,ie,ut.width,ut.height,0,ut.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ie?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,0,0,ut.width,ut.height,Ze,lt,ut.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe,ie,ut.width,ut.height,0,Ze,lt,ut.data)}}}else{Pe=I.mipmaps,Ie&&xe&&(Pe.length>0&&Ue++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ue,ie,ge[0].width,ge[0].height));for(let Me=0;Me<6;Me++)if($e){Ie?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,ge[Me].width,ge[Me].height,Ze,lt,ge[Me].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,ie,ge[Me].width,ge[Me].height,0,Ze,lt,ge[Me].data);for(let Xe=0;Xe<Pe.length;Xe++){const At=Pe[Xe].image[Me].image;Ie?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,0,0,At.width,At.height,Ze,lt,At.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,ie,At.width,At.height,0,Ze,lt,At.data)}}else{Ie?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,0,0,Ze,lt,ge[Me]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,0,ie,Ze,lt,ge[Me]);for(let Xe=0;Xe<Pe.length;Xe++){const ut=Pe[Xe];Ie?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,0,0,Ze,lt,ut.image[Me]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Me,Xe+1,ie,Ze,lt,ut.image[Me])}}}C(I,qe)&&T(t.TEXTURE_CUBE_MAP),ve.__version=Se.version,I.onUpdate&&I.onUpdate(I)}U.__version=I.version}function _e(U,I,se,ye,Se,ve){const Be=a.convert(se.format,se.colorSpace),Ge=a.convert(se.type),Ke=O(se.internalFormat,Be,Ge,se.colorSpace);if(!r.get(I).__hasExternalTextures){const $e=Math.max(1,I.width>>ve),ge=Math.max(1,I.height>>ve);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,ve,Ke,$e,ge,I.depth,0,Be,Ge,null):n.texImage2D(Se,ve,Ke,$e,ge,0,Be,Ge,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),ke(I)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,Se,r.get(se).__webglTexture,0,de(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,ye,Se,r.get(se).__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ne(U,I,se){if(t.bindRenderbuffer(t.RENDERBUFFER,U),I.depthBuffer&&!I.stencilBuffer){let ye=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(se||ke(I)){const Se=I.depthTexture;Se&&Se.isDepthTexture&&(Se.type===Rc?ye=t.DEPTH_COMPONENT32F:Se.type===od&&(ye=t.DEPTH_COMPONENT24));const ve=de(I);ke(I)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,ye,I.width,I.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,ye,I.width,I.height)}else t.renderbufferStorage(t.RENDERBUFFER,ye,I.width,I.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(I.depthBuffer&&I.stencilBuffer){const ye=de(I);se&&ke(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,I.width,I.height):ke(I)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ye,t.DEPTH24_STENCIL8,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const ye=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let Se=0;Se<ye.length;Se++){const ve=ye[Se],Be=a.convert(ve.format,ve.colorSpace),Ge=a.convert(ve.type),Ke=O(ve.internalFormat,Be,Ge,ve.colorSpace),ct=de(I);se&&ke(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ct,Ke,I.width,I.height):ke(I)?g.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ct,Ke,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,Ke,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function He(U,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),q(I.depthTexture,0);const ye=r.get(I.depthTexture).__webglTexture,Se=de(I);if(I.depthTexture.format===Yh)ke(I)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(I.depthTexture.format===Qp)ke(I)?g.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function B(U){const I=r.get(U),se=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!I.__autoAllocateDepthBuffer){if(se)throw new Error("target.depthTexture not supported in Cube render targets");He(I.__webglFramebuffer,U)}else if(se){I.__webglDepthbuffer=[];for(let ye=0;ye<6;ye++)n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[ye]),I.__webglDepthbuffer[ye]=t.createRenderbuffer(),ne(I.__webglDepthbuffer[ye],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer=t.createRenderbuffer(),ne(I.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function H(U,I,se){const ye=r.get(U);I!==void 0&&_e(ye.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),se!==void 0&&B(U)}function le(U){const I=U.texture,se=r.get(U),ye=r.get(I);U.addEventListener("dispose",D),U.isWebGLMultipleRenderTargets!==!0&&(ye.__webglTexture===void 0&&(ye.__webglTexture=t.createTexture()),ye.__version=I.version,o.memory.textures++);const Se=U.isWebGLCubeRenderTarget===!0,ve=U.isWebGLMultipleRenderTargets===!0,Be=A(U)||l;if(Se){se.__webglFramebuffer=[];for(let Ge=0;Ge<6;Ge++)if(l&&I.mipmaps&&I.mipmaps.length>0){se.__webglFramebuffer[Ge]=[];for(let Ke=0;Ke<I.mipmaps.length;Ke++)se.__webglFramebuffer[Ge][Ke]=t.createFramebuffer()}else se.__webglFramebuffer[Ge]=t.createFramebuffer()}else{if(l&&I.mipmaps&&I.mipmaps.length>0){se.__webglFramebuffer=[];for(let Ge=0;Ge<I.mipmaps.length;Ge++)se.__webglFramebuffer[Ge]=t.createFramebuffer()}else se.__webglFramebuffer=t.createFramebuffer();if(ve)if(i.drawBuffers){const Ge=U.texture;for(let Ke=0,ct=Ge.length;Ke<ct;Ke++){const $e=r.get(Ge[Ke]);$e.__webglTexture===void 0&&($e.__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&&U.samples>0&&ke(U)===!1){const Ge=ve?I:[I];se.__webglMultisampledFramebuffer=t.createFramebuffer(),se.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,se.__webglMultisampledFramebuffer);for(let Ke=0;Ke<Ge.length;Ke++){const ct=Ge[Ke];se.__webglColorRenderbuffer[Ke]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,se.__webglColorRenderbuffer[Ke]);const $e=a.convert(ct.format,ct.colorSpace),ge=a.convert(ct.type),Je=O(ct.internalFormat,$e,ge,ct.colorSpace,U.isXRRenderTarget===!0),qe=de(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,qe,Je,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ke,t.RENDERBUFFER,se.__webglColorRenderbuffer[Ke])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(se.__webglDepthRenderbuffer=t.createRenderbuffer(),ne(se.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Se){n.bindTexture(t.TEXTURE_CUBE_MAP,ye.__webglTexture),ue(t.TEXTURE_CUBE_MAP,I,Be);for(let Ge=0;Ge<6;Ge++)if(l&&I.mipmaps&&I.mipmaps.length>0)for(let Ke=0;Ke<I.mipmaps.length;Ke++)_e(se.__webglFramebuffer[Ge][Ke],U,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,Ke);else _e(se.__webglFramebuffer[Ge],U,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ge,0);C(I,Be)&&T(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ve){const Ge=U.texture;for(let Ke=0,ct=Ge.length;Ke<ct;Ke++){const $e=Ge[Ke],ge=r.get($e);n.bindTexture(t.TEXTURE_2D,ge.__webglTexture),ue(t.TEXTURE_2D,$e,Be),_e(se.__webglFramebuffer,U,$e,t.COLOR_ATTACHMENT0+Ke,t.TEXTURE_2D,0),C($e,Be)&&T(t.TEXTURE_2D)}n.unbindTexture()}else{let Ge=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(l?Ge=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ge,ye.__webglTexture),ue(Ge,I,Be),l&&I.mipmaps&&I.mipmaps.length>0)for(let Ke=0;Ke<I.mipmaps.length;Ke++)_e(se.__webglFramebuffer[Ke],U,I,t.COLOR_ATTACHMENT0,Ge,Ke);else _e(se.__webglFramebuffer,U,I,t.COLOR_ATTACHMENT0,Ge,0);C(I,Be)&&T(Ge),n.unbindTexture()}U.depthBuffer&&B(U)}function $(U){const I=A(U)||l,se=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let ye=0,Se=se.length;ye<Se;ye++){const ve=se[ye];if(C(ve,I)){const Be=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ge=r.get(ve).__webglTexture;n.bindTexture(Be,Ge),T(Be),n.unbindTexture()}}}function ee(U){if(l&&U.samples>0&&ke(U)===!1){const I=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],se=U.width,ye=U.height;let Se=t.COLOR_BUFFER_BIT;const ve=[],Be=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ge=r.get(U),Ke=U.isWebGLMultipleRenderTargets===!0;if(Ke)for(let ct=0;ct<I.length;ct++)n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ge.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ge.__webglFramebuffer);for(let ct=0;ct<I.length;ct++){ve.push(t.COLOR_ATTACHMENT0+ct),U.depthBuffer&&ve.push(Be);const $e=Ge.__ignoreDepthValues!==void 0?Ge.__ignoreDepthValues:!1;if($e===!1&&(U.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Ke&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ge.__webglColorRenderbuffer[ct]),$e===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Be]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Be])),Ke){const ge=r.get(I[ct]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,ge,0)}t.blitFramebuffer(0,0,se,ye,0,0,se,ye,Se,t.NEAREST),p&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ve)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ke)for(let ct=0;ct<I.length;ct++){n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,Ge.__webglColorRenderbuffer[ct]);const $e=r.get(I[ct]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ge.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,$e,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ge.__webglMultisampledFramebuffer)}}function de(U){return Math.min(f,U.samples)}function ke(U){const I=r.get(U);return l&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function we(U){const I=o.render.frame;x.get(U)!==I&&(x.set(U,I),U.update())}function Ee(U,I){const se=U.colorSpace,ye=U.format,Se=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===mP||se!==tu&&se!==lo&&(or.getTransfer(se)===Sr?l===!1?e.has("EXT_sRGB")===!0&&ye===oo?(U.format=mP,U.minFilter=so,U.generateMipmaps=!1):I=AQ.sRGBToLinear(I):(ye!==oo||Se!==bd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",se)),I}this.allocateTextureUnit=Y,this.resetTextureUnits=G,this.setTexture2D=q,this.setTexture2DArray=F,this.setTexture3D=V,this.setTextureCube=te,this.rebindTextures=H,this.setupRenderTarget=le,this.updateRenderTargetMipmap=$,this.updateMultisampleRenderTarget=ee,this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=_e,this.useMultisampledRTT=ke}function RUe(t,e,n){const r=n.isWebGL2;function i(a,o=lo){let l;const c=or.getTransfer(o);if(a===bd)return t.UNSIGNED_BYTE;if(a===gQ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===xQ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===r4e)return t.BYTE;if(a===i4e)return t.SHORT;if(a===KO)return t.UNSIGNED_SHORT;if(a===pQ)return t.INT;if(a===od)return t.UNSIGNED_INT;if(a===Rc)return t.FLOAT;if(a===fb)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===a4e)return t.ALPHA;if(a===oo)return t.RGBA;if(a===s4e)return t.LUMINANCE;if(a===o4e)return t.LUMINANCE_ALPHA;if(a===Yh)return t.DEPTH_COMPONENT;if(a===Qp)return t.DEPTH_STENCIL;if(a===mP)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===l4e)return t.RED;if(a===bQ)return t.RED_INTEGER;if(a===c4e)return t.RG;if(a===yQ)return t.RG_INTEGER;if(a===vQ)return t.RGBA_INTEGER;if(a===EC||a===NC||a===AC||a===TC)if(c===Sr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===EC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===NC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===AC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===EC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===NC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===AC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===I$||a===F$||a===U$||a===z$)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===I$)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===F$)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===U$)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===z$)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===_Q)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===B$||a===H$)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===B$)return c===Sr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===H$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===$$||a===V$||a===G$||a===W$||a===q$||a===K$||a===X$||a===Y$||a===Z$||a===Q$||a===J$||a===eV||a===tV||a===nV)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===$$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===V$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===G$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===W$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===q$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===K$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===X$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===Y$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===Z$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===Q$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===J$)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===eV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===tV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===nV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===CC||a===rV||a===iV)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===CC)return c===Sr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===rV)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===iV)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===u4e||a===aV||a===sV||a===oV)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===CC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===aV)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===sV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===oV)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Xh?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 DUe extends Ts{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class a0 extends Ua{constructor(){super(),this.isGroup=!0,this.type="Group"}}const OUe={type:"move"};class QC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new a0,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 a0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Le,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Le),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new a0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Le,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Le),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const y of e.hand.values()){const b=n.getJointPose(y,r),v=this._getHandJoint(u,y);b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=b.radius),v.visible=b!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],g=d.position.distanceTo(f.position),p=.02,x=.005;u.inputState.pinching&&g>p+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&g<=p-x&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(OUe)))}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 a0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class LUe extends Of{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,g=null,p=null,x=null;const y=n.getContextAttributes();let b=null,v=null;const E=[],w=[],A=new an;let N=null;const C=new Ts;C.layers.enable(1),C.viewport=new cr;const T=new Ts;T.layers.enable(2),T.viewport=new cr;const O=[C,T],k=new DUe;k.layers.enable(1),k.layers.enable(2);let R=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(te){let re=E[te];return re===void 0&&(re=new QC,E[te]=re),re.getTargetRaySpace()},this.getControllerGrip=function(te){let re=E[te];return re===void 0&&(re=new QC,E[te]=re),re.getGripSpace()},this.getHand=function(te){let re=E[te];return re===void 0&&(re=new QC,E[te]=re),re.getHandSpace()};function D(te){const re=w.indexOf(te.inputSource);if(re===-1)return;const ae=E[re];ae!==void 0&&(ae.update(te.inputSource,te.frame,u||o),ae.dispatchEvent({type:te.type,data:te.inputSource}))}function K(){i.removeEventListener("select",D),i.removeEventListener("selectstart",D),i.removeEventListener("selectend",D),i.removeEventListener("squeeze",D),i.removeEventListener("squeezestart",D),i.removeEventListener("squeezeend",D),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",P);for(let te=0;te<E.length;te++){const re=w[te];re!==null&&(w[te]=null,E[te].disconnect(re))}R=null,z=null,e.setRenderTarget(b),p=null,g=null,f=null,i=null,v=null,V.stop(),r.isPresenting=!1,e.setPixelRatio(N),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(te){a=te,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(te){l=te,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(te){u=te},this.getBaseLayer=function(){return g!==null?g:p},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(te){if(i=te,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",D),i.addEventListener("selectstart",D),i.addEventListener("selectend",D),i.addEventListener("squeeze",D),i.addEventListener("squeezestart",D),i.addEventListener("squeezeend",D),i.addEventListener("end",K),i.addEventListener("inputsourceschange",P),y.xrCompatible!==!0&&await n.makeXRCompatible(),N=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const re={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(i,n,re),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new Mf(p.framebufferWidth,p.framebufferHeight,{format:oo,type:bd,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let re=null,ae=null,he=null;y.depth&&(he=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,re=y.stencil?Qp:Yh,ae=y.stencil?Xh:od);const ue={colorFormat:n.RGBA8,depthFormat:he,scaleFactor:a};f=new XRWebGLBinding(i,n),g=f.createProjectionLayer(ue),i.updateRenderState({layers:[g]}),e.setPixelRatio(1),e.setSize(g.textureWidth,g.textureHeight,!1),v=new Mf(g.textureWidth,g.textureHeight,{format:oo,type:bd,depthTexture:new UQ(g.textureWidth,g.textureHeight,ae,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const ce=e.properties.get(v);ce.__ignoreDepthValues=g.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 P(te){for(let re=0;re<te.removed.length;re++){const ae=te.removed[re],he=w.indexOf(ae);he>=0&&(w[he]=null,E[he].disconnect(ae))}for(let re=0;re<te.added.length;re++){const ae=te.added[re];let he=w.indexOf(ae);if(he===-1){for(let ce=0;ce<E.length;ce++)if(ce>=w.length){w.push(ae),he=ce;break}else if(w[ce]===null){w[ce]=ae,he=ce;break}if(he===-1)break}const ue=E[he];ue&&ue.connect(ae)}}const W=new Le,Z=new Le;function G(te,re,ae){W.setFromMatrixPosition(re.matrixWorld),Z.setFromMatrixPosition(ae.matrixWorld);const he=W.distanceTo(Z),ue=re.projectionMatrix.elements,ce=ae.projectionMatrix.elements,fe=ue[14]/(ue[10]-1),pe=ue[14]/(ue[10]+1),_e=(ue[9]+1)/ue[5],ne=(ue[9]-1)/ue[5],He=(ue[8]-1)/ue[0],B=(ce[8]+1)/ce[0],H=fe*He,le=fe*B,$=he/(-He+B),ee=$*-He;re.matrixWorld.decompose(te.position,te.quaternion,te.scale),te.translateX(ee),te.translateZ($),te.matrixWorld.compose(te.position,te.quaternion,te.scale),te.matrixWorldInverse.copy(te.matrixWorld).invert();const de=fe+$,ke=pe+$,we=H-ee,Ee=le+(he-ee),U=_e*pe/ke*de,I=ne*pe/ke*de;te.projectionMatrix.makePerspective(we,Ee,U,I,de,ke),te.projectionMatrixInverse.copy(te.projectionMatrix).invert()}function Y(te,re){re===null?te.matrixWorld.copy(te.matrix):te.matrixWorld.multiplyMatrices(re.matrixWorld,te.matrix),te.matrixWorldInverse.copy(te.matrixWorld).invert()}this.updateCamera=function(te){if(i===null)return;k.near=T.near=C.near=te.near,k.far=T.far=C.far=te.far,(R!==k.near||z!==k.far)&&(i.updateRenderState({depthNear:k.near,depthFar:k.far}),R=k.near,z=k.far);const re=te.parent,ae=k.cameras;Y(k,re);for(let he=0;he<ae.length;he++)Y(ae[he],re);ae.length===2?G(k,C,T):k.projectionMatrix.copy(C.projectionMatrix),X(te,k,re)};function X(te,re,ae){ae===null?te.matrix.copy(re.matrixWorld):(te.matrix.copy(ae.matrixWorld),te.matrix.invert(),te.matrix.multiply(re.matrixWorld)),te.matrix.decompose(te.position,te.quaternion,te.scale),te.updateMatrixWorld(!0),te.projectionMatrix.copy(re.projectionMatrix),te.projectionMatrixInverse.copy(re.projectionMatrixInverse),te.isPerspectiveCamera&&(te.fov=pb*2*Math.atan(1/te.projectionMatrix.elements[5]),te.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(g===null&&p===null))return c},this.setFoveation=function(te){c=te,g!==null&&(g.fixedFoveation=te),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=te)};let q=null;function F(te,re){if(d=re.getViewerPose(u||o),x=re,d!==null){const ae=d.views;p!==null&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let he=!1;ae.length!==k.cameras.length&&(k.cameras.length=0,he=!0);for(let ue=0;ue<ae.length;ue++){const ce=ae[ue];let fe=null;if(p!==null)fe=p.getViewport(ce);else{const _e=f.getViewSubImage(g,ce);fe=_e.viewport,ue===0&&(e.setRenderTargetTextures(v,_e.colorTexture,g.ignoreDepthValues?void 0:_e.depthStencilTexture),e.setRenderTarget(v))}let pe=O[ue];pe===void 0&&(pe=new Ts,pe.layers.enable(ue),pe.viewport=new cr,O[ue]=pe),pe.matrix.fromArray(ce.transform.matrix),pe.matrix.decompose(pe.position,pe.quaternion,pe.scale),pe.projectionMatrix.fromArray(ce.projectionMatrix),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert(),pe.viewport.set(fe.x,fe.y,fe.width,fe.height),ue===0&&(k.matrix.copy(pe.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),he===!0&&k.cameras.push(pe)}}for(let ae=0;ae<E.length;ae++){const he=w[ae],ue=E[ae];he!==null&&ue!==void 0&&ue.update(he,re,u||o)}q&&q(te,re),re.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:re}),x=null}const V=new FQ;V.setAnimationLoop(F),this.setAnimationLoop=function(te){q=te},this.dispose=function(){}}}function IUe(t,e){function n(b,v){b.matrixAutoUpdate===!0&&b.updateMatrix(),v.value.copy(b.matrix)}function r(b,v){v.color.getRGB(b.fogColor.value,OQ(t)),v.isFog?(b.fogNear.value=v.near,b.fogFar.value=v.far):v.isFogExp2&&(b.fogDensity.value=v.density)}function i(b,v,E,w,A){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(b,v):v.isMeshToonMaterial?(a(b,v),f(b,v)):v.isMeshPhongMaterial?(a(b,v),d(b,v)):v.isMeshStandardMaterial?(a(b,v),g(b,v),v.isMeshPhysicalMaterial&&p(b,v,A)):v.isMeshMatcapMaterial?(a(b,v),x(b,v)):v.isMeshDepthMaterial?a(b,v):v.isMeshDistanceMaterial?(a(b,v),y(b,v)):v.isMeshNormalMaterial?a(b,v):v.isLineBasicMaterial?(o(b,v),v.isLineDashedMaterial&&l(b,v)):v.isPointsMaterial?c(b,v,E,w):v.isSpriteMaterial?u(b,v):v.isShadowMaterial?(b.color.value.copy(v.color),b.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(b,v){b.opacity.value=v.opacity,v.color&&b.diffuse.value.copy(v.color),v.emissive&&b.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.bumpMap&&(b.bumpMap.value=v.bumpMap,n(v.bumpMap,b.bumpMapTransform),b.bumpScale.value=v.bumpScale,v.side===ls&&(b.bumpScale.value*=-1)),v.normalMap&&(b.normalMap.value=v.normalMap,n(v.normalMap,b.normalMapTransform),b.normalScale.value.copy(v.normalScale),v.side===ls&&b.normalScale.value.negate()),v.displacementMap&&(b.displacementMap.value=v.displacementMap,n(v.displacementMap,b.displacementMapTransform),b.displacementScale.value=v.displacementScale,b.displacementBias.value=v.displacementBias),v.emissiveMap&&(b.emissiveMap.value=v.emissiveMap,n(v.emissiveMap,b.emissiveMapTransform)),v.specularMap&&(b.specularMap.value=v.specularMap,n(v.specularMap,b.specularMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest);const E=e.get(v).envMap;if(E&&(b.envMap.value=E,b.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=v.reflectivity,b.ior.value=v.ior,b.refractionRatio.value=v.refractionRatio),v.lightMap){b.lightMap.value=v.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;b.lightMapIntensity.value=v.lightMapIntensity*w,n(v.lightMap,b.lightMapTransform)}v.aoMap&&(b.aoMap.value=v.aoMap,b.aoMapIntensity.value=v.aoMapIntensity,n(v.aoMap,b.aoMapTransform))}function o(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform))}function l(b,v){b.dashSize.value=v.dashSize,b.totalSize.value=v.dashSize+v.gapSize,b.scale.value=v.scale}function c(b,v,E,w){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.size.value=v.size*E,b.scale.value=w*.5,v.map&&(b.map.value=v.map,n(v.map,b.uvTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function u(b,v){b.diffuse.value.copy(v.color),b.opacity.value=v.opacity,b.rotation.value=v.rotation,v.map&&(b.map.value=v.map,n(v.map,b.mapTransform)),v.alphaMap&&(b.alphaMap.value=v.alphaMap,n(v.alphaMap,b.alphaMapTransform)),v.alphaTest>0&&(b.alphaTest.value=v.alphaTest)}function d(b,v){b.specular.value.copy(v.specular),b.shininess.value=Math.max(v.shininess,1e-4)}function f(b,v){v.gradientMap&&(b.gradientMap.value=v.gradientMap)}function g(b,v){b.metalness.value=v.metalness,v.metalnessMap&&(b.metalnessMap.value=v.metalnessMap,n(v.metalnessMap,b.metalnessMapTransform)),b.roughness.value=v.roughness,v.roughnessMap&&(b.roughnessMap.value=v.roughnessMap,n(v.roughnessMap,b.roughnessMapTransform)),e.get(v).envMap&&(b.envMapIntensity.value=v.envMapIntensity)}function p(b,v,E){b.ior.value=v.ior,v.sheen>0&&(b.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),b.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(b.sheenColorMap.value=v.sheenColorMap,n(v.sheenColorMap,b.sheenColorMapTransform)),v.sheenRoughnessMap&&(b.sheenRoughnessMap.value=v.sheenRoughnessMap,n(v.sheenRoughnessMap,b.sheenRoughnessMapTransform))),v.clearcoat>0&&(b.clearcoat.value=v.clearcoat,b.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(b.clearcoatMap.value=v.clearcoatMap,n(v.clearcoatMap,b.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,n(v.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(b.clearcoatNormalMap.value=v.clearcoatNormalMap,n(v.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===ls&&b.clearcoatNormalScale.value.negate())),v.iridescence>0&&(b.iridescence.value=v.iridescence,b.iridescenceIOR.value=v.iridescenceIOR,b.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(b.iridescenceMap.value=v.iridescenceMap,n(v.iridescenceMap,b.iridescenceMapTransform)),v.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=v.iridescenceThicknessMap,n(v.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),v.transmission>0&&(b.transmission.value=v.transmission,b.transmissionSamplerMap.value=E.texture,b.transmissionSamplerSize.value.set(E.width,E.height),v.transmissionMap&&(b.transmissionMap.value=v.transmissionMap,n(v.transmissionMap,b.transmissionMapTransform)),b.thickness.value=v.thickness,v.thicknessMap&&(b.thicknessMap.value=v.thicknessMap,n(v.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=v.attenuationDistance,b.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(b.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(b.anisotropyMap.value=v.anisotropyMap,n(v.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=v.specularIntensity,b.specularColor.value.copy(v.specularColor),v.specularColorMap&&(b.specularColorMap.value=v.specularColorMap,n(v.specularColorMap,b.specularColorMapTransform)),v.specularIntensityMap&&(b.specularIntensityMap.value=v.specularIntensityMap,n(v.specularIntensityMap,b.specularIntensityMapTransform))}function x(b,v){v.matcap&&(b.matcap.value=v.matcap)}function y(b,v){const E=e.get(v).light;b.referencePosition.value.setFromMatrixPosition(E.matrixWorld),b.nearDistance.value=E.shadow.camera.near,b.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function FUe(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(x(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",b));const N=w.program;r.updateUBOMapping(E,N);const C=e.render.frame;a[E.id]!==C&&(g(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),N=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,N,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<l;E++)if(o.indexOf(E)===-1)return o.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function g(E){const w=i[E.id],A=E.uniforms,N=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,T=A.length;C<T;C++){const O=A[C];if(p(O,C,N)===!0){const k=O.__offset,R=Array.isArray(O.value)?O.value:[O.value];let z=0;for(let D=0;D<R.length;D++){const K=R[D],P=y(K);typeof K=="number"?(O.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,k+z,O.__data)):K.isMatrix3?(O.__data[0]=K.elements[0],O.__data[1]=K.elements[1],O.__data[2]=K.elements[2],O.__data[3]=K.elements[0],O.__data[4]=K.elements[3],O.__data[5]=K.elements[4],O.__data[6]=K.elements[5],O.__data[7]=K.elements[0],O.__data[8]=K.elements[6],O.__data[9]=K.elements[7],O.__data[10]=K.elements[8],O.__data[11]=K.elements[0]):(K.toArray(O.__data,z),z+=P.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,k,O.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function p(E,w,A){const N=E.value;if(A[w]===void 0){if(typeof N=="number")A[w]=N;else{const C=Array.isArray(N)?N:[N],T=[];for(let O=0;O<C.length;O++)T.push(C[O].clone());A[w]=T}return!0}else if(typeof N=="number"){if(A[w]!==N)return A[w]=N,!0}else{const C=Array.isArray(A[w])?A[w]:[A[w]],T=Array.isArray(N)?N:[N];for(let O=0;O<C.length;O++){const k=C[O];if(k.equals(T[O])===!1)return k.copy(T[O]),!0}}return!1}function x(E){const w=E.uniforms;let A=0;const N=16;let C=0;for(let T=0,O=w.length;T<O;T++){const k=w[T],R={boundary:0,storage:0},z=Array.isArray(k.value)?k.value:[k.value];for(let D=0,K=z.length;D<K;D++){const P=z[D],W=y(P);R.boundary+=W.boundary,R.storage+=W.storage}if(k.__data=new Float32Array(R.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=A,T>0){C=A%N;const D=N-C;C!==0&&D-R.boundary<0&&(A+=N-C,k.__offset=A)}A+=R.storage}return C=A%N,C>0&&(A+=N-C),E.__size=A,E.__cache={},this}function y(E){const w={boundary:0,storage:0};return typeof E=="number"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function b(E){const w=E.target;w.removeEventListener("dispose",b);const A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function v(){for(const E in i)t.deleteBuffer(i[E]);o=[],i={},a={}}return{bind:c,update:u,dispose:v}}class xP{constructor(e={}){const{canvas:n=O4e(),context:r=null,depth:i=!0,stencil:a=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let g;r!==null?g=r.getContextAttributes().alpha:g=o;const p=new Uint32Array(4),x=new Int32Array(4);let y=null,b=null;const v=[],E=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=la,this._useLegacyLights=!1,this.toneMapping=xd,this.toneMappingExposure=1;const w=this;let A=!1,N=0,C=0,T=null,O=-1,k=null;const R=new cr,z=new cr;let D=null;const K=new Xt(0);let P=0,W=n.width,Z=n.height,G=1,Y=null,X=null;const q=new cr(0,0,W,Z),F=new cr(0,0,W,Z);let V=!1;const te=new b2;let re=!1,ae=!1,he=null;const ue=new yr,ce=new an,fe=new Le,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function _e(){return T===null?G:1}let ne=r;function He(J,Ne){for(let ze=0;ze<J.length;ze++){const Ye=J[ze],nt=n.getContext(Ye,Ne);if(nt!==null)return nt}return null}try{const J={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${p2}`),n.addEventListener("webglcontextlost",Ie,!1),n.addEventListener("webglcontextrestored",xe,!1),n.addEventListener("webglcontextcreationerror",Ue,!1),ne===null){const Ne=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ne.shift(),ne=He(Ne,J),ne===null)throw He(Ne)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ne instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ne.getShaderPrecisionFormat===void 0&&(ne.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(J){throw console.error("THREE.WebGLRenderer: "+J.message),J}let B,H,le,$,ee,de,ke,we,Ee,U,I,se,ye,Se,ve,Be,Ge,Ke,ct,$e,ge,Je,qe,Ze;function lt(){B=new X5e(ne),H=new H5e(ne,B,e),B.init(H),Je=new RUe(ne,B,H),le=new jUe(ne,B,H),$=new Q5e(ne),ee=new xUe,de=new PUe(ne,B,le,ee,H,Je,$),ke=new V5e(w),we=new K5e(w),Ee=new aLe(ne,H),qe=new z5e(ne,B,Ee,H),U=new Y5e(ne,Ee,$,qe),I=new nFe(ne,U,Ee,$),ct=new tFe(ne,H,de),Be=new $5e(ee),se=new gUe(w,ke,we,B,H,qe,Be),ye=new IUe(w,ee),Se=new yUe,ve=new EUe(B,H),Ke=new U5e(w,ke,we,le,I,g,c),Ge=new kUe(w,I,H),Ze=new FUe(ne,$,H,le),$e=new B5e(ne,B,$,H),ge=new Z5e(ne,B,$,H),$.programs=se.programs,w.capabilities=H,w.extensions=B,w.properties=ee,w.renderLists=Se,w.shadowMap=Ge,w.state=le,w.info=$}lt();const ie=new LUe(w,ne);this.xr=ie,this.getContext=function(){return ne},this.getContextAttributes=function(){return ne.getContextAttributes()},this.forceContextLoss=function(){const J=B.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){const J=B.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(J){J!==void 0&&(G=J,this.setSize(W,Z,!1))},this.getSize=function(J){return J.set(W,Z)},this.setSize=function(J,Ne,ze=!0){if(ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=J,Z=Ne,n.width=Math.floor(J*G),n.height=Math.floor(Ne*G),ze===!0&&(n.style.width=J+"px",n.style.height=Ne+"px"),this.setViewport(0,0,J,Ne)},this.getDrawingBufferSize=function(J){return J.set(W*G,Z*G).floor()},this.setDrawingBufferSize=function(J,Ne,ze){W=J,Z=Ne,G=ze,n.width=Math.floor(J*ze),n.height=Math.floor(Ne*ze),this.setViewport(0,0,J,Ne)},this.getCurrentViewport=function(J){return J.copy(R)},this.getViewport=function(J){return J.copy(q)},this.setViewport=function(J,Ne,ze,Ye){J.isVector4?q.set(J.x,J.y,J.z,J.w):q.set(J,Ne,ze,Ye),le.viewport(R.copy(q).multiplyScalar(G).floor())},this.getScissor=function(J){return J.copy(F)},this.setScissor=function(J,Ne,ze,Ye){J.isVector4?F.set(J.x,J.y,J.z,J.w):F.set(J,Ne,ze,Ye),le.scissor(z.copy(F).multiplyScalar(G).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(J){le.setScissorTest(V=J)},this.setOpaqueSort=function(J){Y=J},this.setTransparentSort=function(J){X=J},this.getClearColor=function(J){return J.copy(Ke.getClearColor())},this.setClearColor=function(){Ke.setClearColor.apply(Ke,arguments)},this.getClearAlpha=function(){return Ke.getClearAlpha()},this.setClearAlpha=function(){Ke.setClearAlpha.apply(Ke,arguments)},this.clear=function(J=!0,Ne=!0,ze=!0){let Ye=0;if(J){let nt=!1;if(T!==null){const Et=T.texture.format;nt=Et===vQ||Et===yQ||Et===bQ}if(nt){const Et=T.texture.type,oe=Et===bd||Et===od||Et===KO||Et===Xh||Et===gQ||Et===xQ,Ae=Ke.getClearColor(),Re=Ke.getClearAlpha(),De=Ae.r,je=Ae.g,at=Ae.b;oe?(p[0]=De,p[1]=je,p[2]=at,p[3]=Re,ne.clearBufferuiv(ne.COLOR,0,p)):(x[0]=De,x[1]=je,x[2]=at,x[3]=Re,ne.clearBufferiv(ne.COLOR,0,x))}else Ye|=ne.COLOR_BUFFER_BIT}Ne&&(Ye|=ne.DEPTH_BUFFER_BIT),ze&&(Ye|=ne.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ne.clear(Ye)},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",Ie,!1),n.removeEventListener("webglcontextrestored",xe,!1),n.removeEventListener("webglcontextcreationerror",Ue,!1),Se.dispose(),ve.dispose(),ee.dispose(),ke.dispose(),we.dispose(),I.dispose(),qe.dispose(),Ze.dispose(),se.dispose(),ie.dispose(),ie.removeEventListener("sessionstart",Yt),ie.removeEventListener("sessionend",Pt),he&&(he.dispose(),he=null),Jt.stop()};function Ie(J){J.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const J=$.autoReset,Ne=Ge.enabled,ze=Ge.autoUpdate,Ye=Ge.needsUpdate,nt=Ge.type;lt(),$.autoReset=J,Ge.enabled=Ne,Ge.autoUpdate=ze,Ge.needsUpdate=Ye,Ge.type=nt}function Ue(J){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function Pe(J){const Ne=J.target;Ne.removeEventListener("dispose",Pe),Me(Ne)}function Me(J){Xe(J),ee.remove(J)}function Xe(J){const Ne=ee.get(J).programs;Ne!==void 0&&(Ne.forEach(function(ze){se.releaseProgram(ze)}),J.isShaderMaterial&&se.releaseShaderCache(J))}this.renderBufferDirect=function(J,Ne,ze,Ye,nt,Et){Ne===null&&(Ne=pe);const oe=nt.isMesh&&nt.matrixWorld.determinant()<0,Ae=cn(J,Ne,ze,Ye,nt);le.setMaterial(Ye,oe);let Re=ze.index,De=1;if(Ye.wireframe===!0){if(Re=U.getWireframeAttribute(ze),Re===void 0)return;De=2}const je=ze.drawRange,at=ze.attributes.position;let bt=je.start*De,Tt=(je.start+je.count)*De;Et!==null&&(bt=Math.max(bt,Et.start*De),Tt=Math.min(Tt,(Et.start+Et.count)*De)),Re!==null?(bt=Math.max(bt,0),Tt=Math.min(Tt,Re.count)):at!=null&&(bt=Math.max(bt,0),Tt=Math.min(Tt,at.count));const Nt=Tt-bt;if(Nt<0||Nt===1/0)return;qe.setup(nt,Ye,Ae,ze,Re);let Ft,jt=$e;if(Re!==null&&(Ft=Ee.get(Re),jt=ge,jt.setIndex(Ft)),nt.isMesh)Ye.wireframe===!0?(le.setLineWidth(Ye.wireframeLinewidth*_e()),jt.setMode(ne.LINES)):jt.setMode(ne.TRIANGLES);else if(nt.isLine){let _t=Ye.linewidth;_t===void 0&&(_t=1),le.setLineWidth(_t*_e()),nt.isLineSegments?jt.setMode(ne.LINES):nt.isLineLoop?jt.setMode(ne.LINE_LOOP):jt.setMode(ne.LINE_STRIP)}else nt.isPoints?jt.setMode(ne.POINTS):nt.isSprite&&jt.setMode(ne.TRIANGLES);if(nt.isBatchedMesh)jt.renderMultiDraw(nt._multiDrawStarts,nt._multiDrawCounts,nt._multiDrawCount);else if(nt.isInstancedMesh)jt.renderInstances(bt,Nt,nt.count);else if(ze.isInstancedBufferGeometry){const _t=ze._maxInstanceCount!==void 0?ze._maxInstanceCount:1/0,nn=Math.min(ze.instanceCount,_t);jt.renderInstances(bt,Nt,nn)}else jt.render(bt,Nt)};function ut(J,Ne,ze){J.transparent===!0&&J.side===Nc&&J.forceSinglePass===!1?(J.side=ls,J.needsUpdate=!0,Qt(J,Ne,ze),J.side=Od,J.needsUpdate=!0,Qt(J,Ne,ze),J.side=Nc):Qt(J,Ne,ze)}this.compile=function(J,Ne,ze=null){ze===null&&(ze=J),b=ve.get(ze),b.init(),E.push(b),ze.traverseVisible(function(nt){nt.isLight&&nt.layers.test(Ne.layers)&&(b.pushLight(nt),nt.castShadow&&b.pushShadow(nt))}),J!==ze&&J.traverseVisible(function(nt){nt.isLight&&nt.layers.test(Ne.layers)&&(b.pushLight(nt),nt.castShadow&&b.pushShadow(nt))}),b.setupLights(w._useLegacyLights);const Ye=new Set;return J.traverse(function(nt){const Et=nt.material;if(Et)if(Array.isArray(Et))for(let oe=0;oe<Et.length;oe++){const Ae=Et[oe];ut(Ae,ze,nt),Ye.add(Ae)}else ut(Et,ze,nt),Ye.add(Et)}),E.pop(),b=null,Ye},this.compileAsync=function(J,Ne,ze=null){const Ye=this.compile(J,Ne,ze);return new Promise(nt=>{function Et(){if(Ye.forEach(function(oe){ee.get(oe).currentProgram.isReady()&&Ye.delete(oe)}),Ye.size===0){nt(J);return}setTimeout(Et,10)}B.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let At=null;function St(J){At&&At(J)}function Yt(){Jt.stop()}function Pt(){Jt.start()}const Jt=new FQ;Jt.setAnimationLoop(St),typeof self<"u"&&Jt.setContext(self),this.setAnimationLoop=function(J){At=J,ie.setAnimationLoop(J),J===null?Jt.stop():Jt.start()},ie.addEventListener("sessionstart",Yt),ie.addEventListener("sessionend",Pt),this.render=function(J,Ne){if(Ne!==void 0&&Ne.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),Ne.parent===null&&Ne.matrixWorldAutoUpdate===!0&&Ne.updateMatrixWorld(),ie.enabled===!0&&ie.isPresenting===!0&&(ie.cameraAutoUpdate===!0&&ie.updateCamera(Ne),Ne=ie.getCamera()),J.isScene===!0&&J.onBeforeRender(w,J,Ne,T),b=ve.get(J,E.length),b.init(),E.push(b),ue.multiplyMatrices(Ne.projectionMatrix,Ne.matrixWorldInverse),te.setFromProjectionMatrix(ue),ae=this.localClippingEnabled,re=Be.init(this.clippingPlanes,ae),y=Se.get(J,v.length),y.init(),v.push(y),Fn(J,Ne,0,w.sortObjects),y.finish(),w.sortObjects===!0&&y.sort(Y,X),this.info.render.frame++,re===!0&&Be.beginShadows();const ze=b.state.shadowsArray;if(Ge.render(ze,J,Ne),re===!0&&Be.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ke.render(y,J),b.setupLights(w._useLegacyLights),Ne.isArrayCamera){const Ye=Ne.cameras;for(let nt=0,Et=Ye.length;nt<Et;nt++){const oe=Ye[nt];Sn(y,J,oe,oe.viewport)}}else Sn(y,J,Ne);T!==null&&(de.updateMultisampleRenderTarget(T),de.updateRenderTargetMipmap(T)),J.isScene===!0&&J.onAfterRender(w,J,Ne),qe.resetDefaultState(),O=-1,k=null,E.pop(),E.length>0?b=E[E.length-1]:b=null,v.pop(),v.length>0?y=v[v.length-1]:y=null};function Fn(J,Ne,ze,Ye){if(J.visible===!1)return;if(J.layers.test(Ne.layers)){if(J.isGroup)ze=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(Ne);else if(J.isLight)b.pushLight(J),J.castShadow&&b.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||te.intersectsSprite(J)){Ye&&fe.setFromMatrixPosition(J.matrixWorld).applyMatrix4(ue);const oe=I.update(J),Ae=J.material;Ae.visible&&y.push(J,oe,Ae,ze,fe.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(!J.frustumCulled||te.intersectsObject(J))){const oe=I.update(J),Ae=J.material;if(Ye&&(J.boundingSphere!==void 0?(J.boundingSphere===null&&J.computeBoundingSphere(),fe.copy(J.boundingSphere.center)):(oe.boundingSphere===null&&oe.computeBoundingSphere(),fe.copy(oe.boundingSphere.center)),fe.applyMatrix4(J.matrixWorld).applyMatrix4(ue)),Array.isArray(Ae)){const Re=oe.groups;for(let De=0,je=Re.length;De<je;De++){const at=Re[De],bt=Ae[at.materialIndex];bt&&bt.visible&&y.push(J,oe,bt,ze,fe.z,at)}}else Ae.visible&&y.push(J,oe,Ae,ze,fe.z,null)}}const Et=J.children;for(let oe=0,Ae=Et.length;oe<Ae;oe++)Fn(Et[oe],Ne,ze,Ye)}function Sn(J,Ne,ze,Ye){const nt=J.opaque,Et=J.transmissive,oe=J.transparent;b.setupLightsView(ze),re===!0&&Be.setGlobalState(w.clippingPlanes,ze),Et.length>0&&vr(nt,Et,Ne,ze),Ye&&le.viewport(R.copy(Ye)),nt.length>0&&ft(nt,Ne,ze),Et.length>0&&ft(Et,Ne,ze),oe.length>0&&ft(oe,Ne,ze),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function vr(J,Ne,ze,Ye){if((ze.isScene===!0?ze.overrideMaterial:null)!==null)return;const Et=H.isWebGL2;he===null&&(he=new Mf(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")?fb:bd,minFilter:hb,samples:Et?4:0})),w.getDrawingBufferSize(ce),Et?he.setSize(ce.x,ce.y):he.setSize(cS(ce.x),cS(ce.y));const oe=w.getRenderTarget();w.setRenderTarget(he),w.getClearColor(K),P=w.getClearAlpha(),P<1&&w.setClearColor(16777215,.5),w.clear();const Ae=w.toneMapping;w.toneMapping=xd,ft(J,ze,Ye),de.updateMultisampleRenderTarget(he),de.updateRenderTargetMipmap(he);let Re=!1;for(let De=0,je=Ne.length;De<je;De++){const at=Ne[De],bt=at.object,Tt=at.geometry,Nt=at.material,Ft=at.group;if(Nt.side===Nc&&bt.layers.test(Ye.layers)){const jt=Nt.side;Nt.side=ls,Nt.needsUpdate=!0,Ht(bt,ze,Ye,Tt,Nt,Ft),Nt.side=jt,Nt.needsUpdate=!0,Re=!0}}Re===!0&&(de.updateMultisampleRenderTarget(he),de.updateRenderTargetMipmap(he)),w.setRenderTarget(oe),w.setClearColor(K,P),w.toneMapping=Ae}function ft(J,Ne,ze){const Ye=Ne.isScene===!0?Ne.overrideMaterial:null;for(let nt=0,Et=J.length;nt<Et;nt++){const oe=J[nt],Ae=oe.object,Re=oe.geometry,De=Ye===null?oe.material:Ye,je=oe.group;Ae.layers.test(ze.layers)&&Ht(Ae,Ne,ze,Re,De,je)}}function Ht(J,Ne,ze,Ye,nt,Et){J.onBeforeRender(w,Ne,ze,Ye,nt,Et),J.modelViewMatrix.multiplyMatrices(ze.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),nt.onBeforeRender(w,Ne,ze,Ye,J,Et),nt.transparent===!0&&nt.side===Nc&&nt.forceSinglePass===!1?(nt.side=ls,nt.needsUpdate=!0,w.renderBufferDirect(ze,Ne,Ye,nt,J,Et),nt.side=Od,nt.needsUpdate=!0,w.renderBufferDirect(ze,Ne,Ye,nt,J,Et),nt.side=Nc):w.renderBufferDirect(ze,Ne,Ye,nt,J,Et),J.onAfterRender(w,Ne,ze,Ye,nt,Et)}function Qt(J,Ne,ze){Ne.isScene!==!0&&(Ne=pe);const Ye=ee.get(J),nt=b.state.lights,Et=b.state.shadowsArray,oe=nt.state.version,Ae=se.getParameters(J,nt.state,Et,Ne,ze),Re=se.getProgramCacheKey(Ae);let De=Ye.programs;Ye.environment=J.isMeshStandardMaterial?Ne.environment:null,Ye.fog=Ne.fog,Ye.envMap=(J.isMeshStandardMaterial?we:ke).get(J.envMap||Ye.environment),De===void 0&&(J.addEventListener("dispose",Pe),De=new Map,Ye.programs=De);let je=De.get(Re);if(je!==void 0){if(Ye.currentProgram===je&&Ye.lightsStateVersion===oe)return $t(J,Ae),je}else Ae.uniforms=se.getUniforms(J),J.onBuild(ze,Ae,w),J.onBeforeCompile(Ae,w),je=se.acquireProgram(Ae,Re),De.set(Re,je),Ye.uniforms=Ae.uniforms;const at=Ye.uniforms;return(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(at.clippingPlanes=Be.uniform),$t(J,Ae),Ye.needsLights=qt(J),Ye.lightsStateVersion=oe,Ye.needsLights&&(at.ambientLightColor.value=nt.state.ambient,at.lightProbe.value=nt.state.probe,at.directionalLights.value=nt.state.directional,at.directionalLightShadows.value=nt.state.directionalShadow,at.spotLights.value=nt.state.spot,at.spotLightShadows.value=nt.state.spotShadow,at.rectAreaLights.value=nt.state.rectArea,at.ltc_1.value=nt.state.rectAreaLTC1,at.ltc_2.value=nt.state.rectAreaLTC2,at.pointLights.value=nt.state.point,at.pointLightShadows.value=nt.state.pointShadow,at.hemisphereLights.value=nt.state.hemi,at.directionalShadowMap.value=nt.state.directionalShadowMap,at.directionalShadowMatrix.value=nt.state.directionalShadowMatrix,at.spotShadowMap.value=nt.state.spotShadowMap,at.spotLightMatrix.value=nt.state.spotLightMatrix,at.spotLightMap.value=nt.state.spotLightMap,at.pointShadowMap.value=nt.state.pointShadowMap,at.pointShadowMatrix.value=nt.state.pointShadowMatrix),Ye.currentProgram=je,Ye.uniformsList=null,je}function mt(J){if(J.uniformsList===null){const Ne=J.currentProgram.getUniforms();J.uniformsList=I1.seqWithValue(Ne.seq,J.uniforms)}return J.uniformsList}function $t(J,Ne){const ze=ee.get(J);ze.outputColorSpace=Ne.outputColorSpace,ze.batching=Ne.batching,ze.instancing=Ne.instancing,ze.instancingColor=Ne.instancingColor,ze.skinning=Ne.skinning,ze.morphTargets=Ne.morphTargets,ze.morphNormals=Ne.morphNormals,ze.morphColors=Ne.morphColors,ze.morphTargetsCount=Ne.morphTargetsCount,ze.numClippingPlanes=Ne.numClippingPlanes,ze.numIntersection=Ne.numClipIntersection,ze.vertexAlphas=Ne.vertexAlphas,ze.vertexTangents=Ne.vertexTangents,ze.toneMapping=Ne.toneMapping}function cn(J,Ne,ze,Ye,nt){Ne.isScene!==!0&&(Ne=pe),de.resetTextureUnits();const Et=Ne.fog,oe=Ye.isMeshStandardMaterial?Ne.environment:null,Ae=T===null?w.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:tu,Re=(Ye.isMeshStandardMaterial?we:ke).get(Ye.envMap||oe),De=Ye.vertexColors===!0&&!!ze.attributes.color&&ze.attributes.color.itemSize===4,je=!!ze.attributes.tangent&&(!!Ye.normalMap||Ye.anisotropy>0),at=!!ze.morphAttributes.position,bt=!!ze.morphAttributes.normal,Tt=!!ze.morphAttributes.color;let Nt=xd;Ye.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(Nt=w.toneMapping);const Ft=ze.morphAttributes.position||ze.morphAttributes.normal||ze.morphAttributes.color,jt=Ft!==void 0?Ft.length:0,_t=ee.get(Ye),nn=b.state.lights;if(re===!0&&(ae===!0||J!==k)){const Yr=J===k&&Ye.id===O;Be.setState(Ye,J,Yr)}let Vt=!1;Ye.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==nn.state.version||_t.outputColorSpace!==Ae||nt.isBatchedMesh&&_t.batching===!1||!nt.isBatchedMesh&&_t.batching===!0||nt.isInstancedMesh&&_t.instancing===!1||!nt.isInstancedMesh&&_t.instancing===!0||nt.isSkinnedMesh&&_t.skinning===!1||!nt.isSkinnedMesh&&_t.skinning===!0||nt.isInstancedMesh&&_t.instancingColor===!0&&nt.instanceColor===null||nt.isInstancedMesh&&_t.instancingColor===!1&&nt.instanceColor!==null||_t.envMap!==Re||Ye.fog===!0&&_t.fog!==Et||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==Be.numPlanes||_t.numIntersection!==Be.numIntersection)||_t.vertexAlphas!==De||_t.vertexTangents!==je||_t.morphTargets!==at||_t.morphNormals!==bt||_t.morphColors!==Tt||_t.toneMapping!==Nt||H.isWebGL2===!0&&_t.morphTargetsCount!==jt)&&(Vt=!0):(Vt=!0,_t.__version=Ye.version);let fn=_t.currentProgram;Vt===!0&&(fn=Qt(Ye,Ne,nt));let _n=!1,jn=!1,Bt=!1;const sn=fn.getUniforms(),un=_t.uniforms;if(le.useProgram(fn.program)&&(_n=!0,jn=!0,Bt=!0),Ye.id!==O&&(O=Ye.id,jn=!0),_n||k!==J){sn.setValue(ne,"projectionMatrix",J.projectionMatrix),sn.setValue(ne,"viewMatrix",J.matrixWorldInverse);const Yr=sn.map.cameraPosition;Yr!==void 0&&Yr.setValue(ne,fe.setFromMatrixPosition(J.matrixWorld)),H.logarithmicDepthBuffer&&sn.setValue(ne,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),(Ye.isMeshPhongMaterial||Ye.isMeshToonMaterial||Ye.isMeshLambertMaterial||Ye.isMeshBasicMaterial||Ye.isMeshStandardMaterial||Ye.isShaderMaterial)&&sn.setValue(ne,"isOrthographic",J.isOrthographicCamera===!0),k!==J&&(k=J,jn=!0,Bt=!0)}if(nt.isSkinnedMesh){sn.setOptional(ne,nt,"bindMatrix"),sn.setOptional(ne,nt,"bindMatrixInverse");const Yr=nt.skeleton;Yr&&(H.floatVertexTextures?(Yr.boneTexture===null&&Yr.computeBoneTexture(),sn.setValue(ne,"boneTexture",Yr.boneTexture,de)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}nt.isBatchedMesh&&(sn.setOptional(ne,nt,"batchingTexture"),sn.setValue(ne,"batchingTexture",nt._matricesTexture,de));const zr=ze.morphAttributes;if((zr.position!==void 0||zr.normal!==void 0||zr.color!==void 0&&H.isWebGL2===!0)&&ct.update(nt,ze,fn),(jn||_t.receiveShadow!==nt.receiveShadow)&&(_t.receiveShadow=nt.receiveShadow,sn.setValue(ne,"receiveShadow",nt.receiveShadow)),Ye.isMeshGouraudMaterial&&Ye.envMap!==null&&(un.envMap.value=Re,un.flipEnvMap.value=Re.isCubeTexture&&Re.isRenderTargetTexture===!1?-1:1),jn&&(sn.setValue(ne,"toneMappingExposure",w.toneMappingExposure),_t.needsLights&&Mn(un,Bt),Et&&Ye.fog===!0&&ye.refreshFogUniforms(un,Et),ye.refreshMaterialUniforms(un,Ye,G,Z,he),I1.upload(ne,mt(_t),un,de)),Ye.isShaderMaterial&&Ye.uniformsNeedUpdate===!0&&(I1.upload(ne,mt(_t),un,de),Ye.uniformsNeedUpdate=!1),Ye.isSpriteMaterial&&sn.setValue(ne,"center",nt.center),sn.setValue(ne,"modelViewMatrix",nt.modelViewMatrix),sn.setValue(ne,"normalMatrix",nt.normalMatrix),sn.setValue(ne,"modelMatrix",nt.matrixWorld),Ye.isShaderMaterial||Ye.isRawShaderMaterial){const Yr=Ye.uniformsGroups;for(let Gn=0,So=Yr.length;Gn<So;Gn++)if(H.isWebGL2){const qn=Yr[Gn];Ze.update(qn,fn),Ze.bind(qn,fn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fn}function Mn(J,Ne){J.ambientLightColor.needsUpdate=Ne,J.lightProbe.needsUpdate=Ne,J.directionalLights.needsUpdate=Ne,J.directionalLightShadows.needsUpdate=Ne,J.pointLights.needsUpdate=Ne,J.pointLightShadows.needsUpdate=Ne,J.spotLights.needsUpdate=Ne,J.spotLightShadows.needsUpdate=Ne,J.rectAreaLights.needsUpdate=Ne,J.hemisphereLights.needsUpdate=Ne}function qt(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(J,Ne,ze){ee.get(J.texture).__webglTexture=Ne,ee.get(J.depthTexture).__webglTexture=ze;const Ye=ee.get(J);Ye.__hasExternalTextures=!0,Ye.__hasExternalTextures&&(Ye.__autoAllocateDepthBuffer=ze===void 0,Ye.__autoAllocateDepthBuffer||B.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Ye.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(J,Ne){const ze=ee.get(J);ze.__webglFramebuffer=Ne,ze.__useDefaultFramebuffer=Ne===void 0},this.setRenderTarget=function(J,Ne=0,ze=0){T=J,N=Ne,C=ze;let Ye=!0,nt=null,Et=!1,oe=!1;if(J){const Re=ee.get(J);Re.__useDefaultFramebuffer!==void 0?(le.bindFramebuffer(ne.FRAMEBUFFER,null),Ye=!1):Re.__webglFramebuffer===void 0?de.setupRenderTarget(J):Re.__hasExternalTextures&&de.rebindTextures(J,ee.get(J.texture).__webglTexture,ee.get(J.depthTexture).__webglTexture);const De=J.texture;(De.isData3DTexture||De.isDataArrayTexture||De.isCompressedArrayTexture)&&(oe=!0);const je=ee.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Array.isArray(je[Ne])?nt=je[Ne][ze]:nt=je[Ne],Et=!0):H.isWebGL2&&J.samples>0&&de.useMultisampledRTT(J)===!1?nt=ee.get(J).__webglMultisampledFramebuffer:Array.isArray(je)?nt=je[ze]:nt=je,R.copy(J.viewport),z.copy(J.scissor),D=J.scissorTest}else R.copy(q).multiplyScalar(G).floor(),z.copy(F).multiplyScalar(G).floor(),D=V;if(le.bindFramebuffer(ne.FRAMEBUFFER,nt)&&H.drawBuffers&&Ye&&le.drawBuffers(J,nt),le.viewport(R),le.scissor(z),le.setScissorTest(D),Et){const Re=ee.get(J.texture);ne.framebufferTexture2D(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Re.__webglTexture,ze)}else if(oe){const Re=ee.get(J.texture),De=Ne||0;ne.framebufferTextureLayer(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,Re.__webglTexture,ze||0,De)}O=-1},this.readRenderTargetPixels=function(J,Ne,ze,Ye,nt,Et,oe){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=ee.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&oe!==void 0&&(Ae=Ae[oe]),Ae){le.bindFramebuffer(ne.FRAMEBUFFER,Ae);try{const Re=J.texture,De=Re.format,je=Re.type;if(De!==oo&&Je.convert(De)!==ne.getParameter(ne.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const at=je===fb&&(B.has("EXT_color_buffer_half_float")||H.isWebGL2&&B.has("EXT_color_buffer_float"));if(je!==bd&&Je.convert(je)!==ne.getParameter(ne.IMPLEMENTATION_COLOR_READ_TYPE)&&!(je===Rc&&(H.isWebGL2||B.has("OES_texture_float")||B.has("WEBGL_color_buffer_float")))&&!at){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ne>=0&&Ne<=J.width-Ye&&ze>=0&&ze<=J.height-nt&&ne.readPixels(Ne,ze,Ye,nt,Je.convert(De),Je.convert(je),Et)}finally{const Re=T!==null?ee.get(T).__webglFramebuffer:null;le.bindFramebuffer(ne.FRAMEBUFFER,Re)}}},this.copyFramebufferToTexture=function(J,Ne,ze=0){const Ye=Math.pow(2,-ze),nt=Math.floor(Ne.image.width*Ye),Et=Math.floor(Ne.image.height*Ye);de.setTexture2D(Ne,0),ne.copyTexSubImage2D(ne.TEXTURE_2D,ze,0,0,J.x,J.y,nt,Et),le.unbindTexture()},this.copyTextureToTexture=function(J,Ne,ze,Ye=0){const nt=Ne.image.width,Et=Ne.image.height,oe=Je.convert(ze.format),Ae=Je.convert(ze.type);de.setTexture2D(ze,0),ne.pixelStorei(ne.UNPACK_FLIP_Y_WEBGL,ze.flipY),ne.pixelStorei(ne.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ze.premultiplyAlpha),ne.pixelStorei(ne.UNPACK_ALIGNMENT,ze.unpackAlignment),Ne.isDataTexture?ne.texSubImage2D(ne.TEXTURE_2D,Ye,J.x,J.y,nt,Et,oe,Ae,Ne.image.data):Ne.isCompressedTexture?ne.compressedTexSubImage2D(ne.TEXTURE_2D,Ye,J.x,J.y,Ne.mipmaps[0].width,Ne.mipmaps[0].height,oe,Ne.mipmaps[0].data):ne.texSubImage2D(ne.TEXTURE_2D,Ye,J.x,J.y,oe,Ae,Ne.image),Ye===0&&ze.generateMipmaps&&ne.generateMipmap(ne.TEXTURE_2D),le.unbindTexture()},this.copyTextureToTexture3D=function(J,Ne,ze,Ye,nt=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Et=J.max.x-J.min.x+1,oe=J.max.y-J.min.y+1,Ae=J.max.z-J.min.z+1,Re=Je.convert(Ye.format),De=Je.convert(Ye.type);let je;if(Ye.isData3DTexture)de.setTexture3D(Ye,0),je=ne.TEXTURE_3D;else if(Ye.isDataArrayTexture)de.setTexture2DArray(Ye,0),je=ne.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ne.pixelStorei(ne.UNPACK_FLIP_Y_WEBGL,Ye.flipY),ne.pixelStorei(ne.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ye.premultiplyAlpha),ne.pixelStorei(ne.UNPACK_ALIGNMENT,Ye.unpackAlignment);const at=ne.getParameter(ne.UNPACK_ROW_LENGTH),bt=ne.getParameter(ne.UNPACK_IMAGE_HEIGHT),Tt=ne.getParameter(ne.UNPACK_SKIP_PIXELS),Nt=ne.getParameter(ne.UNPACK_SKIP_ROWS),Ft=ne.getParameter(ne.UNPACK_SKIP_IMAGES),jt=ze.isCompressedTexture?ze.mipmaps[0]:ze.image;ne.pixelStorei(ne.UNPACK_ROW_LENGTH,jt.width),ne.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,jt.height),ne.pixelStorei(ne.UNPACK_SKIP_PIXELS,J.min.x),ne.pixelStorei(ne.UNPACK_SKIP_ROWS,J.min.y),ne.pixelStorei(ne.UNPACK_SKIP_IMAGES,J.min.z),ze.isDataTexture||ze.isData3DTexture?ne.texSubImage3D(je,nt,Ne.x,Ne.y,Ne.z,Et,oe,Ae,Re,De,jt.data):ze.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ne.compressedTexSubImage3D(je,nt,Ne.x,Ne.y,Ne.z,Et,oe,Ae,Re,jt.data)):ne.texSubImage3D(je,nt,Ne.x,Ne.y,Ne.z,Et,oe,Ae,Re,De,jt),ne.pixelStorei(ne.UNPACK_ROW_LENGTH,at),ne.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,bt),ne.pixelStorei(ne.UNPACK_SKIP_PIXELS,Tt),ne.pixelStorei(ne.UNPACK_SKIP_ROWS,Nt),ne.pixelStorei(ne.UNPACK_SKIP_IMAGES,Ft),nt===0&&Ye.generateMipmaps&&ne.generateMipmap(je),le.unbindTexture()},this.initTexture=function(J){J.isCubeTexture?de.setTextureCube(J,0):J.isData3DTexture?de.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?de.setTexture2DArray(J,0):de.setTexture2D(J,0),le.unbindTexture()},this.resetState=function(){N=0,C=0,T=null,le.reset(),qe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return yl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===XO?"display-p3":"srgb",n.unpackColorSpace=or.workingColorSpace===x2?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===la?Zh:wQ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Zh?la:tu}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 UUe extends xP{}UUe.prototype.isWebGL1Renderer=!0;class t4{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Xt(e),this.near=n,this.far=r}clone(){return new t4(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class zUe extends Ua{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 BUe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=fP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=zc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=zc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=zc()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Pa=new Le;class ld{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,r=this.data.count;n<r;n++)Pa.fromBufferAttribute(this,n),Pa.applyMatrix4(e),this.setXYZ(n,Pa.x,Pa.y,Pa.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Pa.fromBufferAttribute(this,n),Pa.applyNormalMatrix(e),this.setXYZ(n,Pa.x,Pa.y,Pa.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Pa.fromBufferAttribute(this,n),Pa.transformDirection(e),this.setXYZ(n,Pa.x,Pa.y,Pa.z);return this}setX(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=sr(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=pl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=pl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=pl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=pl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=sr(n,this.array),r=sr(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=sr(n,this.array),r=sr(r,this.array),i=sr(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=sr(n,this.array),r=sr(r,this.array),i=sr(i,this.array),a=sr(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 Os(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 ld(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 HUe extends cs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=oa,d=oa,f,g){super(null,o,l,c,u,d,i,a,f,g),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function $Ue(t,e){return t.z-e.z}function VUe(t,e){return e.z-t.z}class GUe{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 Qm="batchId",Hu=new yr,XV=new yr,WUe=new yr,YV=new yr,JC=new b2,q_=new po,vh=new wl,qx=new Le,ek=new GUe,ya=new zo,K_=[];function qUe(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 KUe extends zo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new Ca,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 HUe(n,e,e,oo,Rc);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,g=new u.constructor(r*d),p=new c.constructor(g,d,f);p.setUsage(c.usage),n.setAttribute(l,p)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new Os(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Qm,new Os(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Qm))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Qm}"`);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===Qm)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 po);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,Hu),this.getBoundingBoxAt(i,q_).applyMatrix4(Hu),n.union(q_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new wl);const e=this._geometryCount,n=this.boundingSphere,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Hu),this.getBoundingSphereAt(i,vh).applyMatrix4(Hu),n.union(vh))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,g=this._active,p=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),g.push(!0);const y=this._geometryCount;this._geometryCount++,WUe.toArray(x,y*16),p.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new po,sphereInitialized:!1,sphere:new wl});const b=this.geometry.getAttribute(Qm);for(let v=0;v<i.vertexCount;v++)b.setX(i.vertexStart+v,y);return b.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const p in r.attributes){if(p===Qm)continue;const x=n.getAttribute(p),y=r.getAttribute(p);qUe(x,y,c);const b=x.itemSize;for(let v=x.count,E=u;v<E;v++){const w=c+v;for(let A=0;A<b;A++)y.setComponent(w,A,0)}y.needsUpdate=!0}if(i){const p=l.indexStart;for(let x=0;x<o.count;x++)a.setX(p+x,c+o.getX(x));for(let x=o.count,y=l.indexCount;x<y;x++)a.setX(p+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],g=n.getAttribute("position");return f.count=i?o.count:g.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,o=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let g=d;l&&(g=l.getX(g)),a.expandByPoint(qx.fromBufferAttribute(c,g))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,q_),q_.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,g=u.start+u.count;f<g;f++){let p=f;l&&(p=l.getX(p)),qx.fromBufferAttribute(c,p),d=Math.max(d,a.center.distanceToSquared(qx))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;ya.material=this.material,ya.geometry.index=c.index,ya.geometry.attributes=c.attributes,ya.geometry.boundingBox===null&&(ya.geometry.boundingBox=new po),ya.geometry.boundingSphere===null&&(ya.geometry.boundingSphere=new wl);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];ya.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,ya.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,ya.geometry.boundingBox),this.getBoundingSphereAt(u,ya.geometry.boundingSphere),ya.raycast(e,K_);for(let f=0,g=K_.length;f<g;f++){const p=K_[f];p.object=this,p.batchId=u,n.push(p)}K_.length=0}ya.material=null,ya.geometry.index=null,ya.geometry.attributes={},ya.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,g=this.perObjectFrustumCulled;g&&(YV.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),JC.setFromProjectionMatrix(YV,e.isWebGPURenderer?mb:yl));let p=0;if(this.sortObjects){XV.copy(this.matrixWorld).invert(),qx.setFromMatrixPosition(r.matrixWorld).applyMatrix4(XV);for(let b=0,v=c.length;b<v;b++)if(c[b]){this.getMatrixAt(b,Hu),this.getBoundingSphereAt(b,vh).applyMatrix4(Hu);let E=!1;if(g&&(E=!JC.intersectsSphere(vh)),!E){const w=qx.distanceTo(vh.center);ek.push(f[b],w)}}const x=ek.list,y=this.customSort;y===null?x.sort(a.transparent?VUe:$Ue):y.call(this,x,r);for(let b=0,v=x.length;b<v;b++){const E=x[b];u[p]=E.start*l,d[p]=E.count,p++}ek.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let b=!1;if(g&&(this.getMatrixAt(x,Hu),this.getBoundingSphereAt(x,vh).applyMatrix4(Hu),b=!JC.intersectsSphere(vh)),!b){const v=f[x];u[p]=v.start*l,d[p]=v.count,p++}}this._multiDrawCount=p,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class py extends Cg{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Xt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const ZV=new Le,QV=new Le,JV=new yr,tk=new ZO,X_=new wl;class XUe extends Ua{constructor(e=new Ca,n=new py){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)ZV.fromBufferAttribute(n,i-1),QV.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=ZV.distanceTo(QV);e.setAttribute("lineDistance",new ni(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),X_.copy(r.boundingSphere),X_.applyMatrix4(i),X_.radius+=a,e.ray.intersectsSphere(X_)===!1)return;JV.copy(i).invert(),tk.copy(e.ray).applyMatrix4(JV);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new Le,d=new Le,f=new Le,g=new Le,p=this.isLineSegments?2:1,x=r.index,b=r.attributes.position;if(x!==null){const v=Math.max(0,o.start),E=Math.min(x.count,o.start+o.count);for(let w=v,A=E-1;w<A;w+=p){const N=x.getX(w),C=x.getX(w+1);if(u.fromBufferAttribute(b,N),d.fromBufferAttribute(b,C),tk.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const O=e.ray.origin.distanceTo(g);O<e.near||O>e.far||n.push({distance:O,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),E=Math.min(b.count,o.start+o.count);for(let w=v,A=E-1;w<A;w+=p){if(u.fromBufferAttribute(b,w),d.fromBufferAttribute(b,w+1),tk.distanceSqToSegment(u,d,g,f)>c)continue;g.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(g);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const e7=new Le,t7=new Le;class v2 extends XUe{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)e7.fromBufferAttribute(n,i),t7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+e7.distanceTo(t7);e.setAttribute("lineDistance",new ni(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class YUe extends Ca{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new Le,a=new Le;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],g=f.start,p=f.count;for(let x=g,y=g+p;x<y;x+=3)for(let b=0;b<3;b++){const v=l.getX(x+b),E=l.getX(x+(b+1)%3);i.fromBufferAttribute(o,v),a.fromBufferAttribute(o,E),n7(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),n7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new ni(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function n7(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 ZUe extends Cg{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Xt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=SQ,this.normalScale=new an(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=qO,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class QUe extends py{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 GQ extends Ua{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Xt(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 nk=new yr,r7=new Le,i7=new Le;class JUe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new an(512,512),this.map=null,this.mapPass=null,this.matrix=new yr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new b2,this._frameExtents=new an(1,1),this._viewportCount=1,this._viewports=[new cr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;r7.setFromMatrixPosition(e.matrixWorld),n.position.copy(r7),i7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(i7),n.updateMatrixWorld(),nk.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(nk),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(nk)}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 a7=new yr,Kx=new Le,rk=new Le;class eze extends JUe{constructor(){super(new Ts(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new an(4,2),this._viewportCount=6,this._viewports=[new cr(2,1,1,1),new cr(0,1,1,1),new cr(3,1,1,1),new cr(1,1,1,1),new cr(3,0,1,1),new cr(1,0,1,1)],this._cubeDirections=[new Le(1,0,0),new Le(-1,0,0),new Le(0,0,1),new Le(0,0,-1),new Le(0,1,0),new Le(0,-1,0)],this._cubeUps=[new Le(0,1,0),new Le(0,1,0),new Le(0,1,0),new Le(0,1,0),new Le(0,0,1),new Le(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()),Kx.setFromMatrixPosition(e.matrixWorld),r.position.copy(Kx),rk.copy(r.position),rk.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(rk),r.updateMatrixWorld(),i.makeTranslation(-Kx.x,-Kx.y,-Kx.z),a7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(a7)}}class tze extends GQ{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 eze}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 nze extends GQ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class rze extends Ca{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 bP extends BUe{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 s7{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(ca(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const o7=new Le,Y_=new Le;class ize{constructor(e=new Le,n=new Le){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){o7.subVectors(e,this.start),Y_.subVectors(this.end,this.start);const r=Y_.dot(Y_);let a=Y_.dot(o7)/r;return n&&(a=ca(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class aze extends v2{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 Ca;i.setAttribute("position",new ni(n,3)),i.setAttribute("color",new ni(r,3));const a=new py({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Xt,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:p2}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=p2);class Sl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Sl.nextNameID=Sl.nextNameID||0,this.$name.id=`lil-gui-name-${++Sl.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class sze extends Sl{constructor(e,n,r){super(e,n,r,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function yP(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 oze={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:yP,toHexString:yP},gb={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},lze={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=gb.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 gb.toHexString(i)}},cze={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=gb.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 gb.toHexString(i)}},uze=[oze,gb,lze,cze];function dze(t){return uze.find(e=>e.match(t))}class hze extends Sl{constructor(e,n,r,i){super(e,n,r,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=dze(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=yP(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 ik extends Sl{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class fze extends Sl{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let E=parseFloat(this.$input.value);isNaN(E)||(this._stepExplicit&&(E=this._snap(E)),this.setValue(this._clamp(E)))},r=E=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},a=E=>{this._inputFocused&&(E.preventDefault(),r(this._step*this._normalizeMouseWheel(E)))};let o=!1,l,c,u,d,f;const g=5,p=E=>{l=E.clientX,c=u=E.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=E=>{if(o){const w=E.clientX-l,A=E.clientY-c;Math.abs(A)>g?(E.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>g&&y()}if(!o){const w=E.clientY-u;f-=w*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",y)},b=()=>{this._inputFocused=!0},v=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",p),this.$input.addEventListener("focus",b),this.$input.addEventListener("blur",v)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(v,E,w,A,N)=>(v-E)/(w-E)*(N-A)+A,n=v=>{const E=this.$slider.getBoundingClientRect();let w=e(v,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=v=>{this._setDraggingStyle(!0),n(v.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=v=>{n(v.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=v=>{v.preventDefault(),this._setDraggingStyle(!0),n(v.touches[0].clientX),o=!1},d=v=>{v.touches.length>1||(this._hasScrollBar?(l=v.touches[0].clientX,c=v.touches[0].clientY,o=!0):u(v),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",g))},f=v=>{if(o){const E=v.touches[0].clientX-l,w=v.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(v):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g))}else v.preventDefault(),n(v.touches[0].clientX)},g=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",g)},p=this._callOnFinishChange.bind(this),x=400;let y;const b=v=>{if(Math.abs(v.deltaX)<Math.abs(v.deltaY)&&this._hasScrollBar)return;v.preventDefault();const w=this._normalizeMouseWheel(v)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(p,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",b,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class mze extends Sl{constructor(e,n,r,i){super(e,n,r,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(i)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class pze extends Sl{constructor(e,n,r){super(e,n,r,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",i=>{i.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const gze=`.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 xze(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 l7=!1;class dS{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"),!l7&&l&&(xze(gze),l7=!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 mze(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new fze(this,e,n,r,i,a);case"boolean":return new sze(this,e,n);case"string":return new pze(this,e,n);case"function":return new ik(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new hze(this,e,n,r)}addFolder(e){const n=new dS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof ik||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 ik)){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 ak(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class n4{constructor(e,n,r,i){this.size=e,this.width=n,this.height=r,this.charLength=i,this.chars=""}static parse(e){const n=e.split(" "),r=n[0],i=r.split("x");return new n4(r,+i[0],+i[1],+n[1])}get src(){return"data:image/jpeg;base64,"+this.chars}get isValid(){return this.chars.length==this.charLength&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(this.chars)}}class r4{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class c7 extends r4{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class $u extends r4{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class u7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class hS{constructor(e){this.lines=[],this.preamble=new u7(-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 c7(e,c,u,o);case"t0":return new $u(e,c,o,0);case"t1":return new $u(e,c,o,1);case"t2":return new $u(e,c,o,2);case"t3":return new $u(e,c,o,3);case"t4":return new $u(e,c,o,4);case"t5":return new $u(e,c,o,5);case"t6":return new $u(e,c,o,6);case"t7":return new $u(e,c,o,7);default:return new r4(e,c,u,o)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,r,i,a)=>{if(i%2==0)return n;let o=a[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof c7){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 u7(this.layers.length,[],r,o))}}this.maxLayer.commands.push(i)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let r;for(const i of e){const a=i.comment;if(!a)continue;const o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=n4.parse(a.slice(o+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}hS.prototype.parseGcode=hS.prototype.parseGCode;const d7={type:"change"},sk={type:"start"},h7={type:"end"},Z_=new ZO,f7=new Yu,bze=Math.cos(70*EQ.DEG2RAD);class yze extends Of{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Le,this.cursor=new Le,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:Dm.ROTATE,MIDDLE:Dm.DOLLY,RIGHT:Dm.PAN},this.touches={ONE:Om.ROTATE,TWO:Om.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(H){H.addEventListener("keydown",_e),this._domElementKeyEvents=H},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(d7),r.update(),a=i.NONE},this.update=(function(){const H=new Le,le=new Ef().setFromUnitVectors(e.up,new Le(0,1,0)),$=le.clone().invert(),ee=new Le,de=new Ef,ke=new Le,we=2*Math.PI;return function(Ee=null){const U=r.object.position;H.copy(U).sub(r.target),H.applyQuaternion(le),l.setFromVector3(H),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})(Ee)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let I=r.minAzimuthAngle,se=r.maxAzimuthAngle;isFinite(I)&&isFinite(se)&&(I<-Math.PI?I+=we:I>Math.PI&&(I-=we),se<-Math.PI?se+=we:se>Math.PI&&(se-=we),l.theta=I<=se?Math.max(I,Math.min(se,l.theta)):l.theta>(I+se)/2?Math.max(I,l.theta):Math.min(se,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=Y(l.radius):l.radius=Y(l.radius*u),H.setFromSpherical(l),H.applyQuaternion($),U.copy(r.target).add(H),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let ye=!1;if(r.zoomToCursor&&C){let Se=null;if(r.object.isPerspectiveCamera){const ve=H.length();Se=Y(ve*u);const Be=ve-Se;r.object.position.addScaledVector(A,Be),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ve=new Le(N.x,N.y,0);ve.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0;const Be=new Le(N.x,N.y,0);Be.unproject(r.object),r.object.position.sub(Be).add(ve),r.object.updateMatrixWorld(),Se=H.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):(Z_.origin.copy(r.object.position),Z_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(Z_.direction))<bze?e.lookAt(r.target):(f7.setFromNormalAndCoplanarPoint(r.object.up,r.target),Z_.intersectPlane(f7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),ye=!0);return u=1,C=!1,!!(ye||ee.distanceToSquared(r.object.position)>o||8*(1-de.dot(r.object.quaternion))>o||ke.distanceToSquared(r.target)>0)&&(r.dispatchEvent(d7),ee.copy(r.object.position),de.copy(r.object.quaternion),ke.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ne),r.domElement.removeEventListener("pointerdown",ue),r.domElement.removeEventListener("pointercancel",fe),r.domElement.removeEventListener("wheel",pe),r.domElement.removeEventListener("pointermove",ce),r.domElement.removeEventListener("pointerup",fe),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 s7,c=new s7;let u=1;const d=new Le,f=new an,g=new an,p=new an,x=new an,y=new an,b=new an,v=new an,E=new an,w=new an,A=new Le,N=new an;let C=!1;const T=[],O={};function k(){return Math.pow(.95,r.zoomSpeed)}function R(H){c.theta-=H}function z(H){c.phi-=H}const D=(function(){const H=new Le;return function(le,$){H.setFromMatrixColumn($,0),H.multiplyScalar(-le),d.add(H)}})(),K=(function(){const H=new Le;return function(le,$){r.screenSpacePanning===!0?H.setFromMatrixColumn($,1):(H.setFromMatrixColumn($,0),H.crossVectors(r.object.up,H)),H.multiplyScalar(le),d.add(H)}})(),P=(function(){const H=new Le;return function(le,$){const ee=r.domElement;if(r.object.isPerspectiveCamera){const de=r.object.position;H.copy(de).sub(r.target);let ke=H.length();ke*=Math.tan(r.object.fov/2*Math.PI/180),D(2*le*ke/ee.clientHeight,r.object.matrix),K(2*$*ke/ee.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(D(le*(r.object.right-r.object.left)/r.object.zoom/ee.clientWidth,r.object.matrix),K($*(r.object.top-r.object.bottom)/r.object.zoom/ee.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function W(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function Z(H){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=H:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G(H){if(!r.zoomToCursor)return;C=!0;const le=r.domElement.getBoundingClientRect(),$=H.clientX-le.left,ee=H.clientY-le.top,de=le.width,ke=le.height;N.x=$/de*2-1,N.y=-ee/ke*2+1,A.set(N.x,N.y,1).unproject(r.object).sub(r.object.position).normalize()}function Y(H){return Math.max(r.minDistance,Math.min(r.maxDistance,H))}function X(H){f.set(H.clientX,H.clientY)}function q(H){x.set(H.clientX,H.clientY)}function F(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const H=.5*(T[0].pageX+T[1].pageX),le=.5*(T[0].pageY+T[1].pageY);f.set(H,le)}}function V(){if(T.length===1)x.set(T[0].pageX,T[0].pageY);else{const H=.5*(T[0].pageX+T[1].pageX),le=.5*(T[0].pageY+T[1].pageY);x.set(H,le)}}function te(){const H=T[0].pageX-T[1].pageX,le=T[0].pageY-T[1].pageY,$=Math.sqrt(H*H+le*le);v.set(0,$)}function re(H){if(T.length==1)g.set(H.pageX,H.pageY);else{const $=B(H),ee=.5*(H.pageX+$.x),de=.5*(H.pageY+$.y);g.set(ee,de)}p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const le=r.domElement;R(2*Math.PI*p.x/le.clientHeight),z(2*Math.PI*p.y/le.clientHeight),f.copy(g)}function ae(H){if(T.length===1)y.set(H.pageX,H.pageY);else{const le=B(H),$=.5*(H.pageX+le.x),ee=.5*(H.pageY+le.y);y.set($,ee)}b.subVectors(y,x).multiplyScalar(r.panSpeed),P(b.x,b.y),x.copy(y)}function he(H){const le=B(H),$=H.pageX-le.x,ee=H.pageY-le.y,de=Math.sqrt($*$+ee*ee);E.set(0,de),w.set(0,Math.pow(E.y/v.y,r.zoomSpeed)),W(w.y),v.copy(E)}function ue(H){r.enabled!==!1&&(T.length===0&&(r.domElement.setPointerCapture(H.pointerId),r.domElement.addEventListener("pointermove",ce),r.domElement.addEventListener("pointerup",fe)),(function(le){T.push(le)})(H),H.pointerType==="touch"?(function(le){switch(He(le),T.length){case 1:switch(r.touches.ONE){case Om.ROTATE:if(r.enableRotate===!1)return;F(),a=i.TOUCH_ROTATE;break;case Om.PAN:if(r.enablePan===!1)return;V(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Om.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&te(),r.enablePan&&V(),a=i.TOUCH_DOLLY_PAN;break;case Om.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&te(),r.enableRotate&&F(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sk)})(H):(function(le){let $;switch(le.button){case 0:$=r.mouseButtons.LEFT;break;case 1:$=r.mouseButtons.MIDDLE;break;case 2:$=r.mouseButtons.RIGHT;break;default:$=-1}switch($){case Dm.DOLLY:if(r.enableZoom===!1)return;(function(ee){G(ee),v.set(ee.clientX,ee.clientY)})(le),a=i.DOLLY;break;case Dm.ROTATE:if(le.ctrlKey||le.metaKey||le.shiftKey){if(r.enablePan===!1)return;q(le),a=i.PAN}else{if(r.enableRotate===!1)return;X(le),a=i.ROTATE}break;case Dm.PAN:if(le.ctrlKey||le.metaKey||le.shiftKey){if(r.enableRotate===!1)return;X(le),a=i.ROTATE}else{if(r.enablePan===!1)return;q(le),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sk)})(H))}function ce(H){r.enabled!==!1&&(H.pointerType==="touch"?(function(le){switch(He(le),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;re(le),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;ae(le),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function($){r.enableZoom&&he($),r.enablePan&&ae($)})(le),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function($){r.enableZoom&&he($),r.enableRotate&&re($)})(le),r.update();break;default:a=i.NONE}})(H):(function(le){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function($){g.set($.clientX,$.clientY),p.subVectors(g,f).multiplyScalar(r.rotateSpeed);const ee=r.domElement;R(2*Math.PI*p.x/ee.clientHeight),z(2*Math.PI*p.y/ee.clientHeight),f.copy(g),r.update()})(le);break;case i.DOLLY:if(r.enableZoom===!1)return;(function($){E.set($.clientX,$.clientY),w.subVectors(E,v),w.y>0?W(k()):w.y<0&&Z(k()),v.copy(E),r.update()})(le);break;case i.PAN:if(r.enablePan===!1)return;(function($){y.set($.clientX,$.clientY),b.subVectors(y,x).multiplyScalar(r.panSpeed),P(b.x,b.y),x.copy(y),r.update()})(le)}})(H))}function fe(H){(function(le){delete O[le.pointerId];for(let $=0;$<T.length;$++)if(T[$].pointerId==le.pointerId)return void T.splice($,1)})(H),T.length===0&&(r.domElement.releasePointerCapture(H.pointerId),r.domElement.removeEventListener("pointermove",ce),r.domElement.removeEventListener("pointerup",fe)),r.dispatchEvent(h7),a=i.NONE}function pe(H){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(H.preventDefault(),r.dispatchEvent(sk),(function(le){G(le),le.deltaY<0?Z(k()):le.deltaY>0&&W(k()),r.update()})(H),r.dispatchEvent(h7))}function _e(H){r.enabled!==!1&&r.enablePan!==!1&&(function(le){let $=!1;switch(le.code){case r.keys.UP:le.ctrlKey||le.metaKey||le.shiftKey?z(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,r.keyPanSpeed),$=!0;break;case r.keys.BOTTOM:le.ctrlKey||le.metaKey||le.shiftKey?z(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,-r.keyPanSpeed),$=!0;break;case r.keys.LEFT:le.ctrlKey||le.metaKey||le.shiftKey?R(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(r.keyPanSpeed,0),$=!0;break;case r.keys.RIGHT:le.ctrlKey||le.metaKey||le.shiftKey?R(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(-r.keyPanSpeed,0),$=!0}$&&(le.preventDefault(),r.update())})(H)}function ne(H){r.enabled!==!1&&H.preventDefault()}function He(H){let le=O[H.pointerId];le===void 0&&(le=new an,O[H.pointerId]=le),le.set(H.pageX,H.pageY)}function B(H){const le=H.pointerId===T[0].pointerId?T[1]:T[0];return O[le.pointerId]}r.domElement.addEventListener("contextmenu",ne),r.domElement.addEventListener("pointerdown",ue),r.domElement.addEventListener("pointercancel",fe),r.domElement.addEventListener("wheel",pe,{passive:!1}),this.update()}}Ct.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new an(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},ns.line={uniforms:QO.merge([Ct.common,Ct.fog,Ct.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 WQ extends Ld{constructor(e){super({type:"LineMaterial",uniforms:QO.clone(ns.line.uniforms),vertexShader:ns.line.vertexShader,fragmentShader:ns.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const m7=new po,Q_=new Le;class qQ extends rze{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new ni([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new ni([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const n=this.attributes.instanceStart,r=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),r.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new bP(n,6,1);return this.setAttribute("instanceStart",new ld(r,3,0)),this.setAttribute("instanceEnd",new ld(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 bP(n,6,1);return this.setAttribute("instanceColorStart",new ld(r,3,0)),this.setAttribute("instanceColorEnd",new ld(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 YUe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new po);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),m7.setFromBufferAttribute(n),this.boundingBox.union(m7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new wl),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Q_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Q_)),Q_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(Q_));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 p7=new Le,g7=new Le,na=new cr,ra=new cr,sl=new cr,ok=new Le,lk=new yr,ia=new ize,x7=new Le,J_=new po,e1=new wl,ol=new cr;let ll,jh;function b7(t,e,n){return ol.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),ol.multiplyScalar(1/ol.w),ol.x=jh/n.width,ol.y=jh/n.height,ol.applyMatrix4(t.projectionMatrixInverse),ol.multiplyScalar(1/ol.w),Math.abs(Math.max(ol.x,ol.y))}class vze extends zo{constructor(e=new qQ,n=new WQ({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)p7.fromBufferAttribute(n,o),g7.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+p7.distanceTo(g7);const a=new bP(i,2,1);return e.setAttribute("instanceDistanceStart",new ld(a,1,0)),e.setAttribute("instanceDistanceEnd",new ld(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;ll=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;jh=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),e1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*jh:u=b7(i,Math.max(i.near,e1.distanceToPoint(ll.origin)),c.resolution),e1.radius+=u,ll.intersectsSphere(e1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),J_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*jh:d=b7(i,Math.max(i.near,J_.distanceToPoint(ll.origin)),c.resolution),J_.expandByScalar(d),ll.intersectsBox(J_)!==!1&&(r?(function(f,g){const p=f.matrixWorld,x=f.geometry,y=x.attributes.instanceStart,b=x.attributes.instanceEnd;for(let v=0,E=Math.min(x.instanceCount,y.count);v<E;v++){ia.start.fromBufferAttribute(y,v),ia.end.fromBufferAttribute(b,v),ia.applyMatrix4(p);const w=new Le,A=new Le;ll.distanceSqToSegment(ia.start,ia.end,A,w),A.distanceTo(w)<.5*jh&&g.push({point:A,pointOnLine:w,distance:ll.origin.distanceTo(A),object:f,face:null,faceIndex:v,uv:null,uv1:null})}})(this,n):(function(f,g,p){const x=g.projectionMatrix,y=f.material.resolution,b=f.matrixWorld,v=f.geometry,E=v.attributes.instanceStart,w=v.attributes.instanceEnd,A=Math.min(v.instanceCount,E.count),N=-g.near;ll.at(1,sl),sl.w=1,sl.applyMatrix4(g.matrixWorldInverse),sl.applyMatrix4(x),sl.multiplyScalar(1/sl.w),sl.x*=y.x/2,sl.y*=y.y/2,sl.z=0,ok.copy(sl),lk.multiplyMatrices(g.matrixWorldInverse,b);for(let C=0,T=A;C<T;C++){if(na.fromBufferAttribute(E,C),ra.fromBufferAttribute(w,C),na.w=1,ra.w=1,na.applyMatrix4(lk),ra.applyMatrix4(lk),na.z>N&&ra.z>N)continue;if(na.z>N){const D=na.z-ra.z,K=(na.z-N)/D;na.lerp(ra,K)}else if(ra.z>N){const D=ra.z-na.z,K=(ra.z-N)/D;ra.lerp(na,K)}na.applyMatrix4(x),ra.applyMatrix4(x),na.multiplyScalar(1/na.w),ra.multiplyScalar(1/ra.w),na.x*=y.x/2,na.y*=y.y/2,ra.x*=y.x/2,ra.y*=y.y/2,ia.start.copy(na),ia.start.z=0,ia.end.copy(ra),ia.end.z=0;const O=ia.closestPointToPointParameter(ok,!0);ia.at(O,x7);const k=EQ.lerp(na.z,ra.z,O),R=k>=-1&&k<=1,z=ok.distanceTo(x7)<.5*jh;if(R&&z){ia.start.fromBufferAttribute(E,C),ia.end.fromBufferAttribute(w,C),ia.start.applyMatrix4(b),ia.end.applyMatrix4(b);const D=new Le,K=new Le;ll.distanceSqToSegment(ia.start,ia.end,K,D),p.push({point:K,pointOnLine:D,distance:ll.origin.distanceTo(K),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class _ze extends v2{constructor(e,n,r,i,a=4473924,o=8947848){a=new Xt(a),o=new Xt(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let g=-1*(e=l*n/2);g<=e;g+=n){c.push(g,0,-1*r,g,0,r);const p=g===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}for(let g=-1*r;g<=r;g+=i){c.push(-1*e,0,g,e,0,g);const p=g===0?a:o;p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3,p.toArray(u,d),d+=3}const f=new Ca;f.setAttribute("position",new ni(c,3)),f.setAttribute("color",new ni(u,3)),super(f,new py({vertexColors:!0,toneMapped:!1}))}}function wze(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new Ca,d=[];return d.push(-o,-l,-c,-o,l,-c,-o,l,-c,o,l,-c,o,l,-c,o,-l,-c,o,-l,-c,-o,-l,-c,-o,-l,c,-o,l,c,-o,l,c,o,l,c,o,l,c,o,-l,c,o,-l,c,-o,-l,c,-o,-l,-c,-o,-l,c,-o,l,-c,-o,l,c,o,l,-c,o,l,c,o,-l,-c,o,-l,c),u.setAttribute("position",new ni(d,3)),u})(t,e,n),a=new v2(i,new QUe({color:new Xt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var y0=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 y0.Panel("FPS","#0ff","#002")),c=n(new y0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new y0.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}};y0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,g=15*o,p=74*o,x=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var b=y.getContext("2d");return b.font="bold "+9*o+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=n,b.fillRect(0,0,l,c),b.fillStyle=e,b.fillText(t,u,d),b.fillRect(f,g,p,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f,g,p,x),{dom:y,update:function(v,E){r=Math.min(r,v),i=Math.max(i,v),b.fillStyle=n,b.globalAlpha=1,b.fillRect(0,0,l,g),b.fillStyle=e,b.fillText(a(v)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),b.drawImage(y,f+o,g,p-o,x,f,g,p-o,x),b.fillRect(f+p-o,g,o,x),b.fillStyle=n,b.globalAlpha=.9,b.fillRect(f+p-o,g,o,a((1-v/E)*x))}}};var Sze=y0;class y7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new dS,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 dS,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 Mze extends Ca{constructor(e=[new Le],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 Le,o=new Le,l=new an,c=[],u=[],d=[],f=[];function g(p){const[x,y,b]=(function(v){const E=e[v],w=new Le,A=new Le,N=new Le,C=new Le;w.copy(E).sub(e[v-1]||E).normalize().add((e[v+1]||E).clone().sub(E).normalize()).normalize();let T=Number.MAX_VALUE;const O=Math.abs(w.x),k=Math.abs(w.y),R=Math.abs(w.z);return O<=T&&(T=O,A.set(1,0,0)),k<=T&&(T=k,A.set(0,1,0)),R<=T&&A.set(0,0,1),C.crossVectors(w,A).normalize(),A.crossVectors(w,C),N.crossVectors(w,A),[E,A,N]})(p);for(let v=0;v<=i;v++){const E=v/i*Math.PI*2,w=Math.sin(E),A=-Math.cos(E);o.x=A*y.x+w*b.x,o.y=A*y.y+w*b.y,o.z=A*y.z+w*b.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=x.x+n*o.x*.5,a.y=x.y+n*o.y*.5,a.z=x.z+r*o.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let p=0;p<e.length;p++)g(p);g(closed===!1?e.length-1:0),(function(){for(let p=0;p<e.length;p++)for(let x=0;x<=i;x++)l.x=p/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let p=1;p<e.length;p++)for(let x=1;x<=i;x++){const y=(i+1)*(p-1)+(x-1),b=(i+1)*p+(x-1),v=(i+1)*p+x,E=(i+1)*(p-1)+x;f.push(y,b,E),f.push(b,v,E)}})()})(),this.setIndex(f),this.setAttribute("position",new ni(c,3)),this.setAttribute("normal",new ni(u,3)),this.setAttribute("uv",new ni(d,2))}}class v0{static get initial(){const e=new v0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const ck={h:0,s:0,l:0};class Np{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=v0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Np.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Xt(14737632),this._travelColor=new Xt(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 hS(this.minLayerThreshold),this.scene=new zUe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Xt(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 Sze:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Xt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Xt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Xt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[p,x]of Object.entries(e.toolColors))this._toolColors[parseInt(p)]=new Xt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+p2),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 xP({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 xP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,p.appendChild(this.canvas)}this.camera=new Ts(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,g=.8*f;this.scene.fog=new t4(this._backgroundColor,g,f),this.resize(),this.controls=new yze(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 Xt(r)}else this._extrusionColor=new Xt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Np.defaultExtrusionColor:this._extrusionColor instanceof Xt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Np.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Xt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Xt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Xt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Xt(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 aze(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 nze(13421772,.3*Math.PI),n=new tze(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 a0;return n.name=e,n.quaternion.setFromEuler(new fy(-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=v0.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 ak(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const g of d.commands)if(g.gcode!="g20"){if(g.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const p=g;this.state.t=p.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(g.gcode)>-1){const p=g,x={x:(n=p.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=p.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=p.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=p.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=p.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=p.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=p.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=p.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(g.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(g.gcode=="g2"||g.gcode=="g3"||g.gcode=="g02"||g.gcode=="g03"?this.addArcSegment(f,this.state,x,y,g.gcode=="g2"||g.gcode=="g02"):this.addLineSegment(f,this.state,x,y))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(ck),a=new Xt().setHSL(ck.h,ck.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 _ze(this.buildVolume.x,10,this.buildVolume.y,10));const e=wze(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 hS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=v0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,g=r.z;let p=r.r,x=r.i,y=r.j;if(p){const W=d-l,Z=f-c,G=Math.sqrt(Math.pow(W/2,2)+Math.pow(Z/2,2));p=Math.max(p,G);const Y=Math.pow(W,2)+Math.pow(Z,2),X=Math.pow(p,2)-Y/4;let q=Math.sqrt(X/Y);(a&&p<0||!a&&p>0)&&(q=-q),x=W/2+Z*q,y=Z/2-W*q}const b=l==d&&c==f,v=l+x,E=c+y,w=Math.sqrt(x*x+y*y),A=Math.atan2(-y,-x),N=Math.atan2(f-E,d-v);let C;b?C=2*Math.PI:(C=a?A-N:N-A,C<0&&(C+=2*Math.PI));let T=w*C/1.8;this.inches&&(T*=25),T<1&&(T=1);let O=C/T;O*=a?-1:1;const k=[];k.push({x:l,y:c,z:u});const R=(u-g)/T;let z=l,D=c,K=u,P=A;for(let W=0;W<T-1;W++)P+=O,z=v+w*Math.cos(P),D=E+w*Math.sin(P),K+=R,k.push({x:z,y:D,z:K});k.push({x:r.x,y:r.y,z:r.z});for(let W=0;W<k.length-1;W++)o.push(k[W].x,k[W].y,k[W].z,k[W+1].x,k[W+1].y,k[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 Ca;i.setAttribute("position",new ni(e,3)),this.disposables.push(i);const a=new py({color:n});this.disposables.push(a);const o=new v2(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 Le(l[0],l[1],l[2]),u=new Le(l[3],l[4],l[5]),d=new Le(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 Mze(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 qQ;this.disposables.push(i);const a=new WQ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new vze(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=>ak(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 ZUe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new KUe(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 ak(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 y7(this):typeof this.devMode=="object"&&(this.devGui=new y7(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())}}Np.defaultExtrusionColor=new Xt("hotpink");function Eze({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=S.useRef(null),a=S.useRef(null),o=S.useRef(null),l=S.useRef(!1),[c,u]=S.useState(!0),[d,f]=S.useState(null),[g,p]=S.useState(!1),[x,y]=S.useState(0),[b,v]=S.useState(0),E=S.useMemo(()=>JSON.stringify(n),[n]);S.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const N=i.current,C=N.parentElement?.getBoundingClientRect();C&&(N.width=C.width,N.height=C.height);const T=n&&n.length>1,O=n?.[0]||"#00ae42",k=new Np({canvas:N,buildVolume:e,backgroundColor:1710618,extrusionColor:T?n:O,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=k,fetch(t).then(async z=>{if(!z.ok)throw z.status===404&&(await z.json().catch(()=>({}))).detail?.includes("sliced")?(p(!0),new Error("not_sliced")):new Error("Failed to load G-code");return z.text()}).then(z=>{const D=new Set,K=/^(\s*)T(\d+)(\s*;.*)?$/gim;let P;for(;(P=K.exec(z))!==null;){const q=parseInt(P[2],10);q<=15&&D.add(q)}const W=new Map,Z=Array.from(D).sort((q,F)=>q-F);Z.forEach((q,F)=>{W.set(q,F%8)});const G=[];Z.forEach((q,F)=>{const V=n?.[q]||"#00ae42";G[F%8]=V});const Y=z.split(`
- `).map(q=>{const F=q.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(F){const V=parseInt(F[2],10);if(V>15)return`; FILTERED: ${q.trim()}`;const te=W.get(V)??0;return`${F[1]}T${te}${F[3]||""}`}return q}).join(`
- `);G.length>0&&(k.extrusionColor=G),k.processGCode(Y);const X=k.layers?.length||0;v(X),y(X),k.render(),u(!1)}).catch(z=>{z.message!=="not_sliced"&&f(z.message),u(!1)});const R=()=>{if(N.parentElement&&a.current){const z=N.parentElement.getBoundingClientRect();N.width=z.width,N.height=z.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,E]);const w=S.useCallback(N=>{if(!a.current)return;const C=Math.max(1,Math.min(N,b));y(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[b]),A=N=>{w(parseInt(N.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(gt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),g&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center max-w-sm px-4",children:[s.jsx(cce,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),s.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer."})]})}),d&&!g&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("div",{className:"text-center text-red-400",children:s.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!g&&b>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Md,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>w(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(of,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:b,value:x,onChange:A,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>w(x+1),disabled:x>=b,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Zo,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",b]})]})})]})}function KQ({archiveId:t,title:e,onClose:n}){const[r,i]=S.useState(null),[a,o]=S.useState(null),[l,c]=S.useState(!0);S.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),S.useEffect(()=>{be.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}${be.getArchiveForSlicer(t,d)}`;Ec(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(qr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(zt,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(vl,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(Ile,{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(gt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(wOe,{url:a.has_source?be.getSource3mfDownloadUrl(t):be.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(Eze,{gcodeUrl:be.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 v7={"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 Nze(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,g=r/255,p=i/255;a===f?c=((g-p)/d+(g<p?6:0))/6:a===g?c=((p-f)/d+2)/6:c=((f-g)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function Bc(t){const e=t.replace("#","").toLowerCase().substring(0,6);return v7[e]?v7[e]:Nze(t)}const Aze={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1};function XQ({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const i=ln(),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(!1),[f,g]=S.useState(Aze),[p,x]=S.useState({});S.useEffect(()=>{x({})},[a]),S.useEffect(()=>{const D=K=>{K.key==="Escape"&&n()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[n]);const{data:y,isLoading:b}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:v}=ht({queryKey:["archive-filaments",t],queryFn:()=>be.getArchiveFilamentRequirements(t)}),{data:E}=ht({queryKey:["printer-status",a],queryFn:()=>be.getPrinterStatus(a),enabled:!!a}),w=xt({mutationFn:()=>{if(!a)throw new Error("No printer selected");return be.reprintArchive(t,a,{ams_mapping:R,...f})},onSuccess:()=>{r(),n()}}),A=y?.filter(D=>D.is_active)||[],N=D=>D?`#${D.replace("#","").substring(0,6)}`:"#808080",C=(D,K,P,W)=>{const Z=String.fromCharCode(65+(D>=128?D-128:D));return P?`HT-${Z}`:`AMS-${Z} Slot ${K+1}`},T=(D,K,P)=>D*4+K,O=S.useMemo(()=>{const D=[];if(E?.ams?.forEach(K=>{const P=K.tray.length===1;K.tray.forEach(W=>{if(W.tray_type){const Z=N(W.tray_color);D.push({type:W.tray_type,color:Z,colorName:Bc(Z),amsId:K.id,trayId:W.id,isHt:P,isExternal:!1,label:C(K.id,W.id,P),globalTrayId:T(K.id,W.id)})}})}),E?.vt_tray?.tray_type){const K=N(E.vt_tray.tray_color);D.push({type:E.vt_tray.tray_type,color:K,colorName:Bc(K),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return D},[E]),k=S.useMemo(()=>{if(!v?.filaments||v.filaments.length===0)return[];const D=W=>W?W.replace("#","").toLowerCase().substring(0,6):"",K=(W,Z,G=40)=>{const Y=D(W),X=D(Z);if(!Y||!X||Y.length<6||X.length<6)return!1;const q=parseInt(Y.substring(0,2),16),F=parseInt(Y.substring(2,4),16),V=parseInt(Y.substring(4,6),16),te=parseInt(X.substring(0,2),16),re=parseInt(X.substring(2,4),16),ae=parseInt(X.substring(4,6),16);return Math.abs(q-te)<=G&&Math.abs(F-re)<=G&&Math.abs(V-ae)<=G},P=new Set(Object.values(p));return v.filaments.map(W=>{const Z=W.slot_id||0;if(Z>0&&p[Z]!==void 0){const ae=p[Z],he=O.find(ue=>ue.globalTrayId===ae);if(he){const ue=he.type?.toUpperCase()===W.type?.toUpperCase(),ce=D(he.color)===D(W.color)||K(he.color,W.color);let fe;return ue&&ce?fe="match":ue?fe="type_only":fe="mismatch",{...W,loaded:he,hasFilament:!0,typeMatch:ue,colorMatch:ce,status:fe,isManual:!0}}}const G=O.find(ae=>!P.has(ae.globalTrayId)&&ae.type?.toUpperCase()===W.type?.toUpperCase()&&D(ae.color)===D(W.color)),Y=!G&&O.find(ae=>!P.has(ae.globalTrayId)&&ae.type?.toUpperCase()===W.type?.toUpperCase()&&K(ae.color,W.color)),X=!G&&!Y&&O.find(ae=>!P.has(ae.globalTrayId)&&ae.type?.toUpperCase()===W.type?.toUpperCase()),q=G||Y||X||void 0;q&&P.add(q.globalTrayId);const F=!!q,V=F,te=!!G||!!Y;let re;return G||Y?re="match":X?re="type_only":re="mismatch",{...W,loaded:q,hasFilament:F,typeMatch:V,colorMatch:te,status:re,isManual:!1}})},[v,O,p]),R=S.useMemo(()=>{if(k.length===0)return;const D=Math.max(...k.map(P=>P.slot_id||0));if(D<=0)return;const K=new Array(D).fill(-1);return k.forEach(P=>{P.slot_id&&P.slot_id>0&&(K[P.slot_id-1]=P.loaded?.globalTrayId??-1)}),K},[k]),z=k.some(D=>D.status==="mismatch");return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:s.jsx(vt,{className:"w-full max-w-lg",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",s.jsx("span",{className:"text-white",children:e})," to a printer"]}),b?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(gt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):A.length===0?s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):s.jsx("div",{className:"space-y-2 mb-6",children:A.map(D=>s.jsxs("button",{onClick:()=>o(D.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${a===D.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${a===D.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Ei,{className:`w-5 h-5 ${a===D.id?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-white font-medium",children:D.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[D.model||"Unknown model"," • ",D.ip_address]})]})]},D.id))}),a&&k.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Filament Check"}),s.jsxs("button",{onClick:async()=>{if(a){c(!0);try{await be.refreshPrinterStatus(a),await new Promise(D=>setTimeout(D,500)),await i.refetchQueries({queryKey:["printer-status",a]})}finally{c(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Re-read AMS status from printer",disabled:l,children:[s.jsx(Dr,{className:`w-3 h-3 ${l?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]}),z?s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(Cn,{className:"w-3 h-3"}),"Type not found"]}):k.some(D=>D.status==="type_only")?s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(Cn,{className:"w-3 h-3"}),"Color mismatch"]}):s.jsxs("span",{className:"text-xs text-bambu-green flex items-center gap-1",children:[s.jsx(ds,{className:"w-3 h-3"}),"Ready"]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 space-y-2 text-xs",children:k.map((D,K)=>s.jsxs("div",{className:"grid items-center gap-2",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${D.type} - ${Bc(D.color)}`,children:s.jsx(z0,{className:"w-3 h-3 flex-shrink-0",fill:D.color,stroke:D.color})}),s.jsxs("span",{className:"text-white truncate",children:[D.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",D.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:D.loaded?.globalTrayId??"",onChange:P=>{const W=D.slot_id||0;if(W>0){const Z=P.target.value;x(Z===""?G=>{const Y={...G};return delete Y[W],Y}:G=>({...G,[W]:parseInt(Z,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${D.status==="match"?"border-bambu-green/50 text-bambu-green":D.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${D.isManual?"ring-1 ring-blue-400/50":""}`,title:D.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),O.map(P=>s.jsxs("option",{value:P.globalTrayId,className:"bg-bambu-dark text-white",children:[P.label,": ",P.type," (",P.colorName,")"]},P.globalTrayId))]}),D.status==="match"?s.jsx(ds,{className:"w-3 h-3 text-bambu-green"}):D.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},K))}),z&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]}),a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{onClick:()=>d(!u),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(pM,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),u?s.jsx(zd,{className:"w-4 h-4 ml-auto"}):s.jsx(Aa,{className:"w-4 h-4 ml-auto"})]}),u&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[{key:"bed_levelling",label:"Bed Levelling",desc:"Auto-level bed before print"},{key:"flow_cali",label:"Flow Calibration",desc:"Calibrate extrusion flow"},{key:"vibration_cali",label:"Vibration Calibration",desc:"Reduce ringing artifacts"},{key:"layer_inspect",label:"First Layer Inspection",desc:"AI inspection of first layer"},{key:"timelapse",label:"Timelapse",desc:"Record timelapse video"}].map(({key:D,label:K,desc:P})=>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:K}),s.jsx("p",{className:"text-xs text-bambu-gray",children:P})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${f[D]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>g(W=>({...W,[D]:!W[D]})),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${f[D]?"translate-x-5":"translate-x-0.5"}`})})]},D))})]}),w.isError&&s.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:w.error.message||"Failed to start print"}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Te,{onClick:()=>w.mutate(),disabled:!a||w.isPending,className:"flex-1",children:w.isPending?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ei,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function Tze({onClose:t,initialFiles:e}){const n=ln(),{showToast:r}=dr(),i=S.useRef(null),[a,o]=S.useState(()=>e?.filter(T=>T.name.endsWith(".3mf")).map(T=>({file:T,status:"pending"}))||[]),[l,c]=S.useState(!1),[u,d]=S.useState(),[f,g]=S.useState(null);S.useEffect(()=>{const T=O=>{O.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]);const{data:p}=ht({queryKey:["printers"],queryFn:be.getPrinters}),x=xt({mutationFn:T=>be.uploadArchivesBulk(T,u),onSuccess:T=>{g(T),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(O=>O.map(k=>{const R=T.results.find(D=>D.filename===k.file.name),z=T.errors.find(D=>D.filename===k.file.name);return R?{...k,status:"success",archiveId:R.id}:z?{...k,status:"error",error:z.error}:k})),T.failed===0?r(`${T.uploaded} file${T.uploaded!==1?"s":""} uploaded`):T.uploaded===0?r(`Failed to upload ${T.failed} file${T.failed!==1?"s":""}`,"error"):r(`${T.uploaded} uploaded, ${T.failed} failed`,"warning")},onError:()=>{o(T=>T.map(O=>({...O,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),y=S.useCallback(T=>{T.preventDefault(),c(!0)},[]),b=S.useCallback(T=>{T.preventDefault(),c(!1)},[]),v=S.useCallback(T=>{T.preventDefault(),c(!1);const O=Array.from(T.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));O.length>0&&o(k=>[...k,...O.map(R=>({file:R,status:"pending"}))])},[]),E=S.useCallback(T=>{const O=Array.from(T.target.files||[]).filter(k=>k.name.endsWith(".3mf"));O.length>0&&o(k=>[...k,...O.map(R=>({file:R,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=S.useCallback(T=>{o(O=>O.filter((k,R)=>R!==T))},[]),A=()=>{if(a.length===0)return;const T=a.filter(O=>O.status==="pending");T.length!==0&&(o(O=>O.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),x.mutate(T.map(O=>O.file)))},N=a.filter(T=>T.status==="pending").length,C=x.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(vt,{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(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:y,onDragLeave:b,onDrop:v,children:[s.jsx(qi,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),s.jsx(Te,{variant:"secondary",onClick:()=>i.current?.click(),disabled:C,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),s.jsxs("div",{className:"px-4 pb-4",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u||"",onChange:T=>d(T.target.value?Number(T.target.value):void 0),disabled:C,children:[s.jsx("option",{value:"",children:"No printer"}),p?.map(T=>s.jsx("option",{value:T.id,children:T.name},T.id))]})]}),a.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:a.map((T,O)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(yR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:T.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(T.file.size/(1024*1024)).toFixed(1)," MB"]}),T.status==="pending"&&s.jsx("button",{onClick:()=>w(O),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:C,children:s.jsx(zt,{className:"w-4 h-4"})}),T.status==="uploading"&&s.jsx(gt,{className:"w-4 h-4 text-bambu-green animate-spin"}),T.status==="success"&&s.jsx(kr,{className:"w-4 h-4 text-bambu-green"}),T.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:T.error}),s.jsx(Na,{className:"w-4 h-4 text-red-400"})]})]},`${T.file.name}-${O}`))})}),f&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Te,{onClick:A,disabled:N===0||C,className:"flex-1",children:C?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(qi,{className:"w-4 h-4"}),"Upload ",N>0&&`(${N})`]})})]})]})})})}const Cze=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],kze=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function YQ({archive:t,onClose:e,existingTags:n=[]}){S.useEffect(()=>{const ae=he=>{he.key==="Escape"&&e()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[e]);const r=ln(),[i,a]=S.useState(t.print_name||""),[o,l]=S.useState(t.printer_id),[c,u]=S.useState(t.project_id??null),[d,f]=S.useState(t.notes||""),[g,p]=S.useState(t.tags||""),[x,y]=S.useState(t.failure_reason||""),[b,v]=S.useState(t.status),[E,w]=S.useState(t.quantity??1),[A,N]=S.useState(t.photos||[]),[C,T]=S.useState(!1),[O,k]=S.useState(!1),R=S.useRef(null),z=S.useRef(null),D=S.useRef(null),{data:K}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:P}=ht({queryKey:["projects"],queryFn:()=>be.getProjects()}),{data:W}=ht({queryKey:["archives"],queryFn:()=>be.getArchives(void 0,1e3,0),enabled:n.length===0}),Z=n.length>0?n:[...new Set(W?.flatMap(ae=>ae.tags?.split(",").map(he=>he.trim())||[]).filter(Boolean)||[])].sort(),G=g.split(",").map(ae=>ae.trim()).filter(Boolean),Y=Z.filter(ae=>!G.includes(ae)),X=ae=>{if(!G.includes(ae)){const he=[...G,ae].join(", ");p(he)}D.current!==null&&clearTimeout(D.current),R.current?.focus()},q=ae=>{const he=G.filter(ue=>ue!==ae).join(", ");p(he)},F=xt({mutationFn:ae=>be.updateArchive(t.id,ae),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),V=async ae=>{const he=ae.target.files?.[0];if(he){T(!0);try{const ue=await be.uploadArchivePhoto(t.id,he);N(ue.photos),r.invalidateQueries({queryKey:["archives"]})}catch(ue){console.error("Failed to upload photo:",ue)}finally{T(!1),z.current&&(z.current.value="")}}},te=async ae=>{try{const he=await be.deleteArchivePhoto(t.id,ae);N(he.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(he){console.error("Failed to delete photo:",he)}},re=ae=>{ae.preventDefault();const he={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:g||void 0,quantity:E};b!==t.status&&(he.status=b),b==="failed"||b==="aborted"?he.failure_reason=x||void 0:(t.status==="failed"||t.status==="aborted")&&(he.failure_reason=null),F.mutate(he)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:ae=>ae.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:re,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:ae=>a(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsxs("select",{value:o??"",onChange:ae=>l(ae.target.value?Number(ae.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No printer"}),K?.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(ha,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:ae=>u(ae.target.value?Number(ae.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No project"}),P?.map(ae=>s.jsx("option",{value:ae.id,children:ae.name},ae.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Rce,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:E,onChange:ae=>w(Math.max(1,parseInt(ae.target.value)||1)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of items produced in this print job"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:ae=>f(ae.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),G.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:G.map(ae=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[s.jsx(Dp,{className:"w-3 h-3"}),ae,s.jsx("button",{type:"button",onClick:()=>q(ae),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-3 h-3"})})]},ae))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:R,type:"text",value:g,onChange:ae=>p(ae.target.value),onFocus:()=>{D.current!==null&&clearTimeout(D.current),k(!0)},onBlur:()=>{D.current=window.setTimeout(()=>k(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:G.length>0?"Add more tags...":"Add tags..."}),O&&Y.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:Y.map(ae=>s.jsx("button",{type:"button",onClick:()=>X(ae),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:ae},ae))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:b,onChange:ae=>{v(ae.target.value),ae.target.value==="completed"&&y("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:kze.map(ae=>s.jsx("option",{value:ae.value,children:ae.label},ae.value))})]}),(b==="failed"||b==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),s.jsxs("select",{value:x,onChange:ae=>y(ae.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"Select reason..."}),Cze.map(ae=>s.jsx("option",{value:ae,children:ae},ae))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(jp,{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(ae=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:be.getArchivePhotoUrl(t.id,ae),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>te(ae),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(vn,{className:"w-3 h-3 text-white"})})]},ae)),s.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[s.jsx("input",{ref:z,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:V,className:"hidden",disabled:C}),C?s.jsx(gt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(mr,{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(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:F.isPending,className:"flex-1",children:[s.jsx(js,{className:"w-4 h-4"}),F.isPending?"Saving...":"Save"]})]})]})]})})}function ZQ({x:t,y:e,items:n,onClose:r}){const i=S.useRef(null),[a,o]=S.useState(null),l=S.useRef(null),[c,u]=S.useState({x:t,y:e,visible:!1}),[d,f]=S.useState(!1),[g,p]=S.useState({});S.useEffect(()=>{const b=w=>{i.current&&!i.current.contains(w.target)&&r()},v=w=>{w.key==="Escape"&&r()},E=()=>{r()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),document.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v),document.removeEventListener("scroll",E,!0),l.current&&clearTimeout(l.current)}},[r]),S.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const b=i.current.getBoundingClientRect(),v=window.innerWidth,E=window.innerHeight,w=8;let A=t,N=e;t+b.width>v-w&&(A=Math.max(w,v-b.width-w)),A<w&&(A=w),e+b.height>E-w&&(N=Math.max(w,E-b.height-w)),N<w&&(N=w);const C=180,T=v-A-b.width,O=A;f(T<C&&O>C),u({x:A,y:N,visible:!0})}},[t,e]);const x=(b,v)=>{l.current&&(clearTimeout(l.current),l.current=null);const E=v.getBoundingClientRect(),w=window.innerHeight,A=300,T=w-E.top-8<A&&E.top>A;p(O=>({...O,[b]:T?"bottom":"top"})),o(b)},y=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((b,v)=>{if(b.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},v);const E=b.submenu&&b.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:w=>E&&x(v,w.currentTarget),onMouseLeave:()=>E&&y(),children:[s.jsxs("button",{onMouseEnter:w=>E&&x(v,w.currentTarget.parentElement),onClick:()=>{E?o(a===v?null:v):b.disabled||(b.onClick(),r())},disabled:b.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${b.disabled?"text-bambu-gray cursor-not-allowed":b.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${E&&a===v?"bg-bambu-dark-tertiary":""}`,children:[b.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:b.icon}),s.jsx("span",{className:"flex-1",children:b.label}),E&&s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray"})]}),E&&a===v&&s.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${g[v]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:b.submenu.map((w,A)=>s.jsxs("button",{onClick:()=>{w.disabled||(w.onClick(),r())},disabled:w.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${w.disabled?"text-bambu-gray cursor-not-allowed":w.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[w.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:w.icon}),w.label]},A))})]},v)})})}function jze({selectedIds:t,existingTags:e,onClose:n}){const r=ln(),{showToast:i}=dr(),[a,o]=S.useState(""),[l,c]=S.useState(new Set),[u,d]=S.useState("add");S.useEffect(()=>{const y=b=>{b.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const f=xt({mutationFn:async()=>{const y=Array.from(l);let b=0;for(const v of t)try{const E=await be.getArchive(v),w=E.tags?E.tags.split(",").map(N=>N.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...w,...y])]:A=w.filter(N=>!l.has(N)),await be.updateArchive(v,{tags:A.join(", ")}),b++}catch(E){throw console.error(`Failed to update archive ${v}:`,E),new Error(`Failed on archive ${v}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:b,mode:u,tags:y}},onSuccess:({count:y,mode:b,tags:v})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${b==="add"?"Added":"Removed"} ${v.length} tag${v.length!==1?"s":""} ${b==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),g=y=>{c(b=>{const v=new Set(b);return v.has(y)?v.delete(y):v.add(y),v})},p=()=>{a.trim()&&!l.has(a.trim())&&(c(y=>new Set([...y,a.trim()])),o(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),p())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(vt,{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(Dp,{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(zt,{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(Te,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Te,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:y=>o(y.target.value),onKeyDown:x}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:p,disabled:!a.trim(),children:s.jsx(mr,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(y=>s.jsx("button",{onClick:()=>g(y),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(y)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:y},y))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(y=>s.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[y,s.jsx("button",{onClick:()=>g(y),className:"hover:opacity-70",children:s.jsx(zt,{className:"w-3 h-3"})})]},y))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Te,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Dp,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function Pze({selectedIds:t,onClose:e}){const n=ln(),{showToast:r}=dr(),{data:i,isLoading:a}=ht({queryKey:["projects"],queryFn:()=>be.getProjects()});S.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=xt({mutationFn:async d=>(await be.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(g=>g.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=xt({mutationFn:async()=>{for(const d of t)await be.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(vt,{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(ha,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(zt,{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(gt,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:s.jsx(Sa,{className:"w-4 h-4 text-red-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&s.jsx(gt,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&s.jsxs("div",{className:"flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>s.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:s.jsx(ha,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:d.name}),s.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&s.jsx(gt,{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(Te,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function Rze(t,e){return new Date(t,e+1,0).getDate()}function Dze(t,e){return new Date(t,e,1).getDay()}const Oze=["January","February","March","April","May","June","July","August","September","October","November","December"],Lze=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ize({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=S.useState(r.getMonth()),[o,l]=S.useState(r.getFullYear()),[c,u]=S.useState(null),[d,f]=S.useState(null),g=S.useMemo(()=>{const N=new Map;return t.forEach(C=>{const T=di(C.completed_at||C.created_at)||new Date,O=`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`,k=N.get(O)||[];k.push(C),N.set(O,k)}),N},[t]),p=Rze(o,i),x=Dze(o,i),y=()=>{i===0?(a(11),l(o-1)):a(i-1)},b=()=>{i===11?(a(0),l(o+1)):a(i+1)},v=()=>{a(r.getMonth()),l(r.getFullYear())},E=[];for(let N=0;N<x;N++)E.push(null);for(let N=1;N<=p;N++)E.push(N);const w=c?g.get(c)||[]:[],A=N=>{N!==c&&f(null),u(N)};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(of,{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:[Oze[i]," ",o]}),s.jsx("button",{onClick:v,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Zo,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:Lze.map(N=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:N},N))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:E.map((N,C)=>{if(N===null)return s.jsx("div",{className:"aspect-square"},`empty-${C}`);const T=`${o}-${String(i+1).padStart(2,"0")}-${String(N).padStart(2,"0")}`,O=g.get(T)||[],k=O.length>0,R=N===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),z=T===c,D=O.filter(P=>P.status==="completed").length,K=O.filter(P=>P.status==="failed").length;return s.jsxs("button",{onClick:()=>A(z?null:T),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${z?"bg-bambu-green text-white":R?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":k?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[s.jsx("span",{className:`text-sm font-medium ${R&&!z?"text-bambu-green":""}`,children:N}),k&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${K>0&&D===0?"bg-red-400":K>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:O.length})]})]},N)})}),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(N=>{const C=new Date(N.completed_at||N.created_at);return C.getMonth()===i&&C.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(N=>{const C=new Date(N.completed_at||N.created_at);return C.getMonth()===i&&C.getFullYear()===o&&N.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(N=>{const C=new Date(N.completed_at||N.created_at);return C.getMonth()===i&&C.getFullYear()===o&&N.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),w.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:w.map(N=>{const C=N.id===d||N.id===n;return s.jsxs("button",{onClick:()=>{f(N.id),e?.(N)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${C?"":"hover:bg-bambu-dark-tertiary"}`,style:C?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[N.thumbnail_path?s.jsx("img",{src:be.getArchiveThumbnail(N.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:N.print_name||N.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:N.status==="failed"?"text-red-400":"text-green-400",children:N.status==="failed"?"Failed":"Completed"}),N.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:N.filament_color.split(",").map((T,O)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:T}},O))})]})]})]},N.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 QQ({archiveId:t,archiveName:e,onClose:n}){const r=be.getArchiveQRCodeUrl(t,300);S.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{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(Te,{onClick:i,className:"w-full",children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function JQ({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=S.useState(0),[l,c]=S.useState(!1);if(S.useEffect(()=>{const p=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(y=>Math.max(0,y-1)),x.key==="ArrowRight"&&o(y=>Math.min(n.length-1,y+1))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n.length]),S.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=be.getArchivePhotoUrl(t,u),f=()=>{const p=document.createElement("a");p.href=d,p.download=`${e}_photo_${a+1}.jpg`,p.click()},g=()=>{i&&c(!0)};return s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:p=>p.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Te,{variant:"secondary",size:"sm",onClick:g,className:"text-red-400 hover:text-red-300",children:s.jsx(vn,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{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(of,{className:"w-8 h-8 text-white"})}),s.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&s.jsx("button",{onClick:()=>o(p=>p+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Zo,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((p,x)=>s.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:be.getArchivePhotoUrl(t,p),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},p))})]}),l&&s.jsx(Qn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function sa(t){this.content=t}sa.prototype={constructor:sa,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new sa(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new sa(n)},addToStart:function(t,e){return new sa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new sa(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new sa(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=sa.from(t),t.size?new sa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=sa.from(t),t.size?new sa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=sa.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};sa.from=function(t){if(t instanceof sa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new sa(e)};function eJ(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=eJ(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function tJ(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=tJ(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class yt{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 yt(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 yt(r,i)}cutByIndex(e,n){return e==n?yt.empty:e==0&&n==this.content.length?this:new yt(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 yt(i,a)}addToStart(e){return new yt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new yt(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 eJ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return tJ(this,e,n,r)}findIndex(e){if(e==0)return t1(0,e);if(e==this.size)return t1(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?t1(n+1,a):t1(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 yt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new yt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return yt.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 yt(n||e,r)}static from(e){if(!e)return yt.empty;if(e instanceof yt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new yt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}yt.empty=new yt([],0);const uk={index:0,offset:0};function t1(t,e){return uk.index=t,uk.offset=e,uk}function fS(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(!fS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!fS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let pr=class vP{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&&fS(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 vP.none;if(e instanceof vP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};pr.none=[];class mS extends Error{}class Dt{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=rJ(this.content,e+this.openStart,n);return r&&new Dt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Dt(nJ(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 Dt.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 Dt(yt.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 Dt(e,r,i)}}Dt.empty=new Dt(yt.empty,0,0);function nJ(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(nJ(a.content,e-i-1,n-i-1)))}function rJ(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=rJ(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function Fze(t,e,n){if(n.openStart>t.depth)throw new mS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new mS("Inconsistent open depths");return iJ(t,e,n,0)}function iJ(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=iJ(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 Jh(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Uze(n,t);return Jh(a,sJ(t,o,l,e,r))}else return Jh(a,pS(t,e,r))}function aJ(t,e){if(!e.type.compatibleContent(t.type))throw new mS("Cannot join "+e.type.name+" onto "+t.type.name)}function _P(t,e,n){let r=t.node(n);return aJ(r,e.node(n)),r}function Qh(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 _0(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&&(Qh(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Qh(i.child(l),r);e&&e.depth==n&&e.textOffset&&Qh(e.nodeBefore,r)}function Jh(t,e){return t.type.checkContent(e),t.copy(e)}function sJ(t,e,n,r,i){let a=t.depth>i&&_P(t,e,i+1),o=r.depth>i&&_P(n,r,i+1),l=[];return _0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(aJ(a,o),Qh(Jh(a,sJ(t,e,n,r,i+1)),l)):(a&&Qh(Jh(a,pS(t,e,i+1)),l),_0(e,n,i,l),o&&Qh(Jh(o,pS(n,r,i+1)),l)),_0(r,null,i,l),new yt(l)}function pS(t,e,n){let r=[];if(_0(null,t,n,r),t.depth>n){let i=_P(t,e,n+1);Qh(Jh(i,pS(t,e,n+1)),r)}return _0(e,null,n,r),new yt(r)}function Uze(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(yt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class xb{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 pr.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 gS(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 xb(n,r,a)}static resolveCached(e,n){let r=_7.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 _7.set(e,r=new zze);let i=r.elts[r.i]=xb.resolve(e,n);return r.i=(r.i+1)%Bze,i}}class zze{constructor(){this.elts=[],this.i=0}}const Bze=12,_7=new WeakMap;class gS{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 Hze=Object.create(null);let yd=class wP{constructor(e,n,r,i=pr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||yt.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&&fS(this.attrs,n||e.defaultAttrs||Hze)&&pr.sameSet(this.marks,r||pr.none)}copy(e=null){return e==this.content?this:new wP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new wP(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 Dt.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 Dt(u,i.depth-o,a.depth-o)}replace(e,n,r){return Fze(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 xb.resolveCached(this,e)}resolveNoCache(e){return xb.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()+")"),oJ(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=yt.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=pr.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(!pr.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=yt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};yd.prototype.text=void 0;class xS extends yd{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):oJ(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 xS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xS(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 oJ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Nf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new $ze(e,n);if(r.next==null)return Nf.empty;let i=lJ(r);r.next&&r.err("Unexpected trailing text");let a=Yze(Xze(i));return Zze(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 yt.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:f}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let g=a(f,l.concat(d));if(g)return g}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
- `)}}Nf.empty=new Nf(!0);class $ze{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 lJ(t){let e=[];do e.push(Vze(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Vze(t){let e=[];do e.push(Gze(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Gze(t){let e=Kze(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=Wze(t,e);else break;return e}function w7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Wze(t,e){let n=w7(t),r=n;return t.eat(",")&&(t.next!="}"?r=w7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function qze(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 Kze(t){if(t.eat("(")){let e=lJ(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=qze(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 Xze(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 cJ(t,e){return e-t}function S7(t,e){let n=[];return r(e),n.sort(cJ);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 Yze(t){let e=Object.create(null);return n(S7(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]);S7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new Nf(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(cJ);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function Zze(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 uJ(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 dJ(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 hJ(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 fJ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Jze(t,r,e[r]);return n}let M7=class mJ{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=fJ(e,r.attrs),this.defaultAttrs=uJ(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==Nf.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:dJ(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new yd(this,this.computeAttrs(e),yt.from(n),pr.setFrom(r))}createChecked(e=null,n,r){return n=yt.from(n),this.checkContent(n),new yd(this,this.computeAttrs(e),n,pr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=yt.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(yt.empty,!0);return a?new yd(this,e,n.append(a),pr.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){hJ(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:pr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new mJ(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 Qze(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 Jze{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Qze(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class _2{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=fJ(e,i.attrs),this.excluded=null;let a=uJ(this.attrs);this.instance=a?new pr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new pr(this,dJ(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new _2(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){hJ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class pJ{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=sa.from(e.nodes),n.marks=sa.from(e.marks||{}),this.nodes=M7.compile(this.spec.nodes,this),this.marks=_2.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]=Nf.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?E7(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==""?[]:E7(this,o.split(" "))}this.nodeFromJSON=i=>yd.fromJSON(this,i),this.markFromJSON=i=>pr.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 M7){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 xS(r,r.defaultAttrs,e,pr.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 E7(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 eBe(t){return t.tag!=null}function tBe(t){return t.style!=null}let w0=class SP{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(eBe(i))this.tags.push(i);else if(tBe(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 A7(this,n,!1);return r.addAll(e,pr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new A7(this,n,!0);return r.addAll(e,pr.none,n.from,n.to),Dt.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(iBe(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=T7(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=T7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new SP(e,SP.schemaRules(e)))}};const gJ={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},nBe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},xJ={ol:!0,ul:!0},bb=1,MP=2,S0=4;function N7(t,e,n){return e!=null?(e?bb:0)|(e==="full"?MP:0):t&&t.whitespace=="pre"?bb|MP:n&~S0}class n1{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=pr.none,this.match=a||(o&S0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(yt.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&bb)){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=yt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(yt.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&&!gJ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class A7{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=N7(null,n.preserveWhitespace,0)|(r?S0:0);i?a=new n1(i.type,i.attrs,pr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new n1(null,null,pr.none,!0,null,o):a=new n1(e.schema.topNodeType,null,pr.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&MP?"full":this.localPreserveWS||(i.options&bb)>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;xJ.hasOwnProperty(o)&&this.parser.normalizeLists&&rBe(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:nBe.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(gJ.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=pr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):C7(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=N7(e,a,o.options);o.options&S0&&o.content.length==0&&(l|=S0);let c=pr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):C7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new n1(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|=bb)}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 rBe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&xJ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function iBe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function T7(t){let e={};for(let n in t)e[n]=t[n];return e}function C7(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 Lf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=dk(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}=F1(dk(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&&F1(dk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return F1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Lf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=k7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return k7(e.marks)}}function k7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function dk(t){return t.document||window.document}const j7=new WeakMap;function aBe(t){let e=j7.get(t);return e===void 0&&j7.set(t,e=sBe(t)),e}function sBe(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 F1(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=aBe(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let g=f.indexOf(" ");g>0?c.setAttributeNS(f.slice(0,g),f.slice(g+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let g=e[f];if(g===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:x}=F1(t,g,n,r);if(c.appendChild(p),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const bJ=65535,yJ=Math.pow(2,16);function oBe(t,e){return t+e*yJ}function P7(t){return t&bJ}function lBe(t){return(t-(t&bJ))/yJ}const vJ=1,_J=2,U1=4,wJ=8;class EP{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&wJ)>0}get deletedBefore(){return(this.delInfo&(vJ|U1))>0}get deletedAfter(){return(this.delInfo&(_J|U1))>0}get deletedAcross(){return(this.delInfo&U1)>0}}class ks{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ks.empty)return ks.empty}recover(e){let n=0,r=P7(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+lBe(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+a],d=this.ranges[l+o],f=c+u;if(e<=f){let g=u?e==c?-1:e==f?1:n:n,p=c+i+(g<0?0:d);if(r)return p;let x=e==(n<0?c:f)?null:oBe(l/3,e-c),y=e==c?_J:e==f?vJ:U1;return(n<0?e!=c:e!=f)&&(y|=wJ),new EP(p,y,x)}i+=d-u}return r?e+i:new EP(e+i,0,null)}touches(e,n){let r=0,i=P7(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 ks(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ks.empty:new ks(e<0?[0,-e,0]:[0,0,e])}}ks.empty=new ks([]);class yb{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 yb(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 yb;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 EP(e,i,null)}}const hk=Object.create(null);class ka{getMap(){return ks.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=hk[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 hk)throw new RangeError("Duplicate use of step JSON ID "+e);return hk[e]=n,n.prototype.jsonID=e,n}}class mi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new mi(e,null)}static fail(e){return new mi(null,e)}static fromReplace(e,n,r,i){try{return mi.ok(e.replace(n,r,i))}catch(a){if(a instanceof mS)return mi.fail(a.message);throw a}}}function i4(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(i4(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return yt.fromArray(r)}class cd extends ka{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 Dt(i4(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return mi.fromReplace(e,this.from,this.to,a)}invert(){return new Bo(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 cd(n.pos,r.pos,this.mark)}merge(e){return e instanceof cd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cd(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 cd(n.from,n.to,e.markFromJSON(n.mark))}}ka.jsonID("addMark",cd);class Bo extends ka{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 Dt(i4(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return mi.fromReplace(e,this.from,this.to,r)}invert(){return new cd(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 Bo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Bo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Bo(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 Bo(n.from,n.to,e.markFromJSON(n.mark))}}ka.jsonID("removeMark",Bo);class ud extends ka{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return mi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return mi.fromReplace(e,this.pos,this.pos+1,new Dt(yt.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 ud(this.pos,n.marks[i]);return new ud(this.pos,this.mark)}}return new Af(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ud(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 ud(n.pos,e.markFromJSON(n.mark))}}ka.jsonID("addNodeMark",ud);class Af extends ka{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return mi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return mi.fromReplace(e,this.pos,this.pos+1,new Dt(yt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ud(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Af(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 Af(n.pos,e.markFromJSON(n.mark))}}ka.jsonID("removeNodeMark",Af);class Gi extends ka{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&NP(e,this.from,this.to)?mi.fail("Structure replace would overwrite content"):mi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ks([this.from,this.to-this.from,this.slice.size])}invert(e){return new Gi(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Gi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Gi)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Dt.empty:new Dt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Gi(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Dt.empty:new Dt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Gi(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Gi(n.from,n.to,Dt.fromJSON(e,n.slice),!!n.structure)}}ka.jsonID("replace",Gi);class Ki extends ka{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&&(NP(e,this.from,this.gapFrom)||NP(e,this.gapTo,this.to)))return mi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return mi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?mi.fromReplace(e,this.from,this.to,r):mi.fail("Content does not fit in gap")}getMap(){return new ks([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ki(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new Ki(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ki(n.from,n.to,n.gapFrom,n.gapTo,Dt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ka.jsonID("replaceAround",Ki);function NP(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 cBe(t,e,n,r){let i=[],a=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let g=Math.max(u,e),p=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let y=0;y<f.length;y++)f[y].isInSet(x)||(o&&o.to==g&&o.mark.eq(f[y])?o.to=p:i.push(o=new Bo(g,p,f[y])));l&&l.to==g?l.to=p:a.push(l=new cd(g,p,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function uBe(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 _2){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],g;for(let p=0;p<i.length;p++){let x=i[p];x.step==a-1&&f.eq(i[p].style)&&(g=x)}g?(g.to=u,g.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new Bo(o.from,o.to,o.style)))}function a4(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new Gi(l,d,Dt.empty));else{r=f;for(let g=0;g<u.marks.length;g++)n.allowsMarkType(u.marks[g].type)||t.step(new Bo(l,d,u.marks[g]));if(i&&u.isText&&n.whitespace!="pre"){let g,p=/\r?\n|\r/g,x;for(;g=p.exec(u.text);)x||(x=new Dt(yt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new Gi(l+g.index,l+g.index+g[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(yt.empty,!0);t.replace(l,l,new Dt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function dBe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function jg(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||!dBe(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function hBe(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=yt.empty,f=0;for(let x=a,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=yt.from(r.node(x).copy(d)),f++):c--;let g=yt.empty,p=0;for(let x=a,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,g=yt.from(i.node(x).copy(g)),p++):u++;t.step(new Ki(c,u,o,l,new Dt(d.append(g),f,p),d.size-f,!0))}function s4(t,e,n=null,r=t){let i=fBe(t,e),a=i&&mBe(r,e);return a?i.map(R7).concat({type:e,attrs:n}).concat(a.map(R7)):null}function R7(t){return{type:t,attrs:null}}function fBe(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 mBe(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 pBe(t,e,n){let r=yt.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=yt.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new Ki(i,a,i,a,new Dt(r,0,0),n.length,!0))}function gBe(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)&&xBe(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!x?u=!1:!p&&x&&(u=!0)}u===!1&&MJ(t,o,l,a),a4(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),g=d.map(l+o.nodeSize,1);return t.step(new Ki(f,g,f+1,g-1,new Dt(yt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&SJ(t,o,l,a),!1}})}function SJ(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 MJ(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 xBe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function bBe(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ki(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Dt(yt.from(o),0,0),1,!0))}function Hc(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),g=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(g,f.childCount),x=r&&r[d+1];x&&(p=p.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||f;if(!f.canReplace(g+1,f.childCount)||!y.type.validContent(p))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function yBe(t,e,n=1,r){let i=t.doc.resolve(e),a=yt.empty,o=yt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=yt.from(i.node(l).copy(a));let d=r&&r[u];o=yt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new Gi(e,e,new Dt(a.append(o),n,n),!0))}function Gd(t,e){let n=t.resolve(e),r=n.index();return EJ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function vBe(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 EJ(t,e){return!!(t&&e&&!t.isLeaf&&vBe(t,e))}function w2(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&&EJ(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 _Be(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);MJ(t,d.node(),d.before(),l)}o.inlineContent&&a4(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new Gi(u,c.map(e+n,-1),Dt.empty,!0)),r===!0){let d=t.doc.resolve(u);SJ(t,d.node(),d.before(),t.steps.length)}return t}function wBe(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 NJ(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 S2(t,e,n=e,r=Dt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return AJ(i,a,r)?new Gi(e,n,r):new SBe(i,a,r).fit()}function AJ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class SBe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=yt.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=yt.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 Dt(a,o,l);return e>-1?new Ki(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Gi(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=fk(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(yt.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=fk(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Dt(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=fk(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Dt(s0(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Dt(s0(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let y=0;y<a.length;y++)this.openFrontierNode(a[y]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:g}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));f=f.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),b=f.matchType(y.type);if(!b)break;u++,(u>1||c==0||y.content.size)&&(f=b,d.push(TJ(y.mark(g.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?p:-1)))}let x=u==l.childCount;x||(p=-1),this.placed=o0(this.placed,n,yt.from(d)),this.frontier[n].match=f,x&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,b=l;y<p;y++){let v=b.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),b=v.content}this.unplaced=x?e==0?Dt.empty:new Dt(s0(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new Dt(s0(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||!mk(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=mk(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=mk(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=o0(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=o0(this.placed,this.depth,yt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(yt.empty,!0);n.childCount&&(this.placed=o0(this.placed,this.frontier.length,n))}}function s0(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(s0(t.firstChild.content,e-1,n)))}function o0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(o0(t.lastChild.content,e-1,n)))}function fk(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function TJ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,TJ(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(yt.empty,!0)))),t.copy(r)}function mk(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&&!MBe(n,a.content,o)?l:null}function MBe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function EBe(t){return t.spec.defining||t.spec.definingForContent}function NBe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(AJ(i,a,r))return t.step(new Gi(e,n,r));let o=kJ(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let g=i.depth,p=i.pos-1;g>0;g--,p--){let x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(g)>-1?l=g:i.before(g)==p&&o.splice(1,0,-g)}let c=o.indexOf(l),u=[],d=r.openStart;for(let g=r.content,p=0;;p++){let x=g.firstChild;if(u.push(x),p==r.openStart)break;g=x.content}for(let g=d-1;g>=0;g--){let p=u[g],x=EBe(p.type);if(x&&!p.sameMarkup(i.node(Math.abs(l)-1)))d=g;else if(x||!p.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let p=(g+d+1)%(r.openStart+1),x=u[p];if(x)for(let y=0;y<o.length;y++){let b=o[(y+c)%o.length],v=!0;b<0&&(v=!1,b=-b);let E=i.node(b-1),w=i.index(b-1);if(E.canReplaceWith(w,w,x.type,x.marks))return t.replace(i.before(b),v?a.after(b):n,new Dt(CJ(r.content,0,r.openStart,p),p,r.openEnd))}}let f=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>f));g--){let p=o[g];p<0||(e=i.before(p),n=a.after(p))}}function CJ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(CJ(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(yt.empty,!0))}return t}function ABe(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=wBe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Dt(yt.from(r),0,0))}function TBe(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=kJ(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 kJ(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class Ap extends ka{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 mi.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 mi.fromReplace(e,this.pos,this.pos+1,new Dt(yt.from(i),0,n.isLeaf?0:1))}getMap(){return ks.empty}invert(e){return new Ap(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ap(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ap(n.pos,n.attr,n.value)}}ka.jsonID("attr",Ap);class vb extends ka{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 mi.ok(r)}getMap(){return ks.empty}invert(e){return new vb(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 vb(n.attr,n.value)}}ka.jsonID("docAttr",vb);let eg=class extends Error{};eg=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};eg.prototype=Object.create(Error.prototype);eg.prototype.constructor=eg;eg.prototype.name="TransformError";class jJ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new yb}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new eg(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Dt.empty){let i=S2(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Dt(yt.from(r),0,0))}delete(e,n){return this.replace(e,n,Dt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return NBe(this,e,n,r),this}replaceRangeWith(e,n,r){return ABe(this,e,n,r),this}deleteRange(e,n){return TBe(this,e,n),this}lift(e,n){return hBe(this,e,n),this}join(e,n=1){return _Be(this,e,n),this}wrap(e,n){return pBe(this,e,n),this}setBlockType(e,n=e,r,i=null){return gBe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return bBe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Ap(e,n,r)),this}setDocAttribute(e,n){return this.step(new vb(e,n)),this}addNodeMark(e,n){return this.step(new ud(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 pr)n.isInSet(r.marks)&&this.step(new Af(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new Af(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 yBe(this,e,n,r),this}addMark(e,n,r){return cBe(this,e,n,r),this}removeMark(e,n,r){return uBe(this,e,n,r),this}clearIncompatible(e,n,r){return a4(this,e,n,r),this}}const pk=Object.create(null);class bn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new CBe(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=Dt.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?Dt.empty:n),l==0&&L7(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),L7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new tn(e):sp(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?sp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):sp(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 Ls(e.node(0))}static atStart(e){return sp(e,e,0,0,1)||new Ls(e)}static atEnd(e){return sp(e,e,e.content.size,e.childCount,-1)||new Ls(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=pk[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 pk)throw new RangeError("Duplicate use of selection JSON ID "+e);return pk[e]=n,n.prototype.jsonID=e,n}getBookmark(){return tn.between(this.$anchor,this.$head).getBookmark()}}bn.prototype.visible=!0;class CBe{constructor(e,n){this.$from=e,this.$to=n}}let D7=!1;function O7(t){!D7&&!t.parent.inlineContent&&(D7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class tn extends bn{constructor(e,n=e){O7(e),O7(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 bn.near(r);let i=e.resolve(n.map(this.anchor));return new tn(i.parent.inlineContent?i:r,r)}replace(e,n=Dt.empty){if(super.replace(e,n),n==Dt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof tn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new M2(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 tn(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=bn.findFrom(n,r,!0)||bn.findFrom(n,-r,!0);if(a)n=a.$head;else return bn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(bn.findFrom(e,-r,!0)||bn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new tn(e,n)}}bn.jsonID("text",tn);class M2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new M2(e.map(this.anchor),e.map(this.head))}resolve(e){return tn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Kt extends bn{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?bn.near(a):new Kt(a)}content(){return new Dt(yt.from(this.node),0,0)}eq(e){return e instanceof Kt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new o4(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Kt(e.resolve(n.anchor))}static create(e,n){return new Kt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Kt.prototype.visible=!1;bn.jsonID("node",Kt);class o4{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new M2(r,r):new o4(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Kt.isSelectable(r)?new Kt(n):bn.near(n)}}class Ls extends bn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Dt.empty){if(n==Dt.empty){e.delete(0,e.doc.content.size);let r=bn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ls(e)}map(e){return new Ls(e)}eq(e){return e instanceof Ls}getBookmark(){return kBe}}bn.jsonID("all",Ls);const kBe={map(){return this},resolve(t){return new Ls(t)}};function sp(t,e,n,r,i,a=!1){if(e.inlineContent)return tn.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&&Kt.isSelectable(l))return Kt.create(t,n-(i<0?l.nodeSize:0))}else{let c=sp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function L7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof Gi||i instanceof Ki))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(bn.near(t.doc.resolve(o),n))}const I7=1,r1=2,F7=4;class jBe extends jJ{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|I7)&~r1,this.storedMarks=null,this}get selectionSet(){return(this.updated&I7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=r1,this}ensureMarks(e){return pr.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&r1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~r1,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||pr.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(bn.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|=F7,this}get scrolledIntoView(){return(this.updated&F7)>0}}function U7(t,e){return!e||!t?t:t.bind(e)}class l0{constructor(e,n,r){this.name=e,this.init=U7(n.init,r),this.apply=U7(n.apply,r)}}const PBe=[new l0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new l0("selection",{init(t,e){return t.selection||bn.atStart(e.doc)},apply(t){return t.selection}}),new l0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new l0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class gk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=PBe.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 l0(r.key,r.spec.state,r))})}}class pp{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 pp(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 jBe(this)}static create(e){let n=new gk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new pp(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 gk(this.schema,e.plugins),r=n.fields,i=new pp(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 gk(e.schema,e.plugins),a=new pp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=yd.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=bn.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 PJ(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=PJ(i,e,{})),n[r]=i}return n}class Ur{constructor(e){this.spec=e,this.props={},e.props&&PJ(e.props,this,this.props),this.key=e.key?e.key.key:RJ("plugin")}getState(e){return e[this.key]}}const xk=Object.create(null);function RJ(t){return t in xk?t+"$"+ ++xk[t]:(xk[t]=0,t+"$")}class Oi{constructor(e="key"){this.key=RJ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const l4=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function DJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const OJ=(t,e,n)=>{let r=DJ(t,n);if(!r)return!1;let i=c4(r);if(!i){let o=r.blockRange(),l=o&&jg(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(VJ(t,i,e,-1))return!0;if(r.parent.content.size==0&&(tg(a,"end")||Kt.isSelectable(a)))for(let o=r.depth;;o--){let l=S2(t.doc,r.before(o),r.after(o),Dt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(tg(a,"end")?bn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Kt.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},RBe=(t,e,n)=>{let r=DJ(t,n);if(!r)return!1;let i=c4(r);return i?LJ(t,i,e):!1},DBe=(t,e,n)=>{let r=FJ(t,n);if(!r)return!1;let i=u4(r);return i?LJ(t,i,e):!1};function LJ(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=S2(t.doc,a,c,Dt.empty);if(!u||u.from!=a||u instanceof Gi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(tn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function tg(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 IJ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=c4(r)}let o=a&&a.nodeBefore;return!o||!Kt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Kt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function c4(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function FJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const UJ=(t,e,n)=>{let r=FJ(t,n);if(!r)return!1;let i=u4(r);if(!i)return!1;let a=i.nodeAfter;if(VJ(t,i,e,1))return!0;if(r.parent.content.size==0&&(tg(a,"start")||Kt.isSelectable(a))){let o=S2(t.doc,r.before(),r.after(),Dt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(tg(a,"start")?bn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Kt.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},zJ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=u4(r)}let o=a&&a.nodeAfter;return!o||!Kt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Kt.create(t.doc,a.pos)).scrollIntoView()),!0)};function u4(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const OBe=(t,e)=>{let n=t.selection,r=n instanceof Kt,i;if(r){if(n.node.isTextblock||!Gd(t.doc,n.from))return!1;i=n.from}else if(i=w2(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Kt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},LBe=(t,e)=>{let n=t.selection,r;if(n instanceof Kt){if(n.node.isTextblock||!Gd(t.doc,n.to))return!1;r=n.to}else if(r=w2(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},IBe=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&jg(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},BJ=(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 d4(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const FBe=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=d4(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(bn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},HJ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ls||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=d4(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,a.createAndFill());l.setSelection(tn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},$J=(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(Hc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&jg(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function UBe(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Kt&&e.selection.node.isBlock)return!r.parentOffset||!Hc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,l,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),l=d4(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),a.unshift(c&&l?{type:l}:null),o=p;break}else{if(p==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof tn||e.selection instanceof Ls)&&d.deleteSelection();let f=d.mapping.map(r.pos),g=Hc(d.doc,f,a.length,a);if(g||(a[0]=l?{type:l}:null,g=Hc(d.doc,f,a.length,a)),!g)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let p=d.mapping.map(r.before(o)),x=d.doc.resolve(p);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const zBe=UBe(),BBe=(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(Kt.create(t.doc,i))),!0)};function HBe(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||Gd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function VJ(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&HBe(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&l.matchType(o[0]||a.type).validEnd){if(n){let p=e.pos+a.nodeSize,x=yt.empty;for(let v=o.length-1;v>=0;v--)x=yt.from(o[v].create(null,x));x=yt.from(i.copy(x));let y=t.tr.step(new Ki(e.pos-1,p,e.pos,p,new Dt(x,1,0),o.length,!0)),b=y.doc.resolve(p+2*o.length);b.nodeAfter&&b.nodeAfter.type==i.type&&Gd(y.doc,b.pos)&&y.join(b.pos),n(y.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:bn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),g=f&&jg(f);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&tg(a,"start",!0)&&tg(i,"end")){let p=i,x=[];for(;x.push(p),!p.isTextblock;)p=p.lastChild;let y=a,b=1;for(;!y.isTextblock;y=y.firstChild)b++;if(p.canReplace(p.childCount,p.childCount,y.content)){if(n){let v=yt.empty;for(let w=x.length-1;w>=0;w--)v=yt.from(x[w].copy(v));let E=t.tr.step(new Ki(e.pos-x.length,e.pos+a.nodeSize,e.pos+b,e.pos+a.nodeSize-b,new Dt(v,x.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function GJ(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(tn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const $Be=GJ(-1),VBe=GJ(1);function GBe(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&s4(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function z7(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function h4(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}h4(l4,OJ,IJ);h4(l4,UJ,zJ);h4(BJ,HJ,$J,zBe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function WBe(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 qBe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function qBe(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 gS(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new gS(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=s4(a,n,r,e);return l?(t&&KBe(t,e,l,i,n),!0):!1}function KBe(t,e,n,r,i){let a=yt.empty;for(let d=n.length-1;d>=0;d--)a=yt.from(n[d].type.create(n[d].attrs,a));t.step(new Ki(e.start-(r?2:0),e.end,e.start,e.end,new Dt(a,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,g=!0;d<f;d++,g=!1)!g&&Hc(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function XBe(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?YBe(e,n,t,a):ZBe(e,n,a):!0:!1}}function YBe(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Ki(a-1,o,a,o,new Dt(yt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new gS(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=jg(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return Gd(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function ZBe(t,e,n){let r=t.tr,i=n.parent;for(let p=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)p-=i.child(x).nodeSize,r.delete(p-1,p+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?yt.empty:yt.from(i))))return!1;let f=a.pos,g=f+o.nodeSize;return r.step(new Ki(f-(l?1:0),g+(c?1:0),f+1,g-1,new Dt((l?yt.empty:yt.from(i.copy(yt.empty))).append(c?yt.empty:yt.from(i.copy(yt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function QBe(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=yt.from(u?t.create():null),f=new Dt(yt.from(t.create(null,yt.from(l.type.create(null,d)))),u?3:1,0),g=a.start,p=a.end;n(e.tr.step(new Ki(g-(u?3:1),p,g,p,f,1,!0)).scrollIntoView())}return!0}}const ua=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ng=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let AP=null;const _c=function(t,e,n){let r=AP||(AP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},JBe=function(){AP=null},Tf=function(t,e,n,r){return n&&(B7(t,e,n,r,-1)||B7(t,e,n,r,1))},e8e=/^(img|br|input|textarea|hr)$/i;function B7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:co(t))){let o=t.parentNode;if(!o||o.nodeType!=1||gy(t)||e8e.test(t.nodeName)||t.contentEditable=="false")return!1;e=ua(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?co(t):0}else return!1}}function co(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function t8e(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=co(t)}else if(t.parentNode&&!gy(t))e=ua(t),t=t.parentNode;else return null}}function n8e(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&&!gy(t))e=ua(t)+1,t=t.parentNode;else return null}}function r8e(t,e,n){for(let r=e==0,i=e==co(t);r||i;){if(t==n)return!0;let a=ua(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==co(t)}}function gy(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 E2=function(t){return t.focusNode&&Tf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ph(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function i8e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function a8e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(co(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(co(r.startContainer),r.startOffset)}}}const jl=typeof navigator<"u"?navigator:null,H7=typeof document<"u"?document:null,Wd=jl&&jl.userAgent||"",TP=/Edge\/(\d+)/.exec(Wd),WJ=/MSIE \d/.exec(Wd),CP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Wd),us=!!(WJ||CP||TP),vd=WJ?document.documentMode:CP?+CP[1]:TP?+TP[1]:0,go=!us&&/gecko\/(\d+)/i.test(Wd);go&&+(/Firefox\/(\d+)/.exec(Wd)||[0,0])[1];const kP=!us&&/Chrome\/(\d+)/.exec(Wd),Ma=!!kP,qJ=kP?+kP[1]:0,Ha=!us&&!!jl&&/Apple Computer/.test(jl.vendor),rg=Ha&&(/Mobile\/\w+/.test(Wd)||!!jl&&jl.maxTouchPoints>2),ro=rg||(jl?/Mac/.test(jl.platform):!1),s8e=jl?/Win/.test(jl.platform):!1,Dc=/Android \d/.test(Wd),xy=!!H7&&"webkitFontSmoothing"in H7.documentElement.style,o8e=xy?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function l8e(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function pc(t,e){return typeof t=="number"?t:t[e]}function c8e(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 $7(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=ng(o);continue}let l=o,c=l==a.body,u=c?l8e(a):c8e(l),d=0,f=0;if(e.top<u.top+pc(r,"top")?f=-(u.top-e.top+pc(i,"top")):e.bottom>u.bottom-pc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+pc(i,"top")-u.top:e.bottom-u.bottom+pc(i,"bottom")),e.left<u.left+pc(r,"left")?d=-(u.left-e.left+pc(i,"left")):e.right>u.right-pc(r,"right")&&(d=e.right-u.right+pc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let p=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let y=l.scrollLeft-p,b=l.scrollTop-x;e={left:e.left-y,top:e.top-b,right:e.right-y,bottom:e.bottom-b}}let g=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:ng(o)}}function u8e(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:KJ(t.dom)}}function KJ(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ng(r));return e}function d8e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;XJ(n,r==0?0:r-e)}function XJ(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 Jm=null;function h8e(t){if(t.setActive)return t.setActive();if(Jm)return t.focus(Jm);let e=KJ(t);t.focus(Jm==null?{get preventScroll(){return Jm={preventScroll:!0},!0}}:void 0),Jm||(Jm=!1,XJ(e,0))}function YJ(t,e){let n,r=2e8,i,a=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let g;if(d.nodeType==1)g=d.getClientRects();else if(d.nodeType==3)g=_c(d).getClientRects();else continue;for(let p=0;p<g.length;p++){let x=g[p];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let y=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(y<r){n=d,r=y,i=y&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&y&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?f8e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:YJ(n,i)}function f8e(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=Wu(r,1);if(a.top!=a.bottom&&f4(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function f4(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function m8e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function p8e(t,e,n){let{node:r,offset:i}=YJ(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 g8e(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 ZJ(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let o=t.childNodes[a];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(f4(e,u))return ZJ(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function x8e(t,e){let n=t.dom.ownerDocument,r,i=0,a=a8e(n,e.left,e.top);a&&({node:r,offset:i}=a);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!f4(e,u)||(o=ZJ(t.dom,e,u),!o))return null}if(Ha)for(let u=o;r&&u;u=ng(u))u.draggable&&(r=void 0);if(o=m8e(o,e),r){if(go&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;xy&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=g8e(t,r,i,e))}l==null&&(l=p8e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function V7(t){return t.top<t.bottom||t.left<t.right}function Wu(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(V7(r))return r}return Array.prototype.find.call(n,V7)||t.getBoundingClientRect()}const b8e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function QJ(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=xy||go;if(r.nodeType==3)if(o&&(b8e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Wu(_c(r,i,i),n);if(go&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Wu(_c(r,i-1,i-1),-1);if(u.top==c.top){let d=Wu(_c(r,i,i+1),-1);if(d.top!=c.top)return Xx(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++,Xx(Wu(_c(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==co(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return bk(c.getBoundingClientRect(),!1)}if(a==null&&i<co(r)){let c=r.childNodes[i];if(c.nodeType==1)return bk(c.getBoundingClientRect(),!0)}return bk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==co(r))){let c=r.childNodes[i-1],u=c.nodeType==3?_c(c,co(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Xx(Wu(u,1),!1)}if(a==null&&i<co(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?_c(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Xx(Wu(u,-1),!0)}return Xx(Wu(r.nodeType==3?_c(r):r,-n),n>=0)}function Xx(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 bk(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 JJ(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 y8e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return JJ(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=QJ(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=_c(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const v8e=/[\u0590-\u08ac]/;function _8e(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?!v8e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:JJ(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),b=x&&!p.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==y;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return g!=null&&(l.caretBidiLevel=g),b}):r.pos==r.start()||r.pos==r.end()}let G7=null,W7=null,q7=!1;function w8e(t,e,n){return G7==e&&W7==n?q7:(G7=e,W7=n,q7=n=="up"||n=="down"?y8e(t,e,n):_8e(t,e,n))}const xo=0,K7=1,Uh=2,Pl=3;class by{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=xo,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>ua(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let o=this.children[r],l=a+o.size;if(l>e||o instanceof tee){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 eee&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?ua(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?ua(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let f=l;f>0;f--){let g=this.children[f-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=ua(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=ua(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let p=0,x=0;p<this.children.length;p++){let y=this.children[p],b=x+y.size;if(a>x&&o<b)return y.setSelection(e-x-y.border,n-x-y.border,r,i);x=b}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((go||Ha)&&e==n){let{node:p,offset:x}=l;if(p.nodeType==3){if(f=!!(x&&p.nodeValue[x-1]==`
- `),f&&x==p.nodeValue.length)for(let y=p,b;y;y=y.parentNode){if(b=y.nextSibling){b.nodeName=="BR"&&(l=c={node:b.parentNode,offset:ua(b)+1});break}let v=y.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let y=p.childNodes[x-1];f=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(go&&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&&Ha)&&Tf(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Tf(c.node,c.offset,d.focusNode,d.focusOffset))return;let g=!1;if((u.extend||e==n)&&!(f&&go)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),g=!0}catch{}}if(!g){if(e>n){let x=l;l=c,c=x}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Uh:K7,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Pl:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Uh:Pl}r=o}this.dirty=Uh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Uh:K7;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class eee extends by{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==xo&&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 S8e extends by{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 Cf extends by{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=Lf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Cf(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Pl||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Pl&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=xo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=xo}}slice(e,n,r){let i=Cf.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=PP(a,n,o,r)),e>0&&(a=PP(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 _d extends by{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}=Lf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let g=d;return d=iee(d,r,n),u?c=new M8e(e,n,r,i,d,f||null,g,u,a,o+1):n.isText?new N2(e,n,r,i,d,g,a):new _d(e,n,r,i,d,f||null,g,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>yt.empty)}return e}matchesNode(e,n,r){return this.dirty==xo&&e.eq(this.node)&&bS(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 N8e(this,o&&o.node,e);C8e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?pr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,g)=>{c.syncToMarks(u.marks,r,e);let p;c.findNodeMatch(u,d,f,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(p=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,p,e)||c.updateNextNode(u,d,f,e,g,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Uh)&&(o&&this.protectLocalComposition(e,o),nee(this.contentDOM,this.children,e),rg&&k8e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof tn)||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=j8e(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 S8e(this,a,n,i);e.input.compositionNodes.push(o),this.children=PP(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Pl||!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=xo}updateOuterDeco(e){if(bS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ree(this.dom,this.nodeDOM,jP(this.outerDeco,this.node,n),jP(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 X7(t,e,n,r,i){iee(r,e,t);let a=new _d(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class N2 extends _d{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==Pl||this.dirty!=xo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=xo||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=xo,!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 N2(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=Pl)}get domAtom(){return!1}isText(e){return this.node.text==e}}class tee extends by{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==xo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class M8e extends _d{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==Pl)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 nee(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=Y7(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Cf){let c=r?r.previousSibling:t.lastChild;nee(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Y7(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const M0=function(t){t&&(this.nodeName=t)};M0.prototype=Object.create(null);const zh=[new M0];function jP(t,e,n){if(t.length==0)return zh;let r=n?zh[0]:new M0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new M0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new M0(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 ree(t,e,n,r){if(n==zh&&r==zh)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=zh[0]),i=c}E8e(i,l||zh[0],o)}return i}function E8e(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 iee(t,e,n){return ree(t,t,zh,jP(e,n,t.nodeType!=1))}function bS(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 Y7(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class N8e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=A8e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=xo,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Cf.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let o=this.top.children[i];return o.dirty==Pl&&o.dom==o.contentDOM&&(o.dirty=Uh),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 _d){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,g=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Pl&&bS(n,c.outerDeco));if(!g&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!g&&(f=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Uh,f.updateChildren(i,o+1),f.dirty=xo),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)||!bS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=_d.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=_d.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 eee(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 Cf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof N2)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ha||Ma)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new tee(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 A8e(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 Cf)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 T8e(t,e){return t.type.side-e.type.side}function C8e(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let b=i[o++];b.widget&&(d?(f||(f=[d])).push(b):d=b)}if(d)if(f){f.sort(T8e);for(let b=0;b<f.length;b++)n(f[b],u,!!c)}else n(d,u,!!c);let g,p;if(c)p=-1,g=c,c=null;else if(u<t.childCount)p=u,g=t.child(u++);else break;for(let b=0;b<l.length;b++)l[b].to<=a&&l.splice(b--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let x=a+g.nodeSize;if(g.isText){let b=x;o<i.length&&i[o].from<b&&(b=i[o].from);for(let v=0;v<l.length;v++)l[v].to<b&&(b=l[v].to);b<x&&(c=g.cut(b-a),g=g.cut(0,b-a),x=b,p=-1)}else for(;o<i.length&&i[o].to<x;)o++;let y=g.isInline&&!g.isLeaf?l.filter(b=>!b.inline):l.slice();r(g,y,e.forChild(a,g),p),a=x}}function k8e(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 j8e(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 PP(t,e,n,r,i){let a=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function m4(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(E2(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Kt.isSelectable(f)&&i.parent&&!(f.isInline&&r8e(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;u=new Kt(o==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,g=o;for(let p=0;p<n.rangeCount;p++){let x=n.getRangeAt(p);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=g==t.state.selection.anchor?[g,f]:[f,g],l=r.resolve(o)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!a?1:-1;u=p4(t,d,l,f)}return u}function aee(t){return t.editable?t.hasFocus():oee(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function $c(t,e=!1){let n=t.state.selection;if(see(t,n),!!aee(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ma){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Tf(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)R8e(t);else{let{anchor:r,head:i}=n,a,o;Z7&&!(n instanceof tn)&&(n.$from.parent.inlineContent||(a=Q7(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Q7(t,n.to))),t.docView.setSelection(r,i,t,e),Z7&&(a&&J7(a),o&&J7(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&P8e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Z7=Ha||Ma&&qJ<63;function Q7(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(Ha&&i&&i.contentEditable=="false")return yk(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return yk(i);if(a)return yk(a)}}function yk(t){return t.contentEditable="true",Ha&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function J7(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function P8e(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(()=>{(!aee(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function R8e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ua(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&us&&vd<=11&&(n.disabled=!0,n.disabled=!1)}function see(t,e){if(e instanceof Kt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(e9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else e9(t)}function e9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function p4(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||tn.between(e,n,r)}function t9(t){return t.editable&&!t.hasFocus()?!1:oee(t)}function oee(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 D8e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Tf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function RP(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&&bn.findFrom(a,e)}function Zu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function n9(t,e,n){let r=t.state.selection;if(r instanceof tn)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 Zu(t,new tn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=RP(t.state,e);return i&&i instanceof Kt?Zu(t,i):!1}else if(!(ro&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Kt.isSelectable(a)?Zu(t,new Kt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):xy?Zu(t,new tn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Kt&&r.node.isInline)return Zu(t,new tn(e>0?r.$to:r.$from));{let i=RP(t.state,e);return i?Zu(t,i):!1}}}function yS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function E0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ep(t,e){return e<0?O8e(t):L8e(t)}function O8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(go&&n.nodeType==1&&r<yS(n)&&E0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(E0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(lee(n))break;{let l=n.previousSibling;for(;l&&E0(l,-1);)i=n.parentNode,a=ua(l),l=l.previousSibling;if(l)n=l,r=yS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?DP(t,n,r):i&&DP(t,i,a)}function L8e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=yS(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(E0(l,1))a=n,o=++r;else break}else{if(lee(n))break;{let l=n.nextSibling;for(;l&&E0(l,1);)a=l.parentNode,o=ua(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=yS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&DP(t,a,o)}function lee(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function I8e(t,e){for(;t&&e==t.childNodes.length&&!gy(t);)e=ua(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function F8e(t,e){for(;t&&!e&&!gy(t);)e=ua(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function DP(t,e,n){if(e.nodeType!=3){let a,o;(o=I8e(e,n))?(e=o,n=0):(a=F8e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(E2(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&&$c(t)},50)}function r9(t,e){let n=t.state.doc.resolve(e);if(!(Ma||s8e)&&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 i9(t,e,n){let r=t.state.selection;if(r instanceof tn&&!r.empty||n.indexOf("s")>-1||ro&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=RP(t.state,e);if(o&&o instanceof Kt)return Zu(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof Ls?bn.near(o,e):bn.findFrom(o,e);return l?Zu(t,l):!1}return!1}function a9(t,e){if(!(t.state.selection instanceof tn))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 s9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function U8e(t){if(!Ha||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;s9(t,r,"true"),setTimeout(()=>s9(t,r,"false"),20)}return!1}function z8e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function B8e(t,e){let n=e.keyCode,r=z8e(e);if(n==8||ro&&n==72&&r=="c")return a9(t,-1)||ep(t,-1);if(n==46&&!e.shiftKey||ro&&n==68&&r=="c")return a9(t,1)||ep(t,1);if(n==13||n==27)return!0;if(n==37||ro&&n==66&&r=="c"){let i=n==37?r9(t,t.state.selection.from)=="ltr"?-1:1:-1;return n9(t,i,r)||ep(t,i)}else if(n==39||ro&&n==70&&r=="c"){let i=n==39?r9(t,t.state.selection.from)=="ltr"?1:-1:1;return n9(t,i,r)||ep(t,i)}else{if(n==38||ro&&n==80&&r=="c")return i9(t,-1,r)||ep(t,-1);if(n==40||ro&&n==78&&r=="c")return U8e(t)||i9(t,1,r)||ep(t,1);if(r==(ro?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function g4(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let o=t.someProp("clipboardSerializer")||Lf.fromSchema(t.state.schema),l=mee(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=fee[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let x=l.createElement(d[p]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:g,slice:e}}function cee(t,e,n,r,i){let a=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",g=>{e=g(e,a||r,t)}),a)return l=new Dt(yt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",g=>{l=g(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(f)l=f;else{let g=i.marks(),{schema:p}=t.state,x=Lf.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let b=o.appendChild(document.createElement("p"));y&&b.appendChild(x.serializeNode(p.text(y,g)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=G8e(n),xy&&W8e(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||w0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!H8e.test(g.parentNode.nodeName)?{ignore:!0}:null}})),d)l=q8e(o9(l,+d[1],+d[2]),d[4]);else if(l=Dt.maxOpen($8e(l.content,i),!0),l.openStart||l.openEnd){let f=0,g=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;g<l.openEnd&&!p.type.spec.isolating;g++,p=p.lastChild);l=o9(l,f,g)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const H8e=/^(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 $8e(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&&dee(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=hee(o[o.length-1],a.length));let d=uee(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return yt.from(o)}return t}function uee(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,yt.from(t));return t}function dee(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=dee(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(yt.from(uee(n,t,i+1))))}}function hee(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,hee(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(yt.empty,!0);return t.copy(n.append(r))}function OP(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=OP(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(yt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function o9(t,e,n){return e<t.openStart&&(t=new Dt(OP(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Dt(OP(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const fee={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 l9=null;function mee(){return l9||(l9=document.implementation.createHTMLDocument("title"))}let vk=null;function V8e(t){let e=window.trustedTypes;return e?(vk||(vk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),vk.createHTML(t)):t}function G8e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=mee().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&fee[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=V8e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function W8e(t){let e=t.querySelectorAll(Ma?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function q8e(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=yt.from(c.create(r[l+1],i)),a++,o++}return new Dt(i,a,o)}const $a={},Va={},K8e={touchstart:!0,touchmove:!0};class X8e{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Y8e(t){for(let e in $a){let n=$a[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Q8e(t,r)&&!x4(t,r)&&(t.editable||!(r.type in Va))&&n(t,r)},K8e[e]?{passive:!0}:void 0)}Ha&&t.dom.addEventListener("input",()=>null),LP(t)}function dd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Z8e(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 LP(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>x4(t,r))})}function x4(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Q8e(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 J8e(t,e){!x4(t,e)&&$a[e.type]&&(t.editable||!(e.type in Va))&&$a[e.type](t,e)}Va.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!gee(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Dc&&Ma&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),rg&&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,Ph(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||B8e(t,n)?n.preventDefault():dd(t,"key")};Va.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Va.keypress=(t,e)=>{let n=e;if(gee(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ro&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof tn)||!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 A2(t){return{left:t.clientX,top:t.clientY}}function e6e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function b4(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,l=>o>a.depth?l(t,n,a.nodeAfter,a.before(o),i,!0):l(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Tp(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 t6e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Kt.isSelectable(r)?(Tp(t,new Kt(n)),!0):!1}function n6e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Kt&&(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(Kt.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?(Tp(t,Kt.create(t.state.doc,i)),!0):!1}function r6e(t,e,n,r,i){return b4(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?n6e(t,n):t6e(t,n))}function i6e(t,e,n,r){return b4(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function a6e(t,e,n,r){return b4(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||s6e(t,n,r)}function s6e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Tp(t,tn.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)Tp(t,tn.create(r,l+1,l+1+o.content.size));else if(Kt.isSelectable(o))Tp(t,Kt.create(r,l));else continue;return!0}}function y4(t){return vS(t)}const pee=ro?"metaKey":"ctrlKey";$a.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=y4(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&e6e(n,t.input.lastClick)&&!n[pee]&&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(A2(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new o6e(t,o,n,!!r)):(a=="doubleClick"?i6e:a6e)(t,o.pos,o.inside,n)?n.preventDefault():dd(t,"pointer"))};class o6e{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[pee],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 Kt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&go&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),dd(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>$c(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(A2(e))),this.updateAllowDefault(e),this.allowDefault||!n?dd(this.view,"pointer"):r6e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ha&&this.mightDrag&&!this.mightDrag.node.isAtom||Ma&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Tp(this.view,bn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):dd(this.view,"pointer")}move(e){this.updateAllowDefault(e),dd(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}$a.touchstart=t=>{t.input.lastTouch=Date.now(),y4(t),dd(t,"pointer")};$a.touchmove=t=>{t.input.lastTouch=Date.now(),dd(t,"pointer")};$a.contextmenu=t=>y4(t);function gee(t,e){return t.composing?!0:Ha&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const l6e=Dc?5e3:-1;Va.compositionstart=Va.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof tn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),vS(t,!0),t.markCursor=null;else if(vS(t,!e.selection.empty),go&&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}xee(t,l6e)};Va.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,xee(t,20))};function xee(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>vS(t),e))}function bee(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=u6e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function c6e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=t8e(e.focusNode,e.focusOffset),r=n8e(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 u6e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function vS(t,e=!1){if(!(Dc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),bee(t),e||t.docView&&t.docView.dirty){let n=m4(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function d6e(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 _b=us&&vd<15||rg&&o8e<604;$a.copy=Va.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=_b?null:n.clipboardData,o=r.content(),{dom:l,text:c}=g4(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):d6e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function h6e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function f6e(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?wb(t,r.value,null,i,e):wb(t,r.textContent,r.innerHTML,i,e)},50)}function wb(t,e,n,r,i){let a=cee(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Dt.empty)))return!0;if(!a)return!1;let o=h6e(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 yee(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," "):""}Va.paste=(t,e)=>{let n=e;if(t.composing&&!Dc)return;let r=_b?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&wb(t,yee(r),r.getData("text/html"),i,n)?n.preventDefault():f6e(t,n)};class vee{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const m6e=ro?"altKey":"ctrlKey";function _ee(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[m6e]}$a.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(A2(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Kt?i.to-1:i.to))){if(r&&r.mightDrag)o=Kt.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=Kt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=g4(t,l);(!n.dataTransfer.files.length||!Ma||qJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(_b?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",_b||n.dataTransfer.setData("text/plain",u),t.dragging=new vee(d,_ee(t,n),o)};$a.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Va.dragover=Va.dragenter=(t,e)=>e.preventDefault();Va.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(A2(n));if(!i)return;let a=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=cee(t,yee(n.dataTransfer),_b?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&_ee(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Dt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?NJ(t.state.doc,a.pos,o):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,g=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(g))return;let p=u.doc.resolve(d);if(f&&Kt.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Kt(p));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,b,v,E)=>x=E),u.setSelection(p4(t,p,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};$a.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())&&$c(t)},20))};$a.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)};$a.beforeinput=(t,e)=>{if(Ma&&Dc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Ph(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 Va)$a[t]=Va[t];function Sb(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 _S{constructor(e,n){this.toDOM=e,this.spec=n||ef,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 Fa(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof _S&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Sb(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class wd{constructor(e,n){this.attrs=e,this.spec=n||ef}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 Fa(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof wd&&Sb(this.attrs,e.attrs)&&Sb(this.spec,e.spec)}static is(e){return e.type instanceof wd}destroy(){}}class v4{constructor(e,n){this.attrs=e,this.spec=n||ef}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 Fa(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof v4&&Sb(this.attrs,e.attrs)&&Sb(this.spec,e.spec)}destroy(){}}class Fa{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Fa(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 Fa(e,e,new _S(n,r))}static inline(e,n,r,i){return new Fa(e,n,new wd(r,i))}static node(e,n,r,i){return new Fa(e,n,new v4(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof wd}get widget(){return this.type instanceof _S}}const op=[],ef={};class Rr{constructor(e,n){this.local=e.length?e:op,this.children=n.length?n:op}static create(e,n){return n.length?wS(n,e,0,ef):_a}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!a||a(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,a)}}map(e,n,r){return this==_a||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ef)}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?p6e(this.children,o||[],e,n,r,i,a):o?new Rr(o.sort(tf),op):_a}add(e,n){return n.length?this==_a?Rr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=See(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,wS(d,l,u+1,ef)),a+=3}});let o=wee(a?Mee(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Rr(o.length?this.local.concat(o).sort(tf):this.local,i||this.children)}remove(e){return e.length==0||this==_a?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let o,l=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(o,l+1);u!=_a?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,o;a<e.length;a++)if(o=e[a])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Rr(i,r):_a}forChild(e,n){if(this==_a)return this;if(n.isLeaf)return Rr.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let a=e+1,o=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>a&&c.type instanceof wd){let u=Math.max(a,c.from)-a,d=Math.min(o,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new Rr(i.sort(tf),op);return r?new rd([l,r]):l}return r||_a}eq(e){if(this==e)return!0;if(!(e instanceof Rr)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return _4(this.localsInner(e))}localsInner(e){if(this==_a)return op;if(e.inlineContent||!this.local.some(wd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof wd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Rr.empty=new Rr([],[]);Rr.removeOverlap=_4;const _a=Rr.empty;class rd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,ef));return rd.from(r)}forChild(e,n){if(n.isLeaf)return Rr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=_a&&(a instanceof rd?r=r.concat(a.members):r.push(a))}return rd.from(r)}eq(e){if(!(e instanceof rd)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let o=0;o<a.length;o++)n.push(a[o])}}return n?_4(r?n:n.sort(tf)):op}static from(e){switch(e.length){case 0:return _a;case 1:return e[0];default:return new rd(e.every(n=>n instanceof Rr)?e:e.reduce((n,r)=>n.concat(r instanceof Rr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function p6e(t,e,n,r,i,a,o){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((g,p,x,y)=>{let b=y-x-(p-g);for(let v=0;v<l.length;v+=3){let E=l[v+1];if(E<0||g>E+d-f)continue;let w=l[v]+d-f;p>=w?l[v+1]=g<=w?-2:-1:g>=d&&b&&(l[v]+=b,l[v+1]+=b)}f+=b}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let g=n.map(t[u+1]+a,-1),p=g-i,{index:x,offset:y}=r.content.findIndex(f),b=r.maybeChild(x);if(b&&y==f&&y+b.nodeSize==p){let v=l[u+2].mapInner(n,b,d+1,t[u]+a+1,o);v!=_a?(l[u]=f,l[u+1]=p,l[u+2]=v):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=g6e(l,t,e,n,i,a,o),d=wS(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,g=0;f<d.children.length;f+=3){let p=d.children[f];for(;g<l.length&&l[g]<p;)g+=3;l.splice(g,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Rr(e.sort(tf),l)}function wee(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 Fa(i.from+e,i.to+e,i.type))}return n}function g6e(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 See(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 Mee(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function wS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=See(t,l,c+n);if(u){a=!0;let d=wS(u,l,n+c+1,r);d!=_a&&i.push(c,c+l.nodeSize,d)}});let o=wee(a?Mee(t):t,-n).sort(tf);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Rr(o,i):_a}function tf(t,e){return t.from-e.from||t.to-e.to}function _4(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),c9(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),c9(e,i,r.copy(a.from,r.to)));break}}}return e}function c9(t,e,n){for(;e<t.length&&tf(n,t[e])>0;)e++;t.splice(e,0,n)}function _k(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=_a&&e.push(r)}),t.cursorWrapper&&e.push(Rr.create(t.state.doc,[t.cursorWrapper.deco])),rd.from(e)}const x6e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},b6e=us&&vd<=11;class y6e{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 v6e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new y6e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);us&&vd<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),b6e&&(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,x6e)),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(t9(this.view)){if(this.suppressingSelectionUpdates)return $c(this.view);if(us&&vd<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Tf(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=ng(a))n.add(a);for(let a=e.anchorNode;a;a=ng(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)&&t9(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(go&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,g]=d;f.parentNode&&f.parentNode.parentNode==g.parentNode?g.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let g of d){let p=g.parentNode;p&&p.nodeName=="LI"&&(!f||S6e(e,f)!=p)&&g.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&E2(r)&&(u=m4(e))&&u.eq(bn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$c(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),_6e(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||$c(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(us&&vd<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:g}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(a=g)}let o=i&&i.parentNode==e.target?ua(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?ua(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let u9=new WeakMap,d9=!1;function _6e(t){if(!u9.has(t)&&(u9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=go,d9)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."),d9=!0}}function h9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Tf(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function w6e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return h9(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?h9(t,n):null}function S6e(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 M6e(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}],E2(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ma&&t.input.lastKeyCode===8)for(let b=a;b>i;b--){let v=r.childNodes[b-1],E=v.pmViewDesc;if(v.nodeName=="BR"&&!E){a=b;break}if(!E||E.size)break}let f=t.state.doc,g=t.someProp("domParser")||w0.fromSchema(t.state.schema),p=f.resolve(o),x=null,y=g.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:E6e,context:p});if(u&&u[0].pos!=null){let b=u[0].pos,v=u[1]&&u[1].pos;v==null&&(v=b),x={anchor:b+o,head:v+o}}return{doc:y,sel:x,from:o,to:l}}function E6e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ha&&/^(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||Ha&&/^(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 N6e=/^(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 A6e(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=m4(t,T);if(O&&!t.state.selection.eq(O)){if(Ma&&Dc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",R=>R(t,Ph(13,"Enter"))))return;let k=t.state.tr.setSelection(O);T=="pointer"?k.setMeta("pointer",!0):T=="key"&&k.scrollIntoView(),a&&k.setMeta("composition",a),t.dispatch(k)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=M6e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),g,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,p="end"):(g=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let x=k6e(f.content,u.doc.content,u.from,g,p);if(x&&t.input.domChangeCount++,(rg&&t.input.lastIOSEnter>Date.now()-225||Dc)&&i.some(T=>T.nodeType==1&&!N6e.test(T.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",T=>T(t,Ph(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof tn&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))x={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let T=f9(t,t.state.doc,u.sel);if(T&&!T.eq(t.state.selection)){let O=t.state.tr.setSelection(T);a&&O.setMeta("composition",a),t.dispatch(O)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof tn&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),us&&vd<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>u.from&&u.doc.textBetween(x.start-u.from-1,x.start-u.from+1)==" "&&(x.start--,x.endA--,x.endB--);let y=u.doc.resolveNoCache(x.start-u.from),b=u.doc.resolveNoCache(x.endB-u.from),v=d.resolve(x.start),E=y.sameParent(b)&&y.parent.inlineContent&&v.end()>=x.endA;if((rg&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!E&&y.pos<u.doc.content.size&&(!y.sameParent(b)||!y.parent.inlineContent)&&y.pos<b.pos&&!/\S/.test(u.doc.textBetween(y.pos,b.pos,"","")))&&t.someProp("handleKeyDown",T=>T(t,Ph(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&C6e(d,x.start,x.endA,y,b)&&t.someProp("handleKeyDown",T=>T(t,Ph(8,"Backspace")))){Dc&&Ma&&t.domObserver.suppressSelectionUpdates();return}Ma&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Dc&&!E&&y.start()!=b.start()&&b.parentOffset==0&&y.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,b=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(T){return T(t,Ph(13,"Enter"))})},20));let w=x.start,A=x.endA,N=T=>{let O=T||t.state.tr.replace(w,A,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let k=f9(t,O.doc,u.sel);k&&!(Ma&&t.composing&&k.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(k.head==w||k.head==O.mapping.map(A)-1)||us&&k.empty&&k.head==w)&&O.setSelection(k)}return a&&O.setMeta("composition",a),O.scrollIntoView()},C;if(E)if(y.pos==b.pos){us&&vd<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>$c(t),20));let T=N(t.state.tr.delete(w,A)),O=d.resolve(x.start).marksAcross(d.resolve(x.endA));O&&T.ensureMarks(O),t.dispatch(T)}else if(x.endA==x.endB&&(C=T6e(y.parent.content.cut(y.parentOffset,b.parentOffset),v.parent.content.cut(v.parentOffset,x.endA-v.start())))){let T=N(t.state.tr);C.type=="add"?T.addMark(w,A,C.mark):T.removeMark(w,A,C.mark),t.dispatch(T)}else if(y.parent.child(y.index()).isText&&y.index()==b.index()-(b.textOffset?0:1)){let T=y.parent.textBetween(y.parentOffset,b.parentOffset),O=()=>N(t.state.tr.insertText(T,w,A));t.someProp("handleTextInput",k=>k(t,w,A,T,O))||t.dispatch(O())}else t.dispatch(N());else t.dispatch(N())}function f9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:p4(t,e.resolve(n.anchor),e.resolve(n.head))}function T6e(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(yt.from(u).eq(t))return{mark:l,type:o}}function C6e(t,e,n,r,i){if(n-e<=i.pos-r.pos||wk(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(wk(a,!0,!0));return!o.parent.isTextblock||o.pos>n||wk(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function wk(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 k6e(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&&m9(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&&m9(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function m9(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 Eee{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 X8e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(y9),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=x9(this),g9(this),this.nodeViews=b9(this),this.docView=X7(this.state.doc,p9(this),_k(this),this.dom,this),this.domObserver=new v6e(this,(r,i,a,o)=>A6e(this,r,i,a,o)),this.domObserver.start(),Y8e(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&&LP(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(y9),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&&(bee(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=b9(this);P6e(p,this.nodeViews)&&(this.nodeViews=p,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&LP(this),this.editable=x9(this),g9(this);let c=_k(this),u=p9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let g=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&u8e(this);if(o){this.domObserver.stop();let p=f&&(us||Ma)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&j6e(i.selection,e.selection);if(f){let x=Ma?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=c6e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=X7(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&D8e(this))?$c(this,p):(see(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():g&&d8e(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Kt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&$7(this,n.getBoundingClientRect(),e)}else $7(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 vee(e.slice,e.move,i<0?void 0:Kt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(us){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&h8e(this.dom),$c(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 x8e(this,e)}coordsAtPos(e,n=1){return QJ(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 w8e(this,n||this.state,e)}pasteHTML(e,n){return wb(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return wb(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return g4(this,e)}destroy(){this.docView&&(Z8e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_k(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,JBe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return J8e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ha&&this.root.nodeType===11&&i8e(this.dom.ownerDocument)==this.dom&&w6e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Eee.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function p9(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"),[Fa.node(0,t.state.doc.content.size,e)]}function g9(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:Fa.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function x9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function j6e(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 b9(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 P6e(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 y9(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 Id={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:"'"},SS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},R6e=typeof navigator<"u"&&/Mac/.test(navigator.platform),D6e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var da=0;da<10;da++)Id[48+da]=Id[96+da]=String(da);for(var da=1;da<=24;da++)Id[da+111]="F"+da;for(var da=65;da<=90;da++)Id[da]=String.fromCharCode(da+32),SS[da]=String.fromCharCode(da);for(var Sk in Id)SS.hasOwnProperty(Sk)||(SS[Sk]=Id[Sk]);function O6e(t){var e=R6e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||D6e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?SS:Id)[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 L6e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),I6e=typeof navigator<"u"&&/Win/.test(navigator.platform);function F6e(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))L6e?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 U6e(t){let e=Object.create(null);for(let n in t)e[F6e(n)]=t[n];return e}function Mk(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 z6e(t){return new Ur({props:{handleKeyDown:Nee(t)}})}function Nee(t){let e=U6e(t);return function(n,r){let i=O6e(r),a,o=e[Mk(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Mk(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(I6e&&r.ctrlKey&&r.altKey)&&(a=Id[r.keyCode])&&a!=i){let l=e[Mk(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var B6e=Object.defineProperty,w4=(t,e)=>{for(var n in e)B6e(t,n,{get:e[n],enumerable:!0})};function T2(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 C2=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,g])=>[f,(...x)=>{const y=this.buildProps(c,e),b=g(...x)(y);return o.push(b),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:T2({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}},Aee={};w4(Aee,{blur:()=>H6e,clearContent:()=>$6e,clearNodes:()=>V6e,command:()=>G6e,createParagraphNear:()=>W6e,cut:()=>q6e,deleteCurrentNode:()=>K6e,deleteNode:()=>X6e,deleteRange:()=>Y6e,deleteSelection:()=>Z6e,enter:()=>Q6e,exitCode:()=>J6e,extendMarkRange:()=>eHe,first:()=>tHe,focus:()=>rHe,forEach:()=>iHe,insertContent:()=>aHe,insertContentAt:()=>lHe,joinBackward:()=>dHe,joinDown:()=>uHe,joinForward:()=>hHe,joinItemBackward:()=>fHe,joinItemForward:()=>mHe,joinTextblockBackward:()=>pHe,joinTextblockForward:()=>gHe,joinUp:()=>cHe,keyboardShortcut:()=>bHe,lift:()=>yHe,liftEmptyBlock:()=>vHe,liftListItem:()=>_He,newlineInCode:()=>wHe,resetAttributes:()=>SHe,scrollIntoView:()=>MHe,selectAll:()=>EHe,selectNodeBackward:()=>NHe,selectNodeForward:()=>AHe,selectParentNode:()=>THe,selectTextblockEnd:()=>CHe,selectTextblockStart:()=>kHe,setContent:()=>jHe,setMark:()=>XHe,setMeta:()=>YHe,setNode:()=>ZHe,setNodeSelection:()=>QHe,setTextDirection:()=>JHe,setTextSelection:()=>e$e,sinkListItem:()=>t$e,splitBlock:()=>n$e,splitListItem:()=>r$e,toggleList:()=>i$e,toggleMark:()=>a$e,toggleNode:()=>s$e,toggleWrap:()=>o$e,undoInputRule:()=>l$e,unsetAllMarks:()=>c$e,unsetMark:()=>u$e,unsetTextDirection:()=>d$e,updateAttributes:()=>h$e,wrapIn:()=>f$e,wrapInList:()=>m$e});var H6e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),$6e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),V6e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),g=u.resolve(d.map(c+l.nodeSize)),p=f.blockRange(g);if(!p)return;const x=jg(p);if(l.type.isTextblock){const{defaultType:y}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,y)}(x||x===0)&&e.lift(p,x)})}),!0},G6e=t=>e=>t(e),W6e=()=>({state:t,dispatch:e})=>HJ(t,e),q6e=(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 tn(r.doc.resolve(Math.max(o-1,0)))),!0},K6e=()=>({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 xi(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 X6e=t=>({tr:e,state:n,dispatch:r})=>{const i=xi(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},Y6e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},Z6e=()=>({state:t,dispatch:e})=>l4(t,e),Q6e=()=>({commands:t})=>t.keyboardShortcut("Enter"),J6e=()=>({state:t,dispatch:e})=>FBe(t,e);function S4(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function MS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:S4(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Tee(t,e,n={}){return t.find(r=>r.type===e&&MS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function v9(t,e,n={}){return!!Tee(t,e,n)}function M4(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!Tee([...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&&v9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&v9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function su(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 eHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=su(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=M4(c,a,e);if(f&&f.from<=u&&f.to>=d){const g=tn.create(o,f.from,f.to);n.setSelection(g)}}return!0},tHe=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 Cee(t){return t instanceof tn}function Bh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function kee(t,e=null){if(!e)return null;const n=bn.atStart(t),r=bn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?tn.create(t,Bh(0,i,a),Bh(t.content.size,i,a)):tn.create(t,Bh(e,i,a),Bh(e,i,a))}function nHe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function E4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var rHe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(E4()||nHe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!Cee(n.state.selection))return o(),!0;const l=kee(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},iHe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),aHe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),jee=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&&jee(r)}return t};function i1(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 jee(n)}function Mb(t,e,n){if(t instanceof yd||t instanceof yt)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 yt.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),Mb("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new pJ({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?w0.fromSchema(c).parseSlice(i1(t),n.parseOptions):w0.fromSchema(c).parse(i1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=w0.fromSchema(e);return n.slice?a.parseSlice(i1(t),n.parseOptions).content:a.parse(i1(t),n.parseOptions)}return Mb("",e,n)}function sHe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof Gi||i instanceof Ki))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(bn.near(t.doc.resolve(o),n))}var oHe=t=>!("type"in t),lHe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=b=>{a.emit("contentError",{editor:a,error:b,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Mb(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(b){c(b)}try{l=Mb(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(b){return c(b),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,p=!0;if((oHe(l)?l:[l]).forEach(b=>{b.check(),g=g?b.isText&&b.marks.length===0:!1,p=p?b.isBlock:!1}),d===f&&p){const{parent:b}=r.doc.resolve(d);b.isTextblock&&!b.type.spec.code&&!b.childCount&&(d-=1,f+=1)}let y;if(g){if(Array.isArray(e))y=e.map(b=>b.text||"").join("");else if(e instanceof yt){let b="";e.forEach(v=>{v.text&&(b+=v.text)}),y=b}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,f)}else{y=l;const b=r.doc.resolve(d),v=b.node(),E=b.parentOffset===0,w=v.isText||v.isTextblock,A=v.content.size>0;E&&w&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,y)}n.updateSelection&&sHe(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},cHe=()=>({state:t,dispatch:e})=>OBe(t,e),uHe=()=>({state:t,dispatch:e})=>LBe(t,e),dHe=()=>({state:t,dispatch:e})=>OJ(t,e),hHe=()=>({state:t,dispatch:e})=>UJ(t,e),fHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=w2(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},mHe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=w2(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},pHe=()=>({state:t,dispatch:e})=>RBe(t,e),gHe=()=>({state:t,dispatch:e})=>DBe(t,e);function Pee(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xHe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))E4()||Pee()?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 bHe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=xHe(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 Fd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?xi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,g)=>{if(f.isText)return;const p=Math.max(r,g),x=Math.min(i,g+f.nodeSize);l.push({node:f,from:p,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>MS(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}var yHe=(t,e={})=>({state:n,dispatch:r})=>{const i=xi(t,n.schema);return Fd(n,i,e)?IBe(n,r):!1},vHe=()=>({state:t,dispatch:e})=>$J(t,e),_He=t=>({state:e,dispatch:n})=>{const r=xi(t,e.schema);return XBe(r)(e,n)},wHe=()=>({state:t,dispatch:e})=>BJ(t,e);function k2(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function _9(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 SHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=k2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=xi(t,r.schema)),l==="mark"&&(o=su(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,_9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(g=>{o===g.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(_9(g.attrs,e))))})})}),c},MHe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),EHe=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ls(t.doc);t.setSelection(n)}return!0},NHe=()=>({state:t,dispatch:e})=>IJ(t,e),AHe=()=>({state:t,dispatch:e})=>zJ(t,e),THe=()=>({state:t,dispatch:e})=>BBe(t,e),CHe=()=>({state:t,dispatch:e})=>VBe(t,e),kHe=()=>({state:t,dispatch:e})=>$Be(t,e);function IP(t,e,n={},r={}){return Mb(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var jHe=(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=IP(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 Ree(t,e){const n=su(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 Dee(t,e){const n=new jJ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function PHe(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 RHe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function DHe(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 j2(t){return e=>DHe(e.$from,t)}function Wt(t,e,n){return t.config[e]===void 0&&t.parent?Wt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Wt(t.parent,e,n):null}):t.config[e]}function N4(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Wt(e,"addExtensions",n);return r?[e,...N4(r())]:e}).flat(10)}function A4(t,e){const n=Lf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Oee(t){return typeof t=="function"}function Yn(t,e=void 0,...n){return Oee(t)?e?t.bind(e)(...n):t(...n):t}function OHe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ig(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 Lee(t){const e=[],{nodeExtensions:n,markExtensions:r}=ig(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=Wt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([g,p])=>{e.push({type:f,name:g,attribute:{...a,...p}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Wt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const g={...a,...f};typeof g?.default=="function"&&(g.default=g.default()),g?.isRequired&&g?.default===void 0&&delete g.default,e.push({type:o.name,name:d,attribute:g})})}),e}function Xr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),l.forEach(d=>{const[f,g]=d.split(":").map(p=>p.trim());u.set(f,g)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function ES(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Xr(n,r),{})}function LHe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function w9(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):LHe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function S9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&OHe(n)?!1:n!=null))}function M9(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 IHe(t,e){var n;const r=Lee(t),{nodeExtensions:i,markExtensions:a}=ig(t),o=(n=i.find(u=>Wt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((v,E)=>{const w=Wt(E,"extendNodeSchema",f);return{...v,...w?w(u):{}}},{}),p=S9({...g,content:Yn(Wt(u,"content",f)),marks:Yn(Wt(u,"marks",f)),group:Yn(Wt(u,"group",f)),inline:Yn(Wt(u,"inline",f)),atom:Yn(Wt(u,"atom",f)),selectable:Yn(Wt(u,"selectable",f)),draggable:Yn(Wt(u,"draggable",f)),code:Yn(Wt(u,"code",f)),whitespace:Yn(Wt(u,"whitespace",f)),linebreakReplacement:Yn(Wt(u,"linebreakReplacement",f)),defining:Yn(Wt(u,"defining",f)),isolating:Yn(Wt(u,"isolating",f)),attrs:Object.fromEntries(d.map(M9))}),x=Yn(Wt(u,"parseHTML",f));x&&(p.parseDOM=x.map(v=>w9(v,d)));const y=Wt(u,"renderHTML",f);y&&(p.toDOM=v=>y({node:v,HTMLAttributes:ES(v,d)}));const b=Wt(u,"renderText",f);return b&&(p.toText=b),[u.name,p]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(b=>b.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},g=t.reduce((b,v)=>{const E=Wt(v,"extendMarkSchema",f);return{...b,...E?E(u):{}}},{}),p=S9({...g,inclusive:Yn(Wt(u,"inclusive",f)),excludes:Yn(Wt(u,"excludes",f)),group:Yn(Wt(u,"group",f)),spanning:Yn(Wt(u,"spanning",f)),code:Yn(Wt(u,"code",f)),attrs:Object.fromEntries(d.map(M9))}),x=Yn(Wt(u,"parseHTML",f));x&&(p.parseDOM=x.map(b=>w9(b,d)));const y=Wt(u,"renderHTML",f);return y&&(p.toDOM=b=>y({mark:b,HTMLAttributes:ES(b,d)})),[u.name,p]}));return new pJ({topNode:o,nodes:l,marks:c})}function FHe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function T4(t){return t.sort((n,r)=>{const i=Wt(n,"priority")||100,a=Wt(r,"priority")||100;return i>a?-1:i<a?1:0})}function Iee(t){const e=T4(N4(t)),n=FHe(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 Fee(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 g;c.isBlock&&u>r&&(l+=a);const p=o?.[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(g=c?.text)==null?void 0:g.slice(Math.max(r,u)-u,i-u))}),l}function UHe(t,e){const n={from:0,to:t.content.size};return Fee(t,n,e)}function Uee(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function zHe(t,e){const n=xi(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 zee(t,e){const n=k2(typeof e=="string"?e:e.name,t.schema);return n==="node"?zHe(t,e):n==="mark"?Ree(t,e):{}}function BHe(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 HHe(t){const e=BHe(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 Bee(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),g=e.invert().map(d);r.push({oldRange:{from:f,to:g},newRange:{from:u,to:d}})})}),HHe(r)}function C4(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=M4(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var $He=(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 Ek(t,e){return e.nodes[t]||e.marks[t]||null}function z1(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 VHe=(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 FP(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?su(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>MS(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:g})=>{const p=f.pos,x=g.pos;t.doc.nodesBetween(p,x,(y,b)=>{if(!y.isText&&!y.marks.length)return;const v=Math.max(p,b),E=Math.min(x,b+y.nodeSize),w=E-v;o+=w,l.push(...y.marks.map(A=>({mark:A,from:v,to:E})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>MS(f.mark.attrs,n,{strict:!1})).reduce((f,g)=>f+g.to-g.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,g)=>f+g.to-g.from,0);return(c>0?c+u:c)>=o}function GHe(t,e,n={}){if(!e)return Fd(t,null,n)||FP(t,null,n);const r=k2(e,t.schema);return r==="node"?Fd(t,e,n):r==="mark"?FP(t,e,n):!1}var WHe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=j2(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)},qHe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function E9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function N9(t,e){const{nodeExtensions:n}=ig(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Yn(Wt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function P2(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&&(P2(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Hee(t){return t instanceof Kt}function KHe(t,e,n){var r;const{selection:i}=e;let a=null;if(Cee(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,g)=>{if(u)return!1;if(d.isInline){const p=!g||g.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=p&&x}return!u}),u})}var XHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=su(t,r.schema);if(i)if(o){const u=Ree(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(g,p)=>{const x=Math.max(p,d),y=Math.min(p+g.nodeSize,f);g.marks.find(v=>v.type===c)?g.marks.forEach(v=>{c===v.type&&n.addMark(x,y,c.create({...v.attrs,...e}))}):n.addMark(x,y,c.create(e))})});return KHe(r,n,c)},YHe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),ZHe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=xi(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})=>z7(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>z7(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},QHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Bh(t,0,r.content.size),a=Kt.create(r,i);e.setSelection(a)}return!0},JHe=(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},e$e=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=tn.atStart(r).from,l=tn.atEnd(r).to,c=Bh(i,o,l),u=Bh(a,o,l),d=tn.create(r,c,u);e.setSelection(d)}return!0},t$e=t=>({state:e,dispatch:n})=>{const r=xi(t,e.schema);return QBe(r)(e,n)};function A9(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 n$e=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=z1(u,l.node().type.name,l.node().attrs);if(a instanceof Kt&&a.node.isBlock)return!l.parentOffset||!Hc(o,l.pos)?!1:(r&&(t&&A9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,g=l.depth===0?void 0:PHe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=f&&g?[{type:g,attrs:d}]:void 0,x=Hc(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!x&&Hc(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(x=!0,p=g?[{type:g,attrs:d}]:void 0),r){if(x&&(a instanceof tn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),g&&!f&&!l.parentOffset&&l.parent.type!==g)){const y=e.mapping.map(l.before()),b=e.doc.resolve(y);l.node(-1).canReplaceWith(b.index(),b.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&A9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},r$e=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=xi(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const g=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let v=yt.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let O=c.depth-E;O>=c.depth-3;O-=1)v=yt.from(c.node(O).copy(v));const w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...z1(g,c.node().type.name,c.node().attrs),...e},N=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;v=v.append(yt.from(l.createAndFill(null,N)||void 0));const C=c.before(c.depth-(E-1));n.replace(C,c.after(-w),new Dt(v,4-E,0));let T=-1;n.doc.nodesBetween(C,n.doc.content.size,(O,k)=>{if(T>-1)return!1;O.isTextblock&&O.content.size===0&&(T=k+1)}),T>-1&&n.setSelection(tn.near(n.doc.resolve(T))),n.scrollIntoView()}return!0}const p=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...z1(g,f.type.name,f.attrs),...e},y={...z1(g,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const b=p?[{type:l,attrs:x},{type:p,attrs:y}]:[{type:l,attrs:x}];if(!Hc(n.doc,c.pos,2))return!1;if(i){const{selection:v,storedMarks:E}=r,{splittableMarks:w}=a.extensionManager,A=E||v.$to.parentOffset&&v.$from.marks();if(n.split(c.pos,2,b).scrollIntoView(),!A||!i)return!0;const N=A.filter(C=>w.includes(C.type.name));n.ensureMarks(N)}return!0},Nk=(t,e)=>{const n=j2(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&&Gd(t.doc,n.pos)&&t.join(n.pos),!0},Ak=(t,e)=>{const n=j2(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&&Gd(t.doc,r)&&t.join(r),!0},i$e=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:g}=i.extensionManager,p=xi(t,o.schema),x=xi(e,o.schema),{selection:y,storedMarks:b}=o,{$from:v,$to:E}=y,w=v.blockRange(E),A=b||y.$to.parentOffset&&y.$from.marks();if(!w)return!1;const N=j2(C=>N9(C.type.name,f))(y);if(w.depth>=1&&N&&w.depth-N.depth<=1){if(N.node.type===p)return u.liftListItem(x);if(N9(N.node.type.name,f)&&p.validContent(N.node.content)&&l)return c().command(()=>(a.setNodeMarkup(N.pos,p),!0)).command(()=>Nk(a,p)).command(()=>Ak(a,p)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(p,r)?!0:u.clearNodes()).wrapInList(p,r).command(()=>Nk(a,p)).command(()=>Ak(a,p)).run():c().command(()=>{const C=d().wrapInList(p,r),T=A.filter(O=>g.includes(O.type.name));return a.ensureMarks(T),C?!0:u.clearNodes()}).wrapInList(p,r).command(()=>Nk(a,p)).command(()=>Ak(a,p)).run()},a$e=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=su(t,r.schema);return FP(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},s$e=(t,e,n={})=>({state:r,commands:i})=>{const a=xi(t,r.schema),o=xi(e,r.schema),l=Fd(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})},o$e=(t,e={})=>({state:n,commands:r})=>{const i=xi(t,n.schema);return Fd(n,i,e)?r.lift(i):r.wrapIn(i,e)},l$e=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const o=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else o.delete(a.from,a.to)}return!0}}return!1},c$e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},u$e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=su(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:g,to:p}=l;const x=(a=u.marks().find(b=>b.type===c))==null?void 0:a.attrs,y=M4(u,c,x);y&&(g=y.from,p=y.to),n.removeMark(g,p,c)}else f.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,c)});return n.removeStoredMark(c),!0},d$e=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},h$e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=k2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=xi(t,r.schema)),l==="mark"&&(o=su(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let g,p,x,y;n.selection.empty?r.doc.nodesBetween(d,f,(b,v)=>{a&&a===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),g=v,p=b)}):r.doc.nodesBetween(d,f,(b,v)=>{v<d&&a&&a===b.type&&(c=!0,x=Math.max(v,d),y=Math.min(v+b.nodeSize,f),g=v,p=b),v>=d&&v<=f&&(a&&a===b.type&&(c=!0,i&&n.setNodeMarkup(v,void 0,{...b.attrs,...e})),o&&b.marks.length&&b.marks.forEach(E=>{if(o===E.type&&(c=!0,i)){const w=Math.max(v,d),A=Math.min(v+b.nodeSize,f);n.addMark(w,A,o.create({...E.attrs,...e}))}}))}),p&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...p.attrs,...e}),o&&p.marks.length&&p.marks.forEach(b=>{o===b.type&&i&&n.addMark(x,y,o.create({...b.attrs,...e}))}))}),c},f$e=(t,e={})=>({state:n,dispatch:r})=>{const i=xi(t,n.schema);return GBe(i,e)(n,r)},m$e=(t,e={})=>({state:n,dispatch:r})=>{const i=xi(t,n.schema);return WBe(i,e)(n,r)},p$e=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},R2=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},g$e=(t,e)=>{if(S4(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function a1(t){var e;const{editor:n,from:r,to:i,text:a,rules:o,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let d=!1;const f=VHe(u)+a;return o.forEach(g=>{if(d)return;const p=g$e(f,g.find);if(!p)return;const x=c.state.tr,y=T2({state:c.state,transaction:x}),b={from:r-(p[0].length-a.length),to:i},{commands:v,chain:E,can:w}=new C2({editor:n,state:y});g.handler({state:y,range:b,match:p,commands:v,chain:E,can:w})===null||!x.steps.length||(g.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function x$e(t){const{editor:e,rules:n}=t,r=new Ur({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=A4(yt.from(d),o.schema);const{from:f}=c,g=f+d.length;a1({editor:e,from:f,to:g,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return a1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&a1({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?a1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function b$e(t){return Object.prototype.toString.call(t).slice(8,-1)}function s1(t){return b$e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function $ee(t,e){const n={...t};return s1(t)&&s1(e)&&Object.keys(e).forEach(r=>{s1(e[r])&&s1(t[r])?n[r]=$ee(t[r],e[r]):n[r]=e[r]}),n}var k4=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Yn(Wt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Yn(Wt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>$ee(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}},qd=class Vee extends k4{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Vee(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 y$e(t){return typeof t=="number"}var v$e=class{constructor(t){this.find=t.find,this.handler=t.handler}},_$e=(t,e,n)=>{if(S4(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function w$e(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new C2({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(p,x)=>{var y,b,v,E,w;if((b=(y=p.type)==null?void 0:y.spec)!=null&&b.code||!(p.isText||p.isTextblock||p.isInline))return;const A=(w=(E=(v=p.content)==null?void 0:v.size)!=null?E:p.nodeSize)!=null?w:0,N=Math.max(r,x),C=Math.min(i,x+A);if(N>=C)return;const T=p.isText?p.text||"":p.textBetween(N-x,C-x,void 0,"");_$e(T,a.find,o).forEach(k=>{if(k.index===void 0)return;const R=N+k.index+1,z=R+k[0].length,D={from:n.tr.mapping.map(R),to:n.tr.mapping.map(z)},K=a.handler({state:n,range:D,match:k,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(K)})}),f.every(p=>p!==null)}var o1=null,S$e=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function M$e(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:g,rule:p,pasteEvt:x})=>{const y=d.tr,b=T2({state:d,transaction:y});if(!(!w$e({editor:e,state:b,from:Math.max(f-1,0),to:g.b-1,rule:p,pasteEvent:x,dropEvent:l})||!y.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return n.map(d=>new Ur({view(f){const g=x=>{var y;r=(y=f.dom.parentElement)!=null&&y.contains(x.target)?f.dom.parentElement:null,r&&(o1=e)},p=()=>{o1&&(o1=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(a=r===f.dom.parentElement,l=g,!a){const p=o1;p?.isEditable&&setTimeout(()=>{const x=p.state.selection;x&&p.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,g)=>{var p;const x=(p=g.clipboardData)==null?void 0:p.getData("text/html");return o=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(f,g,p)=>{const x=f[0],y=x.getMeta("uiEvent")==="paste"&&!i,b=x.getMeta("uiEvent")==="drop"&&!a,v=x.getMeta("applyPasteRules"),E=!!v;if(!y&&!b&&!E)return;if(E){let{text:N}=v;typeof N=="string"?N=N:N=A4(yt.from(N),p.schema);const{from:C}=v,T=C+N.length,O=S$e(N);return c({rule:d,state:p,from:C,to:{b:T},pasteEvt:O})}const w=g.doc.content.findDiffStart(p.doc.content),A=g.doc.content.findDiffEnd(p.doc.content);if(!(!y$e(w)||!A||w===A.b))return c({rule:d,state:p,from:w,to:A,pasteEvt:o})}}))}var D2=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Iee(t),this.schema=IHe(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:Ek(e.name,this.schema)},r=Wt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return T4([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ek(r.name,this.schema)},a=[],o=Wt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Wt(r,"exitable",i)&&(l.ArrowRight=()=>qd.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([p,x])=>[p,()=>x({editor:t})]));l={...l,...g}}const c=z6e(l);a.push(c);const u=Wt(r,"addInputRules",i);if(E9(r,t.options.enableInputRules)&&u){const g=u();if(g&&g.length){const p=x$e({editor:t,rules:g}),x=Array.isArray(p)?p:[p];a.push(...x)}}const d=Wt(r,"addPasteRules",i);if(E9(r,t.options.enablePasteRules)&&d){const g=d();if(g&&g.length){const p=M$e({editor:t,rules:g});a.push(...p)}}const f=Wt(r,"addProseMirrorPlugins",i);if(f){const g=f();a.push(...g)}return a})}get attributes(){return Lee(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ig(this.extensions);return Object.fromEntries(e.filter(n=>!!Wt(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:xi(n.name,this.schema)},a=Wt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,g)=>{const p=ES(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:g,editor:t,extension:n,HTMLAttributes:p})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=ig(this.extensions);return Object.fromEntries(e.filter(n=>!!Wt(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:su(n.name,this.schema)},a=Wt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=ES(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{U$e(l,t,f)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ek(e.name,this.schema)};e.type==="mark"&&((n=Yn(Wt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Wt(e,"onBeforeCreate",r),a=Wt(e,"onCreate",r),o=Wt(e,"onUpdate",r),l=Wt(e,"onSelectionUpdate",r),c=Wt(e,"onTransaction",r),u=Wt(e,"onFocus",r),d=Wt(e,"onBlur",r),f=Wt(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)})}};D2.resolve=Iee;D2.sort=T4;D2.flatten=N4;var E$e={};w4(E$e,{ClipboardTextSerializer:()=>Wee,Commands:()=>qee,Delete:()=>Kee,Drop:()=>Xee,Editable:()=>Yee,FocusEvents:()=>Qee,Keymap:()=>Jee,Paste:()=>ete,Tabindex:()=>tte,TextDirection:()=>nte,focusEventsPluginKey:()=>Zee});var hr=class Gee extends k4{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Gee(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Wee=hr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ur({key:new Oi("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=Uee(n);return Fee(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),qee=hr.create({name:"commands",addCommands(){return{...Aee}}}),Kee=hr.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=Dee(t.before,[t,...e]);Bee(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(x,y)=>{const b=y+x.nodeSize-2,v=p.oldRange.from<=y&&b<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:y,to:b,newFrom:d.mapping.map(y),newTo:d.mapping.map(b),deletedRange:p.oldRange,newRange:p.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:d})})});const g=d.mapping;d.steps.forEach((p,x)=>{var y,b;if(p instanceof Bo){const v=g.slice(x).map(p.from,-1),E=g.slice(x).map(p.to),w=g.invert().map(v,-1),A=g.invert().map(E),N=(y=d.doc.nodeAt(v-1))==null?void 0:y.marks.some(T=>T.eq(p.mark)),C=(b=d.doc.nodeAt(E))==null?void 0:b.marks.some(T=>T.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:w,to:A},newRange:{from:v,to:E},partial:!!(C||N),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()}}),Xee=hr.create({name:"drop",addProseMirrorPlugins(){return[new Ur({key:new Oi("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Yee=hr.create({name:"editable",addProseMirrorPlugins(){return[new Ur({key:new Oi("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Zee=new Oi("focusEvents"),Qee=hr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ur({key:Zee,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}}}})]}}),Jee=hr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:g,parent:p}=f,x=f.parent.isTextblock&&g>0?l.doc.resolve(g-1):f,y=x.parent.type.spec.isolating,b=f.pos-f.parentOffset,v=y&&x.parent.childCount===1?b===f.pos:bn.atStart(u).from===g;return!d||!p.type.isTextblock||p.textContent.length||!v||v&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return E4()||Pee()?a:i},addProseMirrorPlugins(){return[new Ur({key:new Oi("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(y=>y.getMeta("composition")))return;const r=t.some(y=>y.docChanged)&&!e.doc.eq(n.doc),i=t.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=bn.atStart(e.doc).from,u=bn.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!P2(n.doc))return;const g=n.tr,p=T2({state:n,transaction:g}),{commands:x}=new C2({editor:this.editor,state:p});if(x.clearNodes(),!!g.steps.length)return g}})]}}),ete=hr.create({name:"paste",addProseMirrorPlugins(){return[new Ur({key:new Oi("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),tte=hr.create({name:"tabindex",addProseMirrorPlugins(){return[new Ur({key:new Oi("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),nte=hr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ig(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 Ur({key:new Oi("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),N$e=class lp{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 lp(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 lp(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 lp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+(a?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new lp(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new lp(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&a.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},A$e=`.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 T$e(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var C$e=class extends p$e{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=kee(e,this.options.autofocus);this.editorState=pp.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=T$e(A$e,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Oee(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?[Yee,Wee.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),qee,Qee,Jee,tte,Xee,ete,Kee,nte.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 D2(r,this)}createCommandManager(){this.commandManager=new C2({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=IP(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=IP(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Eee(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return zee(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return GHe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return A4(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return UHe(this.state.doc,{blockSeparator:e,textSerializers:{...Uee(this.schema),...n}})}get isEmpty(){return P2(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 N$e(e,this)}get $doc(){return this.$pos(0)}};function ag(t){return new R2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Yn(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(C4(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const g=n.from+c+o.length;a.addMark(n.from+c,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function rte(t){return new R2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Yn(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,o+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function UP(t){return new R2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Yn(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function sg(t){return new R2({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Yn(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&s4(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=e,{splittableMarks:p}=t.editor.extensionManager,x=g||f.$to.parentOffset&&f.$from.marks();if(x){const y=x.filter(b=>p.includes(b.type.name));o.ensureMarks(y)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Gd(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var k$e=t=>"touches"in t,j$e=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,k$e(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,o;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function P$e(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Kt){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 R$e={};w4(R$e,{createAtomBlockMarkdownSpec:()=>D$e,createBlockMarkdownSpec:()=>O$e,createInlineMarkdownSpec:()=>F$e,parseAttributes:()=>j4,parseIndentedBlocks:()=>zP,renderNestedMarkdownContent:()=>R4,serializeAttributes:()=>P4});function j4(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const g=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),p=n[g];p&&(e[u]=p.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function P4(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 D$e(t){const{nodeName:e,name:n,parseAttributes:r=j4,serializeAttributes:i=P4,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(g=>{g in d&&(f[g]=d[g])}),f};return{parseMarkdown:(d,f)=>{const g={...a,...d.attributes};return f.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const g=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(f=d.match(g))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,g){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(p);if(!x)return;const y=x[1]||"",b=r(y);if(!o.find(E=>!(E in b)))return{type:e,raw:x[0],attributes:b}}},renderMarkdown:d=>{const f=u(d.attrs||{}),g=i(f),p=g?` {${g}}`:"";return`:::${c}${p} :::`}}}function O$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=j4,serializeAttributes:a=P4,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const g={};return c.forEach(p=>{p in f&&(g[p]=f[p])}),g};return{parseMarkdown:(f,g)=>{let p;if(r){const y=r(f);p=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?p=g.parseChildren(f.tokens||[]):p=g.parseInline(f.tokens||[]);const x={...o,...f.attributes};return g.createNode(e,x,p)},markdownTokenizer:{name:e,level:"block",start(f){var g;const p=new RegExp(`^:::${u}`,"m"),x=(g=f.match(p))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(f,g,p){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),b=f.match(y);if(!b)return;const[v,E=""]=b,w=i(E);let A=1;const N=v.length;let C="";const T=/^:::([\w-]*)(\s.*)?/gm,O=f.slice(N);for(T.lastIndex=0;;){const k=T.exec(O);if(k===null)break;const R=k.index,z=k[1];if(!((x=k[2])!=null&&x.endsWith(":::"))){if(z)A+=1;else if(A-=1,A===0){const D=O.slice(0,R);C=D.trim();const K=f.slice(0,N+R+k[0].length);let P=[];if(C)if(l==="block")for(P=p.blockTokens(D),P.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=p.inlineTokens(W.text))});P.length>0;){const W=P[P.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))P.pop();else break}else P=p.inlineTokens(C);return{type:e,raw:K,attributes:w,content:C,tokens:P}}}}}},renderMarkdown:(f,g)=>{const p=d(f.attrs||{}),x=a(p),y=x?` {${x}}`:"",b=g.renderChildren(f.content||[],`
- `);return`:::${u}${y}
- ${b}
- :::`}}}function L$e(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function I$e(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function F$e(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=L$e,serializeAttributes:a=I$e,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=g=>{if(!c)return g;const p={};return c.forEach(x=>{x in g&&(p[x]=g[x])}),p},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,p)=>{const x={...o,...g.attributes};if(l)return p.createNode(e,x);const y=r?r(g):g.content||"";return y?p.createNode(e,x,[p.createTextNode(y)]):p.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const p=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=g.match(p),y=x?.index;return y!==void 0?y:-1},tokenize(g,p,x){const y=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),b=g.match(y);if(!b)return;let v="",E="";if(l){const[,A]=b;E=A}else{const[,A,N]=b;E=A,v=N||""}const w=i(E.trim());return{type:e,raw:b[0],content:v.trim(),attributes:w}}},renderMarkdown:g=>{let p="";r?p=r(g):g.content&&g.content.length>0&&(p=g.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const x=d(g.attrs||{}),y=a(x),b=y?` ${y}`:"";return l?`[${u}${b}]`:`[${u}${b}]${p}[/${u}]`}}}function zP(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 g=l[d],p=g.match(e.itemPattern);if(!p){if(c.length>0)break;if(g.trim()===""){d+=1,u=`${u}${g}
- `;continue}else return}const x=e.extractItemData(p),{indentLevel:y,mainContent:b}=x;u=`${u}${g}
- `;const v=[b];for(d+=1;d<l.length;){const N=l[d];if(N.trim()===""){const T=l.slice(d+1).findIndex(R=>R.trim()!=="");if(T===-1)break;if((((i=(r=l[d+1+T].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){v.push(N),u=`${u}${N}
- `,d+=1;continue}else break}if((((o=(a=N.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>y)v.push(N),u=`${u}${N}
- `,d+=1;else break}let E;const w=v.slice(1);if(w.length>0){const N=w.map(C=>C.slice(y+f)).join(`
- `);N.trim()&&(e.customNestedParser?E=e.customNestedParser(N):E=n.blockTokens(N))}const A=e.createToken(x,E);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function R4(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(g=>g?e.indent(g):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function U$e(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(p=>{if(p!==o)return!1;f=p}),!f)return;let g=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(g=!0)}),g){const p=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,p)}}),a.docChanged&&e.view.dispatch(a)}var ms=class ite extends k4{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new ite(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function kf(t){return new v$e({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Yn(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),g=f+l.length;if(C4(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(b=>b===t.type&&b!==x.mark.type)).filter(x=>x.to>f).length)return null;g<n.to&&o.delete(g,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}var Tk,T9;function z$e(){return T9||(T9=1,Tk=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),Tk}var B$e=z$e();const H$e=_o(B$e);var $$e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},V$e=({contentComponent:t})=>{const e=sR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function G$e(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:aoe.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 W$e=class extends Cr.Component{constructor(t){var e;super(t),this.editorContentRef=Cr.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=G$e(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:$$e(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(V$e,{contentComponent:t.contentComponent})]})}},q$e=S.forwardRef((t,e)=>{const n=Cr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Cr.createElement(W$e,{key:n,innerRef:e,...t})}),K$e=Cr.memo(q$e),X$e=typeof window<"u"?S.useLayoutEffect:S.useEffect,Y$e=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 Z$e(t){var e;const[n]=S.useState(()=>new Y$e(t.editor)),r=YW.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:H$e);return X$e(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var Q$e=!1,BP=typeof window>"u",J$e=BP||!!(typeof window<"u"&&window.next),eVe=class ate{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?BP||J$e?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 C$e(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?ate.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 tVe(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new eVe(n)),i=sR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(i),S.useEffect(r.onRender(e)),Z$e({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var nVe=S.createContext({editor:null});nVe.Consumer;var rVe=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),iVe=()=>S.useContext(rVe);Cr.forwardRef((t,e)=>{const{onDragStart:n}=iVe(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Cr.createContext({markViewContentRef:()=>{}});var NS=(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]},aVe=/^\s*>\s$/,sVe=ms.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return NS("blockquote",{...Xr(this.options.HTMLAttributes,t),children:NS("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[sg({find:aVe,type:this.type})]}}),oVe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,lVe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,cVe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,uVe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,dVe=qd.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 NS("strong",{...Xr(this.options.HTMLAttributes,t),children:NS("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[ag({find:oVe,type:this.type}),ag({find:cVe,type:this.type})]},addPasteRules(){return[kf({find:lVe,type:this.type}),kf({find:uVe,type:this.type})]}}),hVe=/(^|[^`])`([^`]+)`(?!`)$/,fVe=/(^|[^`])`([^`]+)`(?!`)/g,mVe=qd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Xr(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ag({find:hVe,type:this.type})]},addPasteRules(){return[kf({find:fVe,type:this.type})]}}),Ck=4,pVe=/^```([a-z]+)?[\s\n]$/,gVe=/^~~~([a-z]+)?[\s\n]$/,xVe=ms.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ck,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Xr(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):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:Ck,{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(x=>l+x).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:Ck,{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 x=0,y=0;const b=u-d;for(let C=0;C<p.length;C+=1){if(y+p[C].length>=b){x=C;break}y+=p[C].length+1}const E=((c=p[x].match(/^ */))==null?void 0:c[0])||"",w=Math.min(E.length,n);if(w===0)return!0;let A=d;for(let C=0;C<x;C+=1)A+=p[C].length+1;return l.delete(A,A+w),u-A<=w&&l.setSelection(tn.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,g=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(p=>{var x;const y=((x=p.match(/^ */))==null?void 0:x[0])||"",b=Math.min(y.length,n);return p.slice(b)}).join(`
- `);return l.replaceWith(c,u,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
- `);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(bn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[UP({find:pVe,type:this.type,getAttributes:t=>({language:t[1]})}),UP({find:gVe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ur({key:new Oi("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(tn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),bVe=ms.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),yVe=ms.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Xr(this.options.HTMLAttributes,t)]},renderText(){return`
- `},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(g=>l.includes(g.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),vVe=ms.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Xr(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>UP({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),_Ve=ms.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Xr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!P$e(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Hee(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(tn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Kt.create(o.doc,c.pos)):o.setSelection(tn.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(tn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[rte({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),wVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,SVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,MVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,EVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,NVe=qd.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Xr(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ag({find:wVe,type:this.type}),ag({find:MVe,type:this.type})]},addPasteRules(){return[kf({find:SVe,type:this.type}),kf({find:EVe,type:this.type})]}});const AVe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",TVe="ελ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",HP="numeric",$P="ascii",VP="alpha",N0="asciinumeric",c0="alphanumeric",GP="domain",ste="emoji",CVe="scheme",kVe="slashscheme",kk="whitespace";function jVe(t,e){return t in e||(e[t]=[]),e[t]}function Hh(t,e,n){e[HP]&&(e[N0]=!0,e[c0]=!0),e[$P]&&(e[N0]=!0,e[VP]=!0),e[N0]&&(e[c0]=!0),e[VP]&&(e[c0]=!0),e[c0]&&(e[GP]=!0),e[ste]&&(e[GP]=!0);for(const r in e){const i=jVe(r,n);i.indexOf(t)<0&&i.push(t)}}function PVe(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function rs(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}rs.groups={};rs.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||rs.groups;let i;return e&&e.j?i=e:(i=new rs(e),n&&r&&Hh(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||rs.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new rs,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new rs,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(PVe(o.t,r),n);Hh(a,c,r)}else n&&Hh(a,n,r);o.t=a}return i.j[t]=o,o}};const mn=(t,e,n,r,i)=>t.ta(e,n,r,i),$r=(t,e,n,r,i)=>t.tr(e,n,r,i),C9=(t,e,n,r,i)=>t.ts(e,n,r,i),wt=(t,e,n,r,i)=>t.tt(e,n,r,i),vc="WORD",WP="UWORD",ote="ASCIINUMERICAL",lte="ALPHANUMERICAL",Eb="LOCALHOST",qP="TLD",KP="UTLD",B1="SCHEME",cp="SLASH_SCHEME",D4="NUM",XP="WS",O4="NL",A0="OPENBRACE",T0="CLOSEBRACE",AS="OPENBRACKET",TS="CLOSEBRACKET",CS="OPENPAREN",kS="CLOSEPAREN",jS="OPENANGLEBRACKET",PS="CLOSEANGLEBRACKET",RS="FULLWIDTHLEFTPAREN",DS="FULLWIDTHRIGHTPAREN",OS="LEFTCORNERBRACKET",LS="RIGHTCORNERBRACKET",IS="LEFTWHITECORNERBRACKET",FS="RIGHTWHITECORNERBRACKET",US="FULLWIDTHLESSTHAN",zS="FULLWIDTHGREATERTHAN",BS="AMPERSAND",HS="APOSTROPHE",$S="ASTERISK",Qu="AT",VS="BACKSLASH",GS="BACKTICK",WS="CARET",id="COLON",L4="COMMA",qS="DOLLAR",cl="DOT",KS="EQUALS",I4="EXCLAMATION",eo="HYPHEN",C0="PERCENT",XS="PIPE",YS="PLUS",ZS="POUND",k0="QUERY",F4="QUOTE",cte="FULLWIDTHMIDDLEDOT",U4="SEMI",ul="SLASH",j0="TILDE",QS="UNDERSCORE",ute="EMOJI",JS="SYM";var dte=Object.freeze({__proto__:null,ALPHANUMERICAL:lte,AMPERSAND:BS,APOSTROPHE:HS,ASCIINUMERICAL:ote,ASTERISK:$S,AT:Qu,BACKSLASH:VS,BACKTICK:GS,CARET:WS,CLOSEANGLEBRACKET:PS,CLOSEBRACE:T0,CLOSEBRACKET:TS,CLOSEPAREN:kS,COLON:id,COMMA:L4,DOLLAR:qS,DOT:cl,EMOJI:ute,EQUALS:KS,EXCLAMATION:I4,FULLWIDTHGREATERTHAN:zS,FULLWIDTHLEFTPAREN:RS,FULLWIDTHLESSTHAN:US,FULLWIDTHMIDDLEDOT:cte,FULLWIDTHRIGHTPAREN:DS,HYPHEN:eo,LEFTCORNERBRACKET:OS,LEFTWHITECORNERBRACKET:IS,LOCALHOST:Eb,NL:O4,NUM:D4,OPENANGLEBRACKET:jS,OPENBRACE:A0,OPENBRACKET:AS,OPENPAREN:CS,PERCENT:C0,PIPE:XS,PLUS:YS,POUND:ZS,QUERY:k0,QUOTE:F4,RIGHTCORNERBRACKET:LS,RIGHTWHITECORNERBRACKET:FS,SCHEME:B1,SEMI:U4,SLASH:ul,SLASH_SCHEME:cp,SYM:JS,TILDE:j0,TLD:qP,UNDERSCORE:QS,UTLD:KP,UWORD:WP,WORD:vc,WS:XP});const gc=/[a-z]/,Yx=new RegExp("\\p{L}","u"),jk=new RegExp("\\p{Emoji}","u"),xc=/\d/,Pk=/\s/,k9="\r",Rk=`
- `,RVe="️",DVe="",Dk="";let l1=null,c1=null;function OVe(t=[]){const e={};rs.groups=e;const n=new rs;l1==null&&(l1=j9(AVe)),c1==null&&(c1=j9(TVe)),wt(n,"'",HS),wt(n,"{",A0),wt(n,"}",T0),wt(n,"[",AS),wt(n,"]",TS),wt(n,"(",CS),wt(n,")",kS),wt(n,"<",jS),wt(n,">",PS),wt(n,"(",RS),wt(n,")",DS),wt(n,"「",OS),wt(n,"」",LS),wt(n,"『",IS),wt(n,"』",FS),wt(n,"<",US),wt(n,">",zS),wt(n,"&",BS),wt(n,"*",$S),wt(n,"@",Qu),wt(n,"`",GS),wt(n,"^",WS),wt(n,":",id),wt(n,",",L4),wt(n,"$",qS),wt(n,".",cl),wt(n,"=",KS),wt(n,"!",I4),wt(n,"-",eo),wt(n,"%",C0),wt(n,"|",XS),wt(n,"+",YS),wt(n,"#",ZS),wt(n,"?",k0),wt(n,'"',F4),wt(n,"/",ul),wt(n,";",U4),wt(n,"~",j0),wt(n,"_",QS),wt(n,"\\",VS),wt(n,"・",cte);const r=$r(n,xc,D4,{[HP]:!0});$r(r,xc,r);const i=$r(r,gc,ote,{[N0]:!0}),a=$r(r,Yx,lte,{[c0]:!0}),o=$r(n,gc,vc,{[$P]:!0});$r(o,xc,i),$r(o,gc,o),$r(i,xc,i),$r(i,gc,i);const l=$r(n,Yx,WP,{[VP]:!0});$r(l,gc),$r(l,xc,a),$r(l,Yx,l),$r(a,xc,a),$r(a,gc),$r(a,Yx,a);const c=wt(n,Rk,O4,{[kk]:!0}),u=wt(n,k9,XP,{[kk]:!0}),d=$r(n,Pk,XP,{[kk]:!0});wt(n,Dk,d),wt(u,Rk,c),wt(u,Dk,d),$r(u,Pk,d),wt(d,k9),wt(d,Rk),$r(d,Pk,d),wt(d,Dk,d);const f=$r(n,jk,ute,{[ste]:!0});wt(f,"#"),$r(f,jk,f),wt(f,RVe,f);const g=wt(f,DVe);wt(g,"#"),$r(g,jk,f);const p=[[gc,o],[xc,i]],x=[[gc,null],[Yx,l],[xc,a]];for(let y=0;y<l1.length;y++)Vu(n,l1[y],qP,vc,p);for(let y=0;y<c1.length;y++)Vu(n,c1[y],KP,WP,x);Hh(qP,{tld:!0,ascii:!0},e),Hh(KP,{utld:!0,alpha:!0},e),Vu(n,"file",B1,vc,p),Vu(n,"mailto",B1,vc,p),Vu(n,"http",cp,vc,p),Vu(n,"https",cp,vc,p),Vu(n,"ftp",cp,vc,p),Vu(n,"ftps",cp,vc,p),Hh(B1,{scheme:!0,ascii:!0},e),Hh(cp,{slashscheme:!0,ascii:!0},e),t=t.sort((y,b)=>y[0]>b[0]?1:-1);for(let y=0;y<t.length;y++){const b=t[y][0],E=t[y][1]?{[CVe]:!0}:{[kVe]:!0};b.indexOf("-")>=0?E[GP]=!0:gc.test(b)?xc.test(b)?E[N0]=!0:E[$P]=!0:E[HP]=!0,C9(n,b,b,E)}return C9(n,"localhost",Eb,{ascii:!0}),n.jd=new rs(JS),{start:n,tokens:Object.assign({groups:e},dte)}}function hte(t,e){const n=LVe(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,g=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,g=0,d=l):f>=0&&(f+=n[o].length,g++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=g,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function LVe(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 Vu(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new rs(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new rs(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function j9(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 Nb={defaultProtocol:"http",events:null,format:P9,formatHref:P9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function z4(t,e=null){let n=Object.assign({},Nb);t&&(n=Object.assign(n,t instanceof z4?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}z4.prototype={o:Nb,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]:Nb[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 P9(t){return t}function fte(t,e){this.t="token",this.v=t,this.tk=e}fte.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=Nb.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 O2(t,e){class n extends fte{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 R9=O2("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),D9=O2("text"),IVe=O2("nl"),u1=O2("url",{isLink:!0,toHref(t=Nb.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Eb&&t[1].t===id}}),Zs=t=>new rs(t);function FVe({groups:t}){const e=t.domain.concat([BS,$S,Qu,VS,GS,WS,qS,KS,eo,D4,C0,XS,YS,ZS,ul,JS,j0,QS]),n=[HS,id,L4,cl,I4,C0,k0,F4,U4,jS,PS,A0,T0,TS,AS,CS,kS,RS,DS,OS,LS,IS,FS,US,zS],r=[BS,HS,$S,VS,GS,WS,qS,KS,eo,A0,T0,C0,XS,YS,ZS,k0,ul,JS,j0,QS],i=Zs(),a=wt(i,j0);mn(a,r,a),mn(a,t.domain,a);const o=Zs(),l=Zs(),c=Zs();mn(i,t.domain,o),mn(i,t.scheme,l),mn(i,t.slashscheme,c),mn(o,r,a),mn(o,t.domain,o);const u=wt(o,Qu);wt(a,Qu,u),wt(l,Qu,u),wt(c,Qu,u);const d=wt(a,cl);mn(d,r,a),mn(d,t.domain,a);const f=Zs();mn(u,t.domain,f),mn(f,t.domain,f);const g=wt(f,cl);mn(g,t.domain,f);const p=Zs(R9);mn(g,t.tld,p),mn(g,t.utld,p),wt(u,Eb,p);const x=wt(f,eo);wt(x,eo,x),mn(x,t.domain,f),mn(p,t.domain,f),wt(p,cl,g),wt(p,eo,x);const y=wt(p,id);mn(y,t.numeric,R9);const b=wt(o,eo),v=wt(o,cl);wt(b,eo,b),mn(b,t.domain,o),mn(v,r,a),mn(v,t.domain,o);const E=Zs(u1);mn(v,t.tld,E),mn(v,t.utld,E),mn(E,t.domain,o),mn(E,r,a),wt(E,cl,v),wt(E,eo,b),wt(E,Qu,u);const w=wt(E,id),A=Zs(u1);mn(w,t.numeric,A);const N=Zs(u1),C=Zs();mn(N,e,N),mn(N,n,C),mn(C,e,N),mn(C,n,C),wt(E,ul,N),wt(A,ul,N);const T=wt(l,id),O=wt(c,id),k=wt(O,ul),R=wt(k,ul);mn(l,t.domain,o),wt(l,cl,v),wt(l,eo,b),mn(c,t.domain,o),wt(c,cl,v),wt(c,eo,b),mn(T,t.domain,N),wt(T,ul,N),wt(T,k0,N),mn(R,t.domain,N),mn(R,e,N),wt(R,ul,N);const z=[[A0,T0],[AS,TS],[CS,kS],[jS,PS],[RS,DS],[OS,LS],[IS,FS],[US,zS]];for(let D=0;D<z.length;D++){const[K,P]=z[D],W=wt(N,K);wt(C,K,W),wt(W,P,N);const Z=Zs(u1);mn(W,e,Z);const G=Zs();mn(W,n),mn(Z,e,Z),mn(Z,n,G),mn(G,e,Z),mn(G,n,G),wt(Z,P,N),wt(G,P,N)}return wt(i,Eb,E),wt(i,O4,IVe),{start:i,tokens:dte}}function UVe(t,e,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,g=-1;for(;i<r&&!(c=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(g=0,f=l):g>=0&&g++,i++,d++;if(g<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Ok(D9,e,o)),o=[]),i-=g,d-=g;const p=f.t,x=n.slice(i-d,i);a.push(Ok(p,e,x))}}return o.length>0&&a.push(Ok(D9,e,o)),a}function Ok(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 zVe=typeof console<"u"&&console&&console.warn||(()=>{}),BVe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Mr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function HVe(){return rs.groups={},Mr.scanner=null,Mr.parser=null,Mr.tokenQueue=[],Mr.pluginQueue=[],Mr.customSchemes=[],Mr.initialized=!1,Mr}function O9(t,e=!1){if(Mr.initialized&&zVe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${BVe}`),!/^[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`);Mr.customSchemes.push([t,e])}function $Ve(){Mr.scanner=OVe(Mr.customSchemes);for(let t=0;t<Mr.tokenQueue.length;t++)Mr.tokenQueue[t][1]({scanner:Mr.scanner});Mr.parser=FVe(Mr.scanner.tokens);for(let t=0;t<Mr.pluginQueue.length;t++)Mr.pluginQueue[t][1]({scanner:Mr.scanner,parser:Mr.parser});return Mr.initialized=!0,Mr}function B4(t){return Mr.initialized||$Ve(),UVe(Mr.parser.start,t,hte(Mr.scanner.start,t))}B4.scan=hte;function mte(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new z4(n),i=B4(t),a=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var H4="[\0- -\u2029 ]",VVe=new RegExp(H4),GVe=new RegExp(`${H4}$`),WVe=new RegExp(H4,"g");function qVe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function KVe(t){return new Ur({key:new Oi("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,l=Dee(n.doc,[...e]);if(Bee(l).forEach(({newRange:u})=>{const d=RHe(r.doc,u,p=>p.isTextblock);let f,g;if(d.length>1)f=d[0],g=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const p=r.doc.textBetween(u.from,u.to," "," ");if(!GVe.test(p))return;f=d[0],g=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const p=g.split(VVe).filter(Boolean);if(p.length<=0)return!1;const x=p[p.length-1],y=f.pos+g.lastIndexOf(x);if(!x)return!1;const b=B4(x).map(v=>v.toObject(t.defaultProtocol));if(!qVe(b))return!1;b.filter(v=>v.isLink).map(v=>({...v,from:y+v.start+1,to:y+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{C4(v.from,v.to,r.doc).some(E=>E.mark.type===t.type)||o.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!o.steps.length)return o}})}function XVe(t){return new Ur({key:new Oi("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(g=>g.nodeName==="A")}if(!o)return!1;const l=zee(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(a=o?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function YVe(t){return new Ur({key:new Oi("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=mte(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function _h(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(WVe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var pte=qd.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"){O9(t);return}O9(t.scheme,t.optionalSlashes)})},onDestroy(){HVe()},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)=>!!_h(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!_h(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=>!!_h(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Xr(this.options.HTMLAttributes,t),0]:["a",Xr(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!_h(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=>!!_h(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[kf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=mte(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!_h(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(KVe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!_h(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(XVe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(YVe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),ZVe=pte,QVe=Object.defineProperty,JVe=(t,e)=>{for(var n in e)QVe(t,n,{get:e[n],enumerable:!0})},e7e="listItem",L9="textStyle",I9=/^\s*([-+*])\s$/,gte=ms.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Xr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(e7e,this.editor.getAttributes(L9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=sg({find:I9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=sg({find:I9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(L9),editor:this.editor})),[t]}}),xte=ms.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Xr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>R4(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),t7e={};JVe(t7e,{findListItemPos:()=>yy,getNextListDepth:()=>$4,handleBackspace:()=>YP,handleDelete:()=>ZP,hasListBefore:()=>bte,hasListItemAfter:()=>n7e,hasListItemBefore:()=>yte,listItemHasSubList:()=>vte,nextListIsDeeper:()=>_te,nextListIsHigher:()=>wte});var yy=(t,e)=>{const{$from:n}=e.selection,r=xi(t,e.schema);let i=null,a=n.depth,o=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},$4=(t,e)=>{const n=yy(t,e);if(!n)return!1;const[,r]=$He(e,t,n.$pos.pos+4);return r},bte=(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))},yte=(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)},vte=(t,e,n)=>{if(!n)return!1;const r=xi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},YP=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Fd(t.state,e)&&bte(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((g,p)=>{g.type.name===e&&u.push({node:g,pos:p})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Fd(t.state,e)||!qHe(t.state))return!1;const r=yy(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=vte(e,t.state,a);return yte(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},_te=(t,e)=>{const n=$4(t,e),r=yy(t,e);return!r||!n?!1:n>r.depth},wte=(t,e)=>{const n=$4(t,e),r=yy(t,e);return!r||!n?!1:n<r.depth},ZP=(t,e)=>{if(!Fd(t.state,e)||!WHe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:_te(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():wte(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},n7e=(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)},Ste=hr.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&&ZP(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&&ZP(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&&YP(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&&YP(t,n,r)&&(e=!0)}),e}}}}),F9=/^(\s*)(\d+)\.\s+(.*)$/,r7e=/^\s/;function i7e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(F9);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const g=[i];for(;f<t.length;){const p=t[f];if(p.match(F9))break;if(p.trim()==="")g.push(p),d+=`
- `,f+=1;else if(p.match(r7e))g.push(p),d+=`
- ${p.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:g.join(`
- `)}),r=f,n=f}return[e,r]}function Mte(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 g=[];for(;f<t.length&&t[f].indent>e;)g.push(t[f]),f+=1;if(g.length>0){const p=Math.min(...g.map(y=>y.indent)),x=Mte(g,p,n);u.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(y=>y.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function a7e(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 s7e="listItem",U9="textStyle",z9=/^(\d+)\.\s$/,Ete=ms.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Xr(this.options.HTMLAttributes,n),0]:["ol",Xr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?a7e(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]=i7e(i);if(a.length===0)return;const l=Mte(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(s7e,this.editor.getAttributes(U9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=sg({find:z9,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=sg({find:z9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(U9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),o7e=/^\s*(\[([( |x])?\])\s$/,l7e=ms.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Xr(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return R4(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,g;l.ariaLabel=((g=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:g.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:g})=>{const p=n();if(typeof p!="number")return!1;const x=g.doc.nodeAt(p);return g.setNodeMarkup(p,void 0,{...x?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[sg({find:o7e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),c7e=ms.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Xr(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",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=zP(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=zP(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()}}});hr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(gte.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(xte.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Ste.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Ete.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(l7e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(c7e.configure(this.options.taskList)),t}});var u7e=ms.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Xr(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),d7e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,h7e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,f7e=qd.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Xr(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ag({find:d7e,type:this.type})]},addPasteRules(){return[kf({find:h7e,type:this.type})]}}),m7e=ms.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Nte=qd.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Xr(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),p7e=Nte;function g7e(t={}){return new Ur({view(e){return new x7e(e,t)}})}class x7e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,g=e.nodeAfter;if(f||g){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let x=p.getBoundingClientRect(),y=f?x.bottom:x.top;f&&g&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;r={left:x.left,right:x.right,top:y-b,bottom:y+b}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={left:f.left-g,right:f.left+g,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),g=f.width/c.offsetWidth,p=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,d=f.top-c.scrollTop*p}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=NJ(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 Gr extends bn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Gr.valid(r)?new Gr(r):bn.near(r)}content(){return Dt.empty}eq(e){return e instanceof Gr&&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 Gr(e.resolve(n.pos))}getBookmark(){return new V4(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!b7e(e)||!y7e(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&&Gr.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(Gr.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Kt.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(Gr.valid(l))return l}return null}}}Gr.prototype.visible=!1;Gr.findFrom=Gr.findGapCursorFrom;bn.jsonID("gapcursor",Gr);class V4{constructor(e){this.pos=e}map(e){return new V4(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Gr.valid(n)?new Gr(n):bn.near(n)}}function Ate(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function b7e(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||Ate(i.type))return!0;if(i.inlineContent)return!1}}return!0}function y7e(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||Ate(i.type))return!0;if(i.inlineContent)return!1}}return!0}function v7e(){return new Ur({props:{decorations:M7e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Gr.valid(n)?new Gr(n):null},handleClick:w7e,handleKeyDown:_7e,handleDOMEvents:{beforeinput:S7e}}})}const _7e=Nee({ArrowLeft:d1("horiz",-1),ArrowRight:d1("horiz",1),ArrowUp:d1("vert",-1),ArrowDown:d1("vert",1)});function d1(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 tn){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Gr.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Gr(u))),!0):!1}}function w7e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Gr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Kt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Gr(r))),!0)}function S7e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Gr))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=yt.empty;for(let o=r.length-1;o>=0;o--)i=yt.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Dt(i,0,0));return a.setSelection(tn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function M7e(t){if(!(t.selection instanceof Gr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Rr.create(t.doc,[Fa.widget(t.selection.head,e,{key:"gapcursor"})])}var eM=200,Xi=function(){};Xi.prototype.append=function(e){return e.length?(e=Xi.from(e),!this.length&&e||e.length<eM&&this.leafAppend(e)||this.length<eM&&e.leafPrepend(this)||this.appendInner(e)):this};Xi.prototype.prepend=function(e){return e.length?Xi.from(e).append(this):this};Xi.prototype.appendInner=function(e){return new E7e(this,e)};Xi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Xi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Xi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Xi.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Xi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Xi.from=function(e){return e instanceof Xi?e:e&&e.length?new Tte(e):Xi.empty};var Tte=(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<=eM)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=eM)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Xi);Xi.empty=new Tte([]);var E7e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Xi);const N7e=500;class Fo{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,g)=>{if(!f.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new dl(f.map));let p=f.step.map(i.slice(a)),x;p&&o.maybeStep(p).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new dl(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Fo(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let a=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),g=new dl(e.mapping.maps[d],f,n),p;(p=c&&c.merge(g))&&(g=p,d?a.pop():l=l.slice(0,l.length-1)),a.push(g),n&&(o++,n=void 0),i||(c=g)}let u=o-r.depth;return u>T7e&&(l=A7e(l,u),o-=u),new Fo(l.append(a),o)}remapping(e,n){let r=new yb;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 Fo(this.items.append(e.map(n=>new dl(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},i);let c=n;this.items.forEach(g=>{let p=a.getMirror(--c);if(p==null)return;o=Math.min(o,p);let x=a.maps[p];if(g.step){let y=e.steps[p].invert(e.docs[p]),b=g.selection&&g.selection.map(a.slice(c+1,p));b&&l++,r.push(new dl(x,y,b))}else r.push(new dl(x))},i);let u=[];for(let g=n;g<o;g++)u.push(new dl(a.maps[g]));let d=this.items.slice(0,i).append(u).append(r),f=new Fo(d,l);return f.emptyItemCount()>N7e&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&a++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&a++;let f=new dl(u.invert(),c,d),g,p=i.length-1;(g=i.length&&i[p].merge(f))?i[p]=g:i.push(f)}}else o.map&&r--},this.items.length,0),new Fo(Xi.from(i.reverse()),a)}}Fo.empty=new Fo(Xi.empty,0);function A7e(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 Ju{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const T7e=20;function C7e(t,e,n,r){let i=n.getMeta(nf),a;if(i)return i.historyState;n.getMeta(P7e)&&(t=new Ju(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(nf))return o.getMeta(nf).redo?new Ju(t.done.addTransform(n,void 0,r,H1(e)),t.undone,B9(n.mapping.maps),t.prevTime,t.prevComposition):new Ju(t.done,t.undone.addTransform(n,void 0,r,H1(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||!k7e(n,t.prevRanges)),u=o?Lk(t.prevRanges,n.mapping):B9(n.mapping.maps);return new Ju(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,H1(e)),Fo.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Ju(t.done.rebased(n,a),t.undone.rebased(n,a),Lk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ju(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Lk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function k7e(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 B9(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 Lk(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 j7e(t,e,n){let r=H1(e),i=nf.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 Ju(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(nf,{redo:n,historyState:c})}let Ik=!1,H9=null;function H1(t){let e=t.plugins;if(H9!=e){Ik=!1,H9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ik=!0;break}}return Ik}const nf=new Oi("history"),P7e=new Oi("closeHistory");function R7e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ur({key:nf,state:{init(){return new Ju(Fo.empty,Fo.empty,null,0,-1)},apply(e,n,r){return C7e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?kte:r=="historyRedo"?jte:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Cte(t,e){return(n,r)=>{let i=nf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=j7e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const kte=Cte(!1,!0),jte=Cte(!0,!0);hr.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 Ur({key:new Oi("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-i,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var D7e=hr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[g7e(this.options)]}});hr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ur({key:new Oi("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Rr.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(Fa.node(u,u+c.nodeSize,{class:this.options.className}))}),Rr.create(t,a)}}})]}});var O7e=hr.create({name:"gapCursor",addProseMirrorPlugins(){return[v7e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Yn(Wt(t,"allowGapCursor",n)))!=null?e:null}}});hr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Ur({key:new Oi("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&P2(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Fa.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Rr.create(t,i)}}})]}});hr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ur({key:new Oi("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Hee(n.selection)||t.view.dragging?null:Rr.create(n.doc,[Fa.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function $9({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var L7e=hr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Oi(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Ur({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,g=u.nodes[n];if(d)return c.insert(f,g.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!$9({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!$9({node:o,types:r})}}})]}}),I7e=hr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>kte(t,e),redo:()=>({state:t,dispatch:e})=>jte(t,e)}},addProseMirrorPlugins(){return[R7e(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()}}}),F7e=hr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(dVe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(sVe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(gte.configure(this.options.bulletList)),this.options.code!==!1&&i.push(mVe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(xVe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(bVe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(D7e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(O7e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(yVe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(vVe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(I7e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(_Ve.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(NVe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(xte.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Ste.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(pte.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Ete.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(u7e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(f7e.configure(this.options.strike)),this.options.text!==!1&&i.push(m7e.configure(this.options.text)),this.options.underline!==!1&&i.push(Nte.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(L7e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),U7e=F7e,z7e=hr.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")}}}),B7e=z7e,H7e=20,Pte=(t,e=0)=>{const n=[];return!t.children.length||e>H7e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Pte(r,e+1))}),n},$7e=t=>{if(!t.children.length)return;const e=Pte(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}`)})},Rte=qd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&$7e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Xr(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),V7e=hr.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()}}}),Dte=hr.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()}}}),G7e=hr.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()}}}),W7e=hr.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()}}}),q7e=hr.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()}}});hr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(V7e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Dte.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(G7e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(W7e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(q7e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Rte.configure(this.options.textStyle)),t}});var K7e=Dte,X7e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Y7e=ms.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Xr(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new j$e({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const g=a();g!==void 0&&this.editor.chain().setNodeSelection(g).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,g)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[rte({find:X7e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Z7e=Y7e;function QP({content:t,onChange:e,placeholder:n}){const r=tVe({extensions:[U7e.configure({heading:!1,codeBlock:!1,code:!1}),p7e,ZVe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),B7e.configure({types:["paragraph"]}),Rte,K7e,Z7e.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(ile,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(Vce,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(Dde,{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(MR,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(QG,{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(Nde,{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(wde,{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(Mde,{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(Lb,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(oW,{className:"w-4 h-4"})})]}),s.jsx(K$e,{editor:r})]})}function Ote({archiveId:t,archiveName:e,onClose:n}){const r=ln(),[i,a]=S.useState(!1),[o,l]=S.useState(null),[c,u]=S.useState({}),{data:d,isLoading:f,error:g}=ht({queryKey:["archive-project-page",t],queryFn:()=>be.getArchiveProjectPage(t)}),p=xt({mutationFn:N=>be.updateArchiveProjectPage(t,N),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});S.useEffect(()=>{const N=C=>{C.key==="Escape"&&(o!==null?l(null):i?v():n())};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],y=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},b=()=>{p.mutate(c)},v=()=>{a(!1),u({})},E=N=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],T=new DOMParser().parseFromString(N,"text/html"),O=k=>{if(k.nodeType===Node.TEXT_NODE)return k.textContent||"";if(k.nodeType===Node.ELEMENT_NODE){const R=k,z=R.tagName.toLowerCase();if(!C.includes(z))return Array.from(R.childNodes).map(O).join("");let D="";if(z==="a"&&R.getAttribute("href")){const P=R.getAttribute("href");P?.toLowerCase().startsWith("http")&&(D=` href="${P}" target="_blank" rel="noopener noreferrer"`)}if(z==="img"){const P=R.getAttribute("src");if(!P?.toLowerCase().startsWith("http"))return"";D=` src="${P}" style="max-width: 100%; height: auto;"`}const K=Array.from(R.childNodes).map(O).join("");return["br","img"].includes(z)?`<${z}${D} />`:`<${z}${D}>${K}</${z}>`}return""};return Array.from(T.body.childNodes).map(O).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),A=N=>{N.target===N.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(is,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:y,children:[s.jsx(uf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:v,children:"Cancel"}),s.jsxs(Te,{variant:"primary",size:"sm",onClick:b,disabled:p.isPending,children:[s.jsx(js,{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(zt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),g&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(is,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:N=>u({...c,title:N.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(f3,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:N=>u({...c,designer:N.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(f3,{className:"w-4 h-4"}),s.jsx("span",{children:d.designer}),d.designer_user_id&&s.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:s.jsx(qr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Wr,{className:"w-4 h-4"}),s.jsx("span",{children:d.creation_date})]}),i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(is,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:N=>u({...c,license:N.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(is,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(QP,{content:c.description||"",onChange:N=>u({...c,description:N}),placeholder:"Enter description..."}):s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:N=>u({...c,profile_title:N.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(QP,{content:c.profile_description||"",onChange:N=>u({...c,profile_description:N}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[s.jsx(Ob,{className:"w-4 h-4"}),"Images (",x.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((N,C)=>s.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:N.url,alt:N.name,className:"w-full h-full object-cover"})},N.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[s.jsx(qr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick:N=>{N.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(of,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:N=>N.stopPropagation()}),s.jsx("button",{onClick:N=>{N.stopPropagation(),l(Math.min(x.length-1,o+1))},disabled:o===x.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(Zo,{className:"w-6 h-6 text-white"})}),s.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:s.jsx(zt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const Q7e=[.25,.5,.75,1,1.5,2,3,4];function tp(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function J7e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=dr(),a=S.useRef(null),o=S.useRef(null),[l,c]=S.useState(!1),[u,d]=S.useState(0),[f,g]=S.useState(0),[p,x]=S.useState(0),[y,b]=S.useState(0),[v,E]=S.useState(1),[w,A]=S.useState(null),[N,C]=S.useState(null),[T,O]=S.useState(.8),[k,R]=S.useState(!1),{data:z,isLoading:D}=ht({queryKey:["timelapse-info",t],queryFn:()=>be.getTimelapseInfo(t)}),{data:K}=ht({queryKey:["timelapse-thumbnails",t],queryFn:()=>be.getTimelapseThumbnails(t,15)}),P=xt({mutationFn:()=>be.processTimelapse(t,{trimStart:p,trimEnd:y,speed:v,saveMode:"replace"},w||void 0),onSuccess:F=>{i(F.message,"success"),r?.(),n()},onError:F=>{i(F.message||"Processing failed","error")}});S.useEffect(()=>{z?.duration&&y===0&&b(z.duration)},[z?.duration,y]),S.useEffect(()=>{const F=V=>{V.key==="Escape"&&n()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[n]),S.useEffect(()=>{const F=a.current;if(!F)return;const V=()=>{const he=F.currentTime;d(he),he>=y&&(F.currentTime=p)},te=()=>{g(F.duration),y===0&&b(F.duration)},re=()=>c(!0),ae=()=>c(!1);return F.addEventListener("timeupdate",V),F.addEventListener("durationchange",te),F.addEventListener("play",re),F.addEventListener("pause",ae),()=>{F.removeEventListener("timeupdate",V),F.removeEventListener("durationchange",te),F.removeEventListener("play",re),F.removeEventListener("pause",ae)}},[p,y]),S.useEffect(()=>{const F=o.current,V=a.current;!F||!V||!N||(F.currentTime=V.currentTime,F.playbackRate=V.playbackRate,l&&!k?F.play().catch(()=>{}):F.pause())},[l,N,k]),S.useEffect(()=>{o.current&&(o.current.volume=k?0:T)},[T,k]),S.useEffect(()=>{a.current&&(a.current.playbackRate=v),o.current&&(o.current.playbackRate=v)},[v]);const W=S.useCallback(()=>{const F=a.current;F&&(l?F.pause():(F.currentTime<p&&(F.currentTime=p),F.play()))},[l,p]),Z=F=>{const V=a.current;V&&(V.currentTime=Math.max(p,Math.min(y,F)))},G=F=>{const V=F.target.files?.[0];V&&(N&&URL.revokeObjectURL(N),A(V),C(URL.createObjectURL(V)))},Y=()=>{N&&URL.revokeObjectURL(N),A(null),C(null)};S.useEffect(()=>()=>{N&&URL.revokeObjectURL(N)},[N]);const X=y-p,q=X/v;return D?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(gt,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(fd,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>P.mutate(),disabled:P.isPending,children:P.isPending?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(js,{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(zt,{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:!!N}),!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(Wc,{className:"w-8 h-8 text-white"})})}),N&&s.jsx("audio",{ref:o,src:N,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(Zue,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[tp(p)," - ",tp(y)," (",tp(X),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:K?.thumbnails.map((F,V)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${F})`}},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:F=>{const V=parseFloat(F.target.value);V<y-1&&(x(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:F=>{const V=parseFloat(F.target.value);V>p+1&&b(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:F=>Z(parseFloat(F.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(NR,{className:"w-5 h-5 text-white"}):s.jsx(Wc,{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(hM,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[v,"x (output: ",tp(q),")"]})]}),s.jsx("div",{className:"flex gap-1",children:Q7e.map(F=>s.jsxs("button",{onClick:()=>E(F),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${v===F?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[F,"x"]},F))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(h3,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),w?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(h3,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:w.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(w.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>R(!k),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:k?s.jsx(Vde,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Hde,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:T,onChange:F=>O(parseFloat(F.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:Y,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(vn,{className:"w-4 h-4 text-red-400"})})]}):s.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[s.jsx(qi,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange: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:"})," ",tp(f)," @ ",z?.width,"x",z?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",tp(q)," @ ",v,"x speed",w&&" + music overlay"]})]})]}),P.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(gt,{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 e9e=[.25,.5,.75,1,1.5,2,3,4];function Lte({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=S.useRef(null),[l,c]=S.useState(!0),[u,d]=S.useState(1),[f,g]=S.useState(0),[p,x]=S.useState(0),[y,b]=S.useState(!1);S.useEffect(()=>{const T=o.current;T&&(T.playbackRate=u)},[u]),S.useEffect(()=>{const T=O=>{O.key==="Escape"&&i()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[i]),S.useEffect(()=>{const T=o.current;if(!T)return;const O=()=>g(T.currentTime),k=()=>x(T.duration),R=()=>c(!0),z=()=>c(!1);return T.addEventListener("timeupdate",O),T.addEventListener("durationchange",k),T.addEventListener("play",R),T.addEventListener("pause",z),()=>{T.removeEventListener("timeupdate",O),T.removeEventListener("durationchange",k),T.removeEventListener("play",R),T.removeEventListener("pause",z)}},[]);const v=()=>{const T=o.current;T&&(l?T.pause():T.play())},E=T=>{const O=o.current;O&&(O.currentTime=parseFloat(T.target.value))},w=()=>{const T=o.current;T&&(T.currentTime=Math.max(0,T.currentTime-5))},A=()=>{const T=o.current;T&&(T.currentTime=Math.min(p,T.currentTime+5))},N=T=>{const O=Math.floor(T/60),k=Math.floor(T%60);return`${O}:${k.toString().padStart(2,"0")}`},C=()=>{const T=document.createElement("a");T.href=t,T.download=n,T.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(fd,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>b(!0),children:[s.jsx(qo,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(Mi,{className:"w-4 h-4"}),"Download"]}),s.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(zt,{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:N(f)}),s.jsx("input",{type:"range",min:0,max:p||100,value:f,onChange:E,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-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:N(p)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:w,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(cde,{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(NR,{className:"w-5 h-5 text-white"}):s.jsx(Wc,{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(tw,{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:e9e.map(T=>s.jsxs("button",{onClick:()=>d(T),className:`px-2 py-1 text-xs rounded transition-colors ${u===T?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[T,"x"]},T))})]})]})]})]})]}),y&&r&&s.jsx(J7e,{archiveId:r,timelapseSrc:t,onClose:()=>b(!1),onSave:a})]})}function G4({archiveId:t,archiveName:e,onClose:n}){const r=ln(),{showToast:i}=dr(),[a,o]=S.useState(null),[l,c]=S.useState("asap"),[u,d]=S.useState(""),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState(!1),[v,E]=S.useState(!1),[w,A]=S.useState({}),{data:N}=ht({queryKey:["printers"],queryFn:()=>be.getPrinters()}),{data:C}=ht({queryKey:["archive-filaments",t],queryFn:()=>be.getArchiveFilamentRequirements(t)}),{data:T}=ht({queryKey:["printer-status",a],queryFn:()=>be.getPrinterStatus(a),enabled:!!a});S.useEffect(()=>{N?.length===1&&!a&&o(N[0].id)},[N,a]),S.useEffect(()=>{A({})},[a]),S.useEffect(()=>{const Y=X=>{X.key==="Escape"&&n()};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[n]);const O=Y=>Y?`#${Y.replace("#","").substring(0,6)}`:"#808080",k=(Y,X,q,F)=>{const V=String.fromCharCode(65+(Y>=128?Y-128:Y));return q?`HT-${V}`:`AMS-${V} Slot ${X+1}`},R=(Y,X,q)=>Y*4+X,z=S.useMemo(()=>{const Y=[];if(T?.ams?.forEach(X=>{const q=X.tray.length===1;X.tray.forEach(F=>{if(F.tray_type){const V=O(F.tray_color);Y.push({type:F.tray_type,color:V,colorName:Bc(V),amsId:X.id,trayId:F.id,isHt:q,isExternal:!1,label:k(X.id,F.id,q),globalTrayId:R(X.id,F.id)})}})}),T?.vt_tray?.tray_type){const X=O(T.vt_tray.tray_color);Y.push({type:T.vt_tray.tray_type,color:X,colorName:Bc(X),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return Y},[T]),D=S.useMemo(()=>{if(!C?.filaments||C.filaments.length===0)return[];const Y=F=>F?F.replace("#","").toLowerCase().substring(0,6):"",X=(F,V,te=40)=>{const re=Y(F),ae=Y(V);if(!re||!ae||re.length<6||ae.length<6)return!1;const he=parseInt(re.substring(0,2),16),ue=parseInt(re.substring(2,4),16),ce=parseInt(re.substring(4,6),16),fe=parseInt(ae.substring(0,2),16),pe=parseInt(ae.substring(2,4),16),_e=parseInt(ae.substring(4,6),16);return Math.abs(he-fe)<=te&&Math.abs(ue-pe)<=te&&Math.abs(ce-_e)<=te},q=new Set(Object.values(w));return C.filaments.map(F=>{const V=F.slot_id||0;if(V>0&&w[V]!==void 0){const _e=w[V],ne=z.find(He=>He.globalTrayId===_e);if(ne){const He=ne.type?.toUpperCase()===F.type?.toUpperCase(),B=Y(ne.color)===Y(F.color)||X(ne.color,F.color);let H;return He&&B?H="match":He?H="type_only":H="mismatch",{...F,loaded:ne,hasFilament:!0,typeMatch:He,colorMatch:B,status:H,isManual:!0}}}const te=z.find(_e=>!q.has(_e.globalTrayId)&&_e.type?.toUpperCase()===F.type?.toUpperCase()&&Y(_e.color)===Y(F.color)),re=!te&&z.find(_e=>!q.has(_e.globalTrayId)&&_e.type?.toUpperCase()===F.type?.toUpperCase()&&X(_e.color,F.color)),ae=!te&&!re&&z.find(_e=>!q.has(_e.globalTrayId)&&_e.type?.toUpperCase()===F.type?.toUpperCase()),he=te||re||ae||void 0;he&&q.add(he.globalTrayId);const ue=!!he,ce=ue,fe=!!te||!!re;let pe;return te||re?pe="match":ae?pe="type_only":pe="mismatch",{...F,loaded:he,hasFilament:ue,typeMatch:ce,colorMatch:fe,status:pe,isManual:!1}})},[C,z,w]),K=S.useMemo(()=>{if(D.length===0)return;const Y=Math.max(...D.map(q=>q.slot_id||0));if(Y<=0)return;const X=new Array(Y).fill(-1);return D.forEach(q=>{q.slot_id&&q.slot_id>0&&(X[q.slot_id-1]=q.loaded?.globalTrayId??-1)}),X},[D]),P=C?.filaments&&C.filaments.length>0,W=xt({mutationFn:Y=>be.addToQueue(Y),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:Y=>{i(Y.message||"Failed to add to queue","error")}}),Z=Y=>{if(Y.preventDefault(),!a){i("Please select a printer","error");return}const X={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:p,manual_start:l==="manual",ams_mapping:K};l==="scheduled"&&u&&(X.scheduled_time=new Date(u).toISOString()),W.mutate(X)},G=()=>{const Y=new Date;return Y.setMinutes(Y.getMinutes()+1),Y.toISOString().slice(0,16)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsx(vt,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:Y=>Y.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(Wr,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Z,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),s.jsx("p",{className:"text-white font-medium truncate",children:e})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),N?.length===0?s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Na,{className:"w-4 h-4"}),"No printers configured"]}):s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:Y=>o(Y.target.value?Number(Y.target.value):null),required:!0,children:[s.jsx("option",{value:"",children:"Select printer..."}),N?.map(Y=>s.jsx("option",{value:Y.id,children:Y.name},Y.id))]})]}),a&&P&&s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>b(!y),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(z0,{className:"w-4 h-4",fill:D.some(Y=>Y.status==="mismatch")?"#f97316":D.some(Y=>Y.status==="type_only")?"#facc15":"#00ae42",stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),D.some(Y=>Y.status==="mismatch")?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):D.some(Y=>Y.status==="type_only")?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),y?s.jsx(zd,{className:"w-4 h-4 ml-auto"}):s.jsx(Aa,{className:"w-4 h-4 ml-auto"})]}),y&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.jsxs("button",{type:"button",onClick:async()=>{if(a){E(!0);try{await be.refreshPrinterStatus(a),await new Promise(Y=>setTimeout(Y,500)),await r.refetchQueries({queryKey:["printer-status",a]})}finally{E(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:v,children:[s.jsx(Dr,{className:`w-3 h-3 ${v?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),D.map((Y,X)=>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: ${Y.type} - ${Bc(Y.color)}`,children:s.jsx(z0,{className:"w-3 h-3",fill:Y.color,stroke:Y.color})}),s.jsxs("span",{className:"text-white truncate",children:[Y.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",Y.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:Y.loaded?.globalTrayId??"",onChange:q=>{const F=Y.slot_id||0;if(F>0){const V=q.target.value;A(V===""?te=>{const re={...te};return delete re[F],re}:te=>({...te,[F]:parseInt(V,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${Y.status==="match"?"border-bambu-green/50 text-bambu-green":Y.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${Y.isManual?"ring-1 ring-blue-400/50":""}`,title:Y.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),z.map(q=>s.jsxs("option",{value:q.globalTrayId,className:"bg-bambu-dark text-white",children:[q.label,": ",q.type," (",q.colorName,")"]},q.globalTrayId))]}),Y.status==="match"?s.jsx(ds,{className:"w-3 h-3 text-bambu-green"}):Y.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},X))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[s.jsx(ur,{className:"w-4 h-4"}),"ASAP"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[s.jsx(Wr,{className:"w-4 h-4"}),"Scheduled"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("manual"),children:[s.jsx(_R,{className:"w-4 h-4"}),"Queue Only"]})]})]}),l==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:Y=>d(Y.target.value),min:G(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:Y=>g(Y.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:Y=>x(Y.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(Ol,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:l==="asap"?"Print will start as soon as the printer is idle.":l==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Te,{type:"submit",className:"flex-1",disabled:W.isPending||!a||N?.length===0,children:W.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function t9e({archiveIds:t,onClose:e}){S.useEffect(()=>{const a=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=ht({queryKey:["archive-comparison",t],queryFn:()=>be.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(zt,{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(gt,{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(Cn,{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(n9e,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Te,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function n9e({comparison:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>s.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[s.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),s.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(Cn,{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(Cn,{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(ds,{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 r9e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function i9e(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 a9e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=S.useState(!1),[c,u]=S.useState(t.tags||""),[d,f]=S.useState(t.notes||""),[g,p]=S.useState(t.project_id),[x,y]=S.useState(!1);return s.jsx(vt,{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(YG,{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:r9e(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(ur,{className:"w-3 h-3"}),i9e(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(zd,{className:"w-5 h-5"}):s.jsx(Aa,{className:"w-5 h-5"})}),s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:g||void 0}),disabled:i,children:i?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ho,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:a,children:a?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(vn,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.jsx(Qn,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),y(!1)},onCancel:()=>y(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.jsx("input",{type:"text",value:c,onChange:b=>u(b.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:b=>f(b.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:g||"",onChange:b=>p(b.target.value?Number(b.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[s.jsx("option",{value:"",children:"No project"}),e.map(b=>s.jsx("option",{value:b.id,children:b.name},b.id))]})]})]})]})})}function s9e(){const t=ln(),{showToast:e}=dr(),[n,r]=S.useState(!1),[i,a]=S.useState(!1),[o,l]=S.useState(new Set),[c,u]=S.useState(new Set),{data:d,isLoading:f}=ht({queryKey:["pending-uploads"],queryFn:Nx.list,refetchInterval:1e4}),{data:g}=ht({queryKey:["projects"],queryFn:()=>be.getProjects()}),p=xt({mutationFn:({id:v,data:E})=>Nx.archive(v,E),onMutate:({id:v})=>{l(E=>new Set(E).add(v))},onSettled:(v,E,{id:w})=>{l(A=>{const N=new Set(A);return N.delete(w),N})},onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${v.print_name}`)},onError:v=>{e(v.message||"Failed to archive","error")}}),x=xt({mutationFn:v=>Nx.discard(v),onMutate:v=>{u(E=>new Set(E).add(v))},onSettled:(v,E,w)=>{u(A=>{const N=new Set(A);return N.delete(w),N})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:v=>{e(v.message||"Failed to discard","error")}}),y=xt({mutationFn:Nx.archiveAll,onSuccess:v=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${v.archived} files${v.failed>0?`, ${v.failed} failed`:""}`)},onError:v=>{e(v.message||"Failed to archive all","error")}}),b=xt({mutationFn:Nx.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(vt,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(gt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(vt,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(ci,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qi,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Ho,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:b.isPending,children:b.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(vn,{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(a9e,{upload:v,projects:g||[],onArchive:(E,w)=>p.mutate({id:E,data:w}),onDiscard:E=>x.mutate(E),isArchiving:o.has(v.id),isDiscarding:c.has(v.id)},v.id))})]})]}),n&&s.jsx(Qn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{y.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(Qn,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{b.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function tM(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Zx(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function o9e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system"}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const c=ln(),{showToast:u}=dr(),d=hW(),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState(!1),[v,E]=S.useState(!1),[w,A]=S.useState(!1),[N,C]=S.useState(!1),[T,O]=S.useState([]),[k,R]=S.useState(!1),[z,D]=S.useState(!1),[K,P]=S.useState(!1),[W,Z]=S.useState(!1),[G,Y]=S.useState(!1),[X,q]=S.useState(null),F=S.useRef(null),V=xt({mutationFn:ne=>be.uploadSource3mf(t.id,ne),onSuccess:ne=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${ne.filename}`)},onError:ne=>{u(ne.message||"Failed to upload source 3MF","error")}}),te=xt({mutationFn:()=>be.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:ne=>{u(ne.message||"Failed to remove source 3MF","error")}}),re=xt({mutationFn:()=>be.scanArchiveTimelapse(t.id),onSuccess:ne=>{ne.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${ne.filename}`)):ne.status==="exists"?u("Timelapse already attached"):ne.status==="not_found"&&ne.available_files&&ne.available_files.length>0?(O(ne.available_files),C(!0)):u(ne.message||"No matching timelapse found","warning")},onError:ne=>{u(ne.message||"Failed to scan for timelapse","error")}}),ae=xt({mutationFn:ne=>be.selectArchiveTimelapse(t.id,ne),onSuccess:ne=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${ne.filename}`),C(!1),O([])},onError:ne=>{u(ne.message||"Failed to attach timelapse","error")}}),he=xt({mutationFn:()=>be.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),ue=xt({mutationFn:()=>be.toggleFavorite(t.id),onSuccess:ne=>{c.invalidateQueries({queryKey:["archives"]}),u(ne.is_favorite?"Added to favorites":"Removed from favorites")}}),ce=xt({mutationFn:ne=>be.updateArchive(t.id,{project_id:ne}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),fe=ne=>{ne.preventDefault(),q({x:ne.clientX,y:ne.clientY})},_e=[...t.filename?.toLowerCase().includes(".gcode.")?[{label:"Print",icon:s.jsx(Ei,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>Z(!0)},{label:"Open in Bambu Studio",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const ne=t.print_name||t.filename||"model",He=`${window.location.origin}${be.getArchiveForSlicer(t.id,ne)}`;Ec(He)}}]:[{label:"Slice",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const ne=t.print_name||t.filename||"model",He=`${window.location.origin}${be.getArchiveForSlicer(t.id,ne)}`;Ec(He)}}],{label:"View on MakerWorld",icon:s.jsx(cf,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(vl,{className:"w-4 h-4"}),onClick:()=>g(!0)},{label:"View Timelapse",icon:s.jsx(fd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(eW,{className:"w-4 h-4"}),onClick:()=>re.mutate(),disabled:!t.printer_id||!!t.timelapse_path||re.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(Z1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ne=document.createElement("a");ne.href=be.getSource3mfDownloadUrl(t.id),ne.download=`${t.print_name||t.filename}_source.3mf`,ne.click()}else F.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(qi,{className:"w-4 h-4"}),onClick:()=>F.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(vn,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Mi,{className:"w-4 h-4"}),onClick:()=>{const ne=document.createElement("a");ne.href=be.getArchiveDownload(t.id),ne.download=`${t.print_name||t.filename}.3mf`,ne.click()}},{label:"Copy Download Link",icon:s.jsx(Wo,{className:"w-4 h-4"}),onClick:()=>{const ne=`${window.location.origin}${be.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ne).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(JG,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(jp,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(is,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(df,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ue.mutate()},{label:"Edit",icon:s.jsx(qo,{className:"w-4 h-4"}),onClick:()=>E(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ha,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ha,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const ne=[];if(t.project_id&&ne.push({label:"Remove from Project",icon:s.jsx(zt,{className:"w-4 h-4"}),onClick:()=>ce.mutate(null)}),!a)ne.push({label:"Loading...",icon:s.jsx(gt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const He=a.filter(B=>B.status==="active");He.length===0?ne.push({label:"No projects available",icon:s.jsx(ha,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):He.forEach(B=>{ne.push({label:B.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:B.color||"#888"}}),onClick:()=>ce.mutate(B.id),disabled:t.project_id===B.id})})}return ne})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Ed,{className:"w-4 h-4"}):s.jsx(Nd,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(vn,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0}];return s.jsxs(vt,{"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:fe,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:ne=>{ne.stopPropagation(),r(t.id)},children:n?s.jsx(Ed,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Nd,{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:be.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(Ob,{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:ne=>{ne.stopPropagation();const He=ne.currentTarget.getBoundingClientRect();q({x:He.left,y:He.bottom+4})},title:"Right-click for more options",children:s.jsx(gp,{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:ne=>{ne.stopPropagation(),ue.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(df,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&s.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&s.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[s.jsx(Wo,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&s.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ne=>{ne.stopPropagation();const He=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",B=`${window.location.origin}${be.getSource3mfForSlicer(t.id,He)}`;Ec(B)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(Z1,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&s.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ne=>{ne.stopPropagation(),A(!0)},title:"View timelapse",children:s.jsx(fd,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:ne=>{ne.stopPropagation(),D(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(jp,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&s.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]})]}),s.jsxs(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 ${t.filename?.toLowerCase().includes(".gcode.")?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:t.filename?.toLowerCase().includes(".gcode.")?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:t.filename?.toLowerCase().includes(".gcode.")?"GCODE":"SOURCE"}),t.project_name&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(ne=>ne.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(ne=>ne.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: ${Zx(t.print_time_seconds||0)}
- Actual: ${Zx(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Zx(t.actual_time_seconds)}`:`Estimated: ${Zx(t.print_time_seconds||0)}`,children:[s.jsx(ur,{className:"w-3 h-3"}),Zx(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(Gc,{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(Md,{className:"w-3 h-3"}),t.total_layers&&s.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`${t.object_count} object${t.object_count>1?"s":""}`,children:[s.jsx(vl,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ne,He)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ne},title:ne},He))})]})]}),(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(nW,{className:"w-3 h-3"})}),t.tags?.split(",").map((ne,He)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ne.trim()},He))]}),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:Lp(t.created_at,l)}),s.jsx("span",{children:tM(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[t.filename?.toLowerCase().includes(".gcode.")?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>x(!0),children:[s.jsx(Ei,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ne=t.print_name||t.filename||"model",He=`${window.location.origin}${be.getArchiveForSlicer(t.id,ne)}`;Ec(He)},title:"Open in Bambu Studio",children:s.jsx(qr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const ne=t.print_name||t.filename||"model",He=`${window.location.origin}${be.getArchiveForSlicer(t.id,ne)}`;Ec(He)},title:"Open in Bambu Studio to slice",children:[s.jsx(qr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:s.jsx(cf,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>g(!0),title:"3D Preview",children:s.jsx(vl,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ne=document.createElement("a");ne.href=be.getArchiveDownload(t.id),ne.download=`${t.print_name||t.filename}.3mf`,ne.click()},title:"Download",children:s.jsx(Mi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>E(!0),title:"Edit",children:s.jsx(qo,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:"Delete",children:s.jsx(vn,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),v&&s.jsx(YQ,{archive:t,onClose:()=>E(!1)}),f&&s.jsx(KQ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>g(!1)}),p&&s.jsx(XQ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1),onSuccess:()=>{}}),y&&s.jsx(Qn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{he.mutate(),b(!1)},onCancel:()=>b(!1)}),G&&s.jsx(Qn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{te.mutate(),Y(!1)},onCancel:()=>Y(!1)}),X&&s.jsx(ZQ,{x:X.x,y:X.y,items:_e,onClose:()=>q(null)}),w&&t.timelapse_path&&s.jsx(Lte,{src:be.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)}}),N&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{C(!1),O([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(ne=>s.jsxs("button",{onClick:()=>ae.mutate(ne.name),disabled:ae.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[s.jsx(fd,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:ne.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[tM(ne.size),ne.mtime&&` • ${Lp(ne.mtime,l)}`]})]})]},ne.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Te,{variant:"secondary",onClick:()=>{C(!1),O([])},className:"w-full",children:"Cancel"})})]})}),k&&s.jsx(QQ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),z&&t.photos&&t.photos.length>0&&s.jsx(JQ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>D(!1),onDelete:async ne=>{try{await be.deleteArchivePhoto(t.id,ne),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),K&&s.jsx(Ote,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),W&&s.jsx(G4,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Z(!1)}),s.jsx("input",{ref:F,type:"file",accept:".3mf",className:"hidden",onChange:ne=>{const He=ne.target.files?.[0];He&&V.mutate(He),ne.target.value=""}})]})}function l9e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=ln(),{showToast:c}=dr(),[u,d]=S.useState(!1),[f,g]=S.useState(!1),[p,x]=S.useState(!1),[y,b]=S.useState(!1),[v,E]=S.useState(!1),[w,A]=S.useState(!1),[N,C]=S.useState(!1),[T,O]=S.useState([]),[k,R]=S.useState(!1),[z,D]=S.useState(!1),[K,P]=S.useState(!1),[W,Z]=S.useState(!1),[G,Y]=S.useState(null),X=S.useRef(null),q=xt({mutationFn:pe=>be.uploadSource3mf(t.id,pe),onSuccess:pe=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${pe.filename}`)},onError:pe=>{c(pe.message||"Failed to upload source 3MF","error")}}),F=xt({mutationFn:()=>be.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:pe=>{c(pe.message||"Failed to remove source 3MF","error")}}),V=xt({mutationFn:()=>be.scanArchiveTimelapse(t.id),onSuccess:pe=>{pe.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${pe.filename}`)):pe.status==="exists"?c("Timelapse already attached"):pe.status==="not_found"&&pe.available_files&&pe.available_files.length>0?(O(pe.available_files),C(!0)):c(pe.message||"No matching timelapse found","warning")},onError:pe=>{c(pe.message||"Failed to scan for timelapse","error")}}),te=xt({mutationFn:pe=>be.selectArchiveTimelapse(t.id,pe),onSuccess:pe=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${pe.filename}`),C(!1),O([])},onError:pe=>{c(pe.message||"Failed to attach timelapse","error")}}),re=xt({mutationFn:()=>be.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),ae=xt({mutationFn:()=>be.toggleFavorite(t.id),onSuccess:pe=>{l.invalidateQueries({queryKey:["archives"]}),c(pe.is_favorite?"Added to favorites":"Removed from favorites")}}),he=xt({mutationFn:pe=>be.updateArchive(t.id,{project_id:pe}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),ue=pe=>{pe.preventDefault(),Y({x:pe.clientX,y:pe.clientY})},fe=[...t.filename?.toLowerCase().includes(".gcode.")?[{label:"Print",icon:s.jsx(Ei,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Schedule",icon:s.jsx(Wr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Open in Bambu Studio",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const pe=t.print_name||t.filename||"model",_e=`${window.location.origin}${be.getArchiveForSlicer(t.id,pe)}`;Ec(_e)}}]:[{label:"Slice",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>{const pe=t.print_name||t.filename||"model",_e=`${window.location.origin}${be.getArchiveForSlicer(t.id,pe)}`;Ec(_e)}}],{label:"View on MakerWorld",icon:s.jsx(cf,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:s.jsx(vl,{className:"w-4 h-4"}),onClick:()=>E(!0)},{label:"View Timelapse",icon:s.jsx(fd,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(eW,{className:"w-4 h-4"}),onClick:()=>V.mutate(),disabled:!t.printer_id||!!t.timelapse_path||V.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(Z1,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const pe=document.createElement("a");pe.href=be.getSource3mfDownloadUrl(t.id),pe.download=`${t.print_name||t.filename}_source.3mf`,pe.click()}else X.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(qi,{className:"w-4 h-4"}),onClick:()=>X.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(vn,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Mi,{className:"w-4 h-4"}),onClick:()=>{const pe=document.createElement("a");pe.href=be.getArchiveDownload(t.id),pe.download=`${t.print_name||t.filename}.3mf`,pe.click()}},{label:"Copy Download Link",icon:s.jsx(Wo,{className:"w-4 h-4"}),onClick:()=>{const pe=`${window.location.origin}${be.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(pe).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(JG,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(jp,{className:"w-4 h-4"}),onClick:()=>D(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(is,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(df,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ae.mutate()},{label:"Edit",icon:s.jsx(qo,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ha,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ha,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const pe=[];if(t.project_id&&pe.push({label:"Remove from Project",icon:s.jsx(zt,{className:"w-4 h-4"}),onClick:()=>he.mutate(null)}),!a)pe.push({label:"Loading...",icon:s.jsx(gt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const _e=a.filter(ne=>ne.status==="active");_e.length===0?pe.push({label:"No projects available",icon:s.jsx(ha,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):_e.forEach(ne=>{pe.push({label:ne.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:ne.color||"#888"}}),onClick:()=>he.mutate(ne.id),disabled:t.project_id===ne.id})})}return pe})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Ed,{className:"w-4 h-4"}):s.jsx(Nd,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(vn,{className:"w-4 h-4"}),onClick:()=>g(!0),danger:!0}];return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:ue,children:[s.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&s.jsx("button",{onClick:()=>r(t.id),children:n?s.jsx(Ed,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Nd,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:be.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(Ob,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),s.jsxs("div",{className:"col-span-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&s.jsx("span",{title:"Has timelapse",children:s.jsx(fd,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((pe,_e)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:pe},title:pe},_e))})]})]}),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:Op(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:tM(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const pe=t.print_name||t.filename||"model",_e=`${window.location.origin}${be.getArchiveForSlicer(t.id,pe)}`;Ec(_e)},title:"Open in Bambu Studio",children:s.jsx(qr,{className:"w-4 h-4"})}),t.makerworld_url&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>window.open(t.makerworld_url,"_blank"),title:"MakerWorld",children:s.jsx(cf,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const pe=document.createElement("a");pe.href=be.getArchiveDownload(t.id),pe.download=`${t.print_name||t.filename}.3mf`,pe.click()},title:"Download",children:s.jsx(Mi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>g(!0),title:"Delete",children:s.jsx(vn,{className:"w-4 h-4 text-red-400"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:pe=>{const _e=pe.currentTarget.getBoundingClientRect();Y({x:_e.left,y:_e.bottom+4})},title:"More options",children:s.jsx(gp,{className:"w-4 h-4"})})]})]}),u&&s.jsx(YQ,{archive:t,onClose:()=>d(!1)}),v&&s.jsx(KQ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>E(!1)}),p&&s.jsx(XQ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1),onSuccess:()=>{}}),f&&s.jsx(Qn,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{re.mutate(),g(!1)},onCancel:()=>g(!1)}),W&&s.jsx(Qn,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{F.mutate(),Z(!1)},onCancel:()=>Z(!1)}),G&&s.jsx(ZQ,{x:G.x,y:G.y,items:fe,onClose:()=>Y(null)}),w&&t.timelapse_path&&s.jsx(Lte,{src:be.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)}}),N&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{C(!1),O([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(pe=>s.jsxs("button",{onClick:()=>te.mutate(pe.name),disabled:te.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:pe.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:tM(pe.size)}),pe.mtime&&s.jsx("span",{children:Op(pe.mtime)})]})]},pe.name))})]})}),k&&s.jsx(QQ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),z&&t.photos&&s.jsx(JQ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>D(!1),onDelete:async pe=>{try{await be.deleteArchivePhoto(t.id,pe),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),K&&s.jsx(Ote,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),y&&s.jsx(G4,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),s.jsx("input",{ref:X,type:"file",accept:".3mf",className:"hidden",onChange:pe=>{const _e=pe.target.files?.[0];_e&&q.mutate(_e),pe.target.value=""}})]})}const c9e=[{id:"all",label:"All Archives",icon:s.jsx(bce,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(ur,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(Wr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(Wr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(df,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(Na,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(Wo,{className:"w-4 h-4"})}];function u9e(){const t=ln(),{showToast:e}=dr(),n=S.useRef(null),[r,i]=S.useState(""),[a,o]=S.useState(()=>{const ie=localStorage.getItem("archiveFilterPrinter");return ie?Number(ie):null}),[l,c]=S.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=S.useState(()=>{const ie=localStorage.getItem("archiveFilterColors");return ie?new Set(JSON.parse(ie)):new Set}),[f,g]=S.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[p,x]=S.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[y,b]=S.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[v,E]=S.useState(()=>localStorage.getItem("archiveFilterTag")),[w,A]=S.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[N,C]=S.useState(!1),[T,O]=S.useState([]),[k,R]=S.useState(!1),[z,D]=S.useState(new Set),[K,P]=S.useState(!1),[W,Z]=S.useState(!1),[G,Y]=S.useState(!1),[X,q]=S.useState(!1),[F,V]=S.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[te,re]=S.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[ae,he]=S.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ue,ce]=S.useState(!1),[fe,pe]=S.useState(!1),[_e,ne]=S.useState(!1),[He,B]=S.useState(null);S.useEffect(()=>{if(He){const ie=setTimeout(()=>{const xe=document.querySelector(`[data-archive-id="${He}"]`);xe&&xe.scrollIntoView({behavior:"smooth",block:"center"})},100),Ie=setTimeout(()=>B(null),5e3);return()=>{clearTimeout(ie),clearTimeout(Ie)}}},[He]);const{data:H,isLoading:le}=ht({queryKey:["archives",a],queryFn:()=>be.getArchives(a||void 0)}),{data:$}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:ee}=ht({queryKey:["projects"],queryFn:()=>be.getProjects()}),{data:de}=ht({queryKey:["settings"],queryFn:be.getSettings}),ke=de?.time_format||"system",we=xt({mutationFn:async ie=>(await Promise.all(ie.map(Ie=>be.deleteArchive(Ie))),ie.length),onSuccess:ie=>{t.invalidateQueries({queryKey:["archives"]}),D(new Set),e(`${ie} archive${ie!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});S.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),S.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),S.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),S.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),S.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",p.toString())},[p]),S.useEffect(()=>{localStorage.setItem("archiveHideFailed",y.toString())},[y]),S.useEffect(()=>{v?localStorage.setItem("archiveFilterTag",v):localStorage.removeItem("archiveFilterTag")},[v]),S.useEffect(()=>{localStorage.setItem("archiveFilterFileType",w)},[w]),S.useEffect(()=>{localStorage.setItem("archiveViewMode",F)},[F]),S.useEffect(()=>{localStorage.setItem("archiveSortBy",te)},[te]),S.useEffect(()=>{localStorage.setItem("archiveCollection",ae)},[ae]);const Ee=new Map($?.map(ie=>[ie.id,ie.name])||[]),U=[...new Set(H?.flatMap(ie=>ie.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),I=[...new Set(H?.flatMap(ie=>ie.filament_color?.split(",")||[]).filter(Boolean)||[])],se=[...new Set(H?.flatMap(ie=>ie.tags?.split(",").map(Ie=>Ie.trim())||[]).filter(Boolean)||[])].sort(),ye=H?.filter(ie=>{const Ie=new Date,xe=di(ie.created_at)||new Date(0);let Ue=!0;switch(ae){case"recent":Ue=Ie.getTime()-xe.getTime()<1440*60*1e3;break;case"this-week":Ue=Ie.getTime()-xe.getTime()<10080*60*1e3;break;case"this-month":Ue=xe.getMonth()===Ie.getMonth()&&xe.getFullYear()===Ie.getFullYear();break;case"favorites":Ue=ie.is_favorite===!0;break;case"failed":Ue=ie.status==="failed"||ie.status==="aborted";break;case"duplicates":Ue=ie.duplicate_count>0;break}const Pe=(ie.print_name||ie.filename).toLowerCase().includes(r.toLowerCase()),Me=!l||ie.filament_type?.split(", ").includes(l),Xe=ie.filament_color?.split(",")||[],ut=u.size===0||(f==="or"?Xe.some(Sn=>u.has(Sn)):[...u].every(Sn=>Xe.includes(Sn))),At=ae==="favorites"||!p||ie.is_favorite,St=ae==="failed"||!y||ie.status!=="failed"&&ie.status!=="aborted",Yt=ie.tags?.split(",").map(Sn=>Sn.trim())||[],Pt=!v||Yt.includes(v),Jt=ie.filename?.toLowerCase().includes(".gcode.");return Ue&&Pe&&Me&&ut&&At&&St&&Pt&&(w==="all"||w==="gcode"&&Jt||w==="source"&&!Jt)}).sort((ie,Ie)=>{switch(te){case"date-desc":return(di(Ie.created_at)?.getTime()||0)-(di(ie.created_at)?.getTime()||0);case"date-asc":return(di(ie.created_at)?.getTime()||0)-(di(Ie.created_at)?.getTime()||0);case"name-asc":return(ie.print_name||ie.filename).localeCompare(Ie.print_name||Ie.filename);case"name-desc":return(Ie.print_name||Ie.filename).localeCompare(ie.print_name||ie.filename);case"size-desc":return Ie.file_size-ie.file_size;case"size-asc":return ie.file_size-Ie.file_size;default:return 0}}),Se=K||z.size>0,ve=ie=>{D(Ie=>{const xe=new Set(Ie);return xe.has(ie)?xe.delete(ie):xe.add(ie),xe})},Be=()=>{ye&&D(new Set(ye.map(ie=>ie.id)))},Ge=()=>{D(new Set),P(!1)},Ke=ie=>{d(Ie=>{const xe=new Set(Ie);return xe.has(ie)?xe.delete(ie):xe.add(ie),xe})},ct=()=>{d(new Set)},$e=()=>{i(""),o(null),c(null),x(!1),b(!1),E(null),A("all")},ge=r||a||l||p||y||v||w!=="all",Je=S.useCallback(ie=>{ie.preventDefault(),ie.dataTransfer.types.includes("Files")&&R(!0)},[]),qe=S.useCallback(ie=>{ie.preventDefault(),ie.currentTarget===ie.target&&R(!1)},[]),Ze=S.useCallback(ie=>{ie.preventDefault(),R(!1);const Ie=Array.from(ie.dataTransfer.files).filter(xe=>xe.name.endsWith(".3mf"));Ie.length>0?(O(Ie),C(!0)):ie.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),lt=S.useCallback(ie=>{const Ie=ie.target;if(Ie.tagName==="INPUT"||Ie.tagName==="TEXTAREA"||Ie.isContentEditable){ie.key==="Escape"&&Ie.blur();return}switch(ie.key){case"/":ie.preventDefault(),n.current?.focus();break;case"u":case"U":!ie.metaKey&&!ie.ctrlKey&&(ie.preventDefault(),C(!0));break;case"Escape":Se&&Ge();break}},[Se]);return S.useEffect(()=>(document.addEventListener("keydown",lt),()=>document.removeEventListener("keydown",lt)),[lt]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:Je,onDragLeave:qe,onDrop:Ze,children:[k&&s.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:s.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[s.jsx(qi,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),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(Te,{variant:"secondary",size:"sm",onClick:Ge,children:[s.jsx(zt,{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:[z.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:Be,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Y(!0),children:[s.jsx(Dp,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>q(!0),children:[s.jsx(ha,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>{const ie=Array.from(z);Promise.all(ie.map(Ie=>be.toggleFavorite(Ie))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ie.length} archive${ie.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(df,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Te,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Z(!0),children:[s.jsx(vn,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:ae,onChange:ie=>he(ie.target.value),children:c9e.map(ie=>s.jsx("option",{value:ie.id,children:ie.label},ie.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[ye?.length||0," of ",H?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>ce(!ue),disabled:fe,children:[fe?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Q1,{className:"w-4 h-4"}),"Export"]}),ue&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{ce(!1),pe(!0);try{const{blob:ie,filename:Ie}=await be.exportArchives({format:"csv",printerId:a||void 0,status:ae==="failed"?"failed":void 0,search:r||void 0}),xe=URL.createObjectURL(ie),Ue=document.createElement("a");Ue.href=xe,Ue.download=Ie,Ue.click(),URL.revokeObjectURL(xe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[s.jsx(is,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{ce(!1),pe(!0);try{const{blob:ie,filename:Ie}=await be.exportArchives({format:"xlsx",printerId:a||void 0,status:ae==="failed"?"failed":void 0,search:r||void 0}),xe=URL.createObjectURL(ie),Ue=document.createElement("a");Ue.href=xe,Ue.download=Ie,Ue.click(),URL.revokeObjectURL(xe),e("Export downloaded")}catch{e("Export failed","error")}finally{pe(!1)}},children:[s.jsx(Q1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),z.size>=2&&z.size<=5&&s.jsxs(Te,{variant:"secondary",onClick:()=>ne(!0),children:[s.jsx(xp,{className:"w-4 h-4"}),"Compare (",z.size,")"]}),!Se&&s.jsxs(Te,{variant:"secondary",onClick:()=>P(!0),children:[s.jsx(Ed,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Te,{onClick:()=>C(!0),children:[s.jsx(qi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(vt,{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(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ie=>i(ie.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(vR,{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:ie=>o(ie.target.value?Number(ie.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),$?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Gc,{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:ie=>c(ie.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),U.map(ie=>s.jsx("option",{value:ie,children:ie},ie))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Z1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:w,onChange:ie=>A(ie.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>x(!p),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${p?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:p?"Show all":"Show favorites only",children:[s.jsx(df,{className:`w-4 h-4 ${p?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>b(!y),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${y?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:y?"Show failed prints":"Hide failed prints",children:[s.jsx(Na,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),se.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Dp,{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:ie=>E(ie.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),se.map(ie=>s.jsx("option",{value:ie,children:ie},ie))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(ele,{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:te,onChange:ie=>re(ie.target.value),children:[s.jsx("option",{value:"date-desc",children:"Newest first"}),s.jsx("option",{value:"date-asc",children:"Oldest first"}),s.jsx("option",{value:"name-asc",children:"Name A-Z"}),s.jsx("option",{value:"name-desc",children:"Name Z-A"}),s.jsx("option",{value:"size-desc",children:"Largest first"}),s.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${F==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("grid"),title:"Grid view",children:s.jsx(SR,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${F==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("list"),title:"List view",children:s.jsx(MR,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${F==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>V("calendar"),title:"Calendar view",children:s.jsx(mle,{className:"w-4 h-4"})})]})]}),ge&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:$e,className:"text-bambu-gray hover:text-white",children:[s.jsx(zt,{className:"w-4 h-4"}),"Reset"]})]}),I.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&s.jsx("button",{onClick:()=>g(ie=>ie==="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:I.map(ie=>s.jsx("button",{onClick:()=>Ke(ie),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ie)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ie},title:ie},ie))}),u.size>0&&s.jsxs("button",{onClick:ct,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(zt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(s9e,{}),le?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):ye?.length===0?s.jsx(vt,{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"})]})}):F==="calendar"?s.jsx(vt,{className:"p-6",children:s.jsx(Ize,{archives:ye||[],onArchiveClick:ie=>{i(""),V("grid"),B(ie.id)},highlightedArchiveId:He})}):F==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:ye?.map(ie=>s.jsx(o9e,{archive:ie,printerName:ie.printer_id?Ee.get(ie.printer_id)||"Unknown":"No Printer",isSelected:z.has(ie.id),onSelect:ve,selectionMode:Se,projects:ee,isHighlighted:ie.id===He,timeFormat:ke},ie.id))}):F==="list"?s.jsx(vt,{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"})]}),ye?.map(ie=>s.jsx(l9e,{archive:ie,printerName:ie.printer_id?Ee.get(ie.printer_id)||"Unknown":"No Printer",isSelected:z.has(ie.id),onSelect:ve,selectionMode:Se,projects:ee,isHighlighted:ie.id===He},ie.id))]})}):null,N&&s.jsx(Tze,{onClose:()=>{C(!1),O([])},initialFiles:T}),W&&s.jsx(Qn,{title:"Delete Archives",message:`Are you sure you want to delete ${z.size} archive${z.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${z.size}`,variant:"danger",onConfirm:()=>{we.mutate(Array.from(z)),Z(!1)},onCancel:()=>Z(!1)}),G&&s.jsx(jze,{selectedIds:Array.from(z),existingTags:se,onClose:()=>Y(!1)}),X&&s.jsx(Pze,{selectedIds:Array.from(z),onClose:()=>q(!1)}),_e&&z.size>=2&&z.size<=5&&s.jsx(t9e,{archiveIds:Array.from(z),onClose:()=>{ne(!1),D(new Set),P(!1)}})]})}function d9e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return S.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const L2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Pg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function W4(t){return"nodeType"in t}function ps(t){var e,n;return t?Pg(t)?t:W4(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function q4(t){const{Document:e}=ps(t);return t instanceof e}function vy(t){return Pg(t)?!1:t instanceof ps(t).HTMLElement}function Ite(t){return t instanceof ps(t).SVGElement}function Rg(t){return t?Pg(t)?t.document:W4(t)?q4(t)?t:vy(t)||Ite(t)?t.ownerDocument:document:document:document}const Rl=L2?S.useLayoutEffect:S.useEffect;function K4(t){const e=S.useRef(t);return Rl(()=>{e.current=t}),S.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function h9e(){const t=S.useRef(null),e=S.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function Ab(t,e){e===void 0&&(e=[t]);const n=S.useRef(t);return Rl(()=>{n.current!==t&&(n.current=t)},e),n}function _y(t,e){const n=S.useRef();return S.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function nM(t){const e=K4(t),n=S.useRef(null),r=S.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function JP(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Fk={};function wy(t,e){return S.useMemo(()=>{if(e)return e;const n=Fk[t]==null?0:Fk[t]+1;return Fk[t]=n,t+"-"+n},[t,e])}function Fte(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 Cp=Fte(1),Tb=Fte(-1);function f9e(t){return"clientX"in t&&"clientY"in t}function X4(t){if(!t)return!1;const{KeyboardEvent:e}=ps(t.target);return e&&t instanceof e}function m9e(t){if(!t)return!1;const{TouchEvent:e}=ps(t.target);return e&&t instanceof e}function eR(t){if(m9e(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 f9e(t)?{x:t.clientX,y:t.clientY}:null}const og=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[og.Translate.toString(t),og.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),V9="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function p9e(t){return t.matches(V9)?t:t.querySelector(V9)}const g9e={display:"none"};function x9e(t){let{id:e,value:n}=t;return Cr.createElement("div",{id:e,style:g9e},n)}function b9e(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 Cr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function y9e(){const[t,e]=S.useState("");return{announce:S.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Ute=S.createContext(null);function v9e(t){const e=S.useContext(Ute);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function _9e(){const[t]=S.useState(()=>new Set),e=S.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[S.useCallback(r=>{let{type:i,event:a}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const w9e={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.
- `},S9e={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 M9e(t){let{announcements:e=S9e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=w9e}=t;const{announce:a,announcement:o}=y9e(),l=wy("DndLiveRegion"),[c,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),v9e(S.useMemo(()=>({onDragStart(f){let{active:g}=f;a(e.onDragStart({active:g}))},onDragMove(f){let{active:g,over:p}=f;e.onDragMove&&a(e.onDragMove({active:g,over:p}))},onDragOver(f){let{active:g,over:p}=f;a(e.onDragOver({active:g,over:p}))},onDragEnd(f){let{active:g,over:p}=f;a(e.onDragEnd({active:g,over:p}))},onDragCancel(f){let{active:g,over:p}=f;a(e.onDragCancel({active:g,over:p}))}}),[a,e])),!c)return null;const d=Cr.createElement(Cr.Fragment,null,Cr.createElement(x9e,{id:r,value:i.draggable}),Cr.createElement(b9e,{id:l,announcement:o}));return n?Tc.createPortal(d,n):d}var wi;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(wi||(wi={}));function rM(){}function iM(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function zte(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return S.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Xo=Object.freeze({x:0,y:0});function Bte(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Hte(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function E9e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function G9(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 $te(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function W9(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 Vte=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=W9(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Bte(W9(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(Hte)},N9e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=G9(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=G9(c),d=i.reduce((g,p,x)=>g+Bte(u[x],p),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(Hte)};function A9e(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 T9e=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=A9e(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(E9e)};function C9e(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function Gte(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Xo}function k9e(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 j9e=k9e(1);function P9e(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 R9e(t,e,n){const r=P9e(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 D9e={ignoreTransform:!1};function Dg(t,e){e===void 0&&(e=D9e);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ps(t).getComputedStyle(t);u&&(n=R9e(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 q9(t){return Dg(t,{ignoreTransform:!0})}function O9e(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function L9e(t,e){return e===void 0&&(e=ps(t).getComputedStyle(t)),e.position==="fixed"}function I9e(t,e){e===void 0&&(e=ps(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 I2(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(q4(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!vy(i)||Ite(i)||n.includes(i))return n;const a=ps(t).getComputedStyle(i);return i!==t&&I9e(i,a)&&n.push(i),L9e(i,a)?n:r(i.parentNode)}return t?r(t):n}function Wte(t){const[e]=I2(t,1);return e??null}function Uk(t){return!L2||!t?null:Pg(t)?t:W4(t)?q4(t)||t===Rg(t).scrollingElement?window:vy(t)?t:null:null}function qte(t){return Pg(t)?t.scrollX:t.scrollLeft}function Kte(t){return Pg(t)?t.scrollY:t.scrollTop}function tR(t){return{x:qte(t),y:Kte(t)}}var Vi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Vi||(Vi={}));function Xte(t){return!L2||!t?!1:t===document.scrollingElement}function Yte(t){const e={x:0,y:0},n=Xte(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 F9e={x:.2,y:.2};function U9e(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=F9e);const{isTop:u,isBottom:d,isLeft:f,isRight:g}=Yte(t),p={x:0,y:0},x={x:0,y:0},y={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+y.height?(p.y=Vi.Backward,x.y=r*Math.abs((e.top+y.height-a)/y.height)):!d&&c>=e.bottom-y.height&&(p.y=Vi.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!g&&l>=e.right-y.width?(p.x=Vi.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!f&&o<=e.left+y.width&&(p.x=Vi.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:p,speed:x}}function z9e(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 Zte(t){return t.reduce((e,n)=>Cp(e,tR(n)),Xo)}function B9e(t){return t.reduce((e,n)=>e+qte(n),0)}function H9e(t){return t.reduce((e,n)=>e+Kte(n),0)}function $9e(t,e){if(e===void 0&&(e=Dg),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);Wte(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const V9e=[["x",["left","right"],B9e],["y",["top","bottom"],H9e]];class Y4{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=I2(n),i=Zte(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of V9e)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class P0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function G9e(t){const{EventTarget:e}=ps(t);return t instanceof e?t:Rg(t)}function zk(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var io;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(io||(io={}));function K9(t){t.preventDefault()}function W9e(t){t.stopPropagation()}var On;(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"})(On||(On={}));const Qte={start:[On.Space,On.Enter],cancel:[On.Esc],end:[On.Space,On.Enter,On.Tab]},q9e=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case On.Right:return{...n,x:n.x+25};case On.Left:return{...n,x:n.x-25};case On.Down:return{...n,y:n.y+25};case On.Up:return{...n,y:n.y-25}}};class F2{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new P0(Rg(n)),this.windowListeners=new P0(ps(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(io.Resize,this.handleCancel),this.windowListeners.add(io.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(io.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&$9e(r),n(Xo)}handleKeyDown(e){if(X4(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Qte,coordinateGetter:o=q9e,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Xo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const g=Tb(f,d),p={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const b=e.code,{isTop:v,isRight:E,isLeft:w,isBottom:A,maxScroll:N,minScroll:C}=Yte(y),T=z9e(y),O={x:Math.min(b===On.Right?T.right-T.width/2:T.right,Math.max(b===On.Right?T.left:T.left+T.width/2,f.x)),y:Math.min(b===On.Down?T.bottom-T.height/2:T.bottom,Math.max(b===On.Down?T.top:T.top+T.height/2,f.y))},k=b===On.Right&&!E||b===On.Left&&!w,R=b===On.Down&&!A||b===On.Up&&!v;if(k&&O.x!==f.x){const z=y.scrollLeft+g.x,D=b===On.Right&&z<=N.x||b===On.Left&&z>=C.x;if(D&&!g.y){y.scrollTo({left:z,behavior:l});return}D?p.x=y.scrollLeft-z:p.x=b===On.Right?y.scrollLeft-N.x:y.scrollLeft-C.x,p.x&&y.scrollBy({left:-p.x,behavior:l});break}else if(R&&O.y!==f.y){const z=y.scrollTop+g.y,D=b===On.Down&&z<=N.y||b===On.Up&&z>=C.y;if(D&&!g.x){y.scrollTo({top:z,behavior:l});return}D?p.y=y.scrollTop-z:p.y=b===On.Down?y.scrollTop-N.y:y.scrollTop-C.y,p.y&&y.scrollBy({top:-p.y,behavior:l});break}}this.handleMove(e,Cp(Tb(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()}}F2.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Qte,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 X9(t){return!!(t&&"distance"in t)}function Y9(t){return!!(t&&"delay"in t)}class Z4{constructor(e,n,r){var i;r===void 0&&(r=G9e(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=Rg(o),this.documentListeners=new P0(this.document),this.listeners=new P0(r),this.windowListeners=new P0(ps(o)),this.initialCoordinates=(i=eR(a))!=null?i:Xo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(io.Resize,this.handleCancel),this.windowListeners.add(io.DragStart,K9),this.windowListeners.add(io.VisibilityChange,this.handleCancel),this.windowListeners.add(io.ContextMenu,K9),this.documentListeners.add(io.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Y9(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(X9(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(io.Click,W9e,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(io.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=eR(e))!=null?n:Xo,u=Tb(i,c);if(!r&&l){if(X9(l)){if(l.tolerance!=null&&zk(u,l.tolerance))return this.handleCancel();if(zk(u,l.distance))return this.handleStart()}if(Y9(l)&&zk(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===On.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const K9e={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class U2 extends Z4{constructor(e){const{event:n}=e,r=Rg(n.target);super(e,K9e,r)}}U2.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 X9e={move:{name:"mousemove"},end:{name:"mouseup"}};var nR;(function(t){t[t.RightClick=2]="RightClick"})(nR||(nR={}));class Y9e extends Z4{constructor(e){super(e,X9e,Rg(e.event.target))}}Y9e.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===nR.RightClick?!1:(r?.({event:n}),!0)}}];const Bk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Z9e extends Z4{constructor(e){super(e,Bk)}static setup(){return window.addEventListener(Bk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Bk.move.name,e)};function e(){}}}Z9e.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 R0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(R0||(R0={}));var aM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(aM||(aM={}));function Q9e(t){let{acceleration:e,activator:n=R0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=aM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:g}=t;const p=eGe({delta:f,disabled:!a}),[x,y]=h9e(),b=S.useRef({x:0,y:0}),v=S.useRef({x:0,y:0}),E=S.useMemo(()=>{switch(n){case R0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case R0.DraggableRect:return i}},[n,i,c]),w=S.useRef(null),A=S.useCallback(()=>{const C=w.current;if(!C)return;const T=b.current.x*v.current.x,O=b.current.y*v.current.y;C.scrollBy(T,O)},[]),N=S.useMemo(()=>l===aM.TreeOrder?[...u].reverse():u,[l,u]);S.useEffect(()=>{if(!a||!u.length||!E){y();return}for(const C of N){if(r?.(C)===!1)continue;const T=u.indexOf(C),O=d[T];if(!O)continue;const{direction:k,speed:R}=U9e(C,O,E,e,g);for(const z of["x","y"])p[z][k[z]]||(R[z]=0,k[z]=0);if(R.x>0||R.y>0){y(),w.current=C,x(A,o),b.current=R,v.current=k;return}}b.current={x:0,y:0},v.current={x:0,y:0},y()},[e,A,r,y,a,o,JSON.stringify(E),JSON.stringify(p),x,u,N,d,JSON.stringify(g)])}const J9e={x:{[Vi.Backward]:!1,[Vi.Forward]:!1},y:{[Vi.Backward]:!1,[Vi.Forward]:!1}};function eGe(t){let{delta:e,disabled:n}=t;const r=JP(e);return _y(i=>{if(n||!r||!i)return J9e;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Vi.Backward]:i.x[Vi.Backward]||a.x===-1,[Vi.Forward]:i.x[Vi.Forward]||a.x===1},y:{[Vi.Backward]:i.y[Vi.Backward]||a.y===-1,[Vi.Forward]:i.y[Vi.Forward]||a.y===1}}},[n,e,r])}function tGe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return _y(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function nGe(t,e){return S.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...a]},[]),[t,e])}var Cb;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Cb||(Cb={}));var rR;(function(t){t.Optimized="optimized"})(rR||(rR={}));const Z9=new Map;function rGe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=S.useState(null),{frequency:l,measure:c,strategy:u}=i,d=S.useRef(t),f=b(),g=Ab(f),p=S.useCallback(function(v){v===void 0&&(v=[]),!g.current&&o(E=>E===null?v:E.concat(v.filter(w=>!E.includes(w))))},[g]),x=S.useRef(null),y=_y(v=>{if(f&&!n)return Z9;if(!v||v===Z9||d.current!==t||a!=null){const E=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){E.set(w.id,w.rect.current);continue}const A=w.node.current,N=A?new Y4(c(A),A):null;w.rect.current=N,N&&E.set(w.id,N)}return E}return v},[t,a,n,f,c]);return S.useEffect(()=>{d.current=t},[t]),S.useEffect(()=>{f||p()},[n,f]),S.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),S.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{p(),x.current=null},l))},[l,f,p,...r]),{droppableRects:y,measureDroppableContainers:p,measuringScheduled:a!=null};function b(){switch(u){case Cb.Always:return!1;case Cb.BeforeDragging:return n;default:return!n}}}function Jte(t,e){return _y(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function iGe(t,e){return Jte(t,e)}function aGe(t){let{callback:e,disabled:n}=t;const r=K4(e),i=S.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return S.useEffect(()=>()=>i?.disconnect(),[i]),i}function z2(t){let{callback:e,disabled:n}=t;const r=K4(e),i=S.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return S.useEffect(()=>()=>i?.disconnect(),[i]),i}function sGe(t){return new Y4(Dg(t),t)}function Q9(t,e,n){e===void 0&&(e=sGe);const[r,i]=S.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=aGe({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=z2({callback:a});return Rl(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function oGe(t){const e=Jte(t);return Gte(t,e)}const J9=[];function lGe(t){const e=S.useRef(t),n=_y(r=>t?r&&r!==J9&&t&&e.current&&t.parentNode===e.current.parentNode?r:I2(t):J9,[t]);return S.useEffect(()=>{e.current=t},[t]),n}function cGe(t){const[e,n]=S.useState(null),r=S.useRef(t),i=S.useCallback(a=>{const o=Uk(a.target);o&&n(l=>l?(l.set(o,tR(o)),new Map(l)):null)},[]);return S.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=Uk(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,tR(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=Uk(c);u?.removeEventListener("scroll",i)})}},[i,t]),S.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>Cp(a,o),Xo):Zte(t):Xo,[t,e])}function eG(t,e){e===void 0&&(e=[]);const n=S.useRef(null);return S.useEffect(()=>{n.current=null},e),S.useEffect(()=>{const r=t!==Xo;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Tb(t,n.current):Xo}function uGe(t){S.useEffect(()=>{if(!L2)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 dGe(t,e){return S.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function ene(t){return S.useMemo(()=>t?O9e(t):null,[t])}const tG=[];function hGe(t,e){e===void 0&&(e=Dg);const[n]=t,r=ene(n?ps(n):null),[i,a]=S.useState(tG);function o(){a(()=>t.length?t.map(c=>Xte(c)?r:new Y4(e(c),c)):tG)}const l=z2({callback:o});return Rl(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function fGe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return vy(e)?e:t}function mGe(t){let{measure:e}=t;const[n,r]=S.useState(null),i=S.useCallback(u=>{for(const{target:d}of u)if(vy(d)){r(f=>{const g=e(d);return f?{...f,width:g.width,height:g.height}:g});break}},[e]),a=z2({callback:i}),o=S.useCallback(u=>{const d=fGe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=nM(o);return S.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const pGe=[{sensor:U2,options:{}},{sensor:F2,options:{}}],gGe={current:{}},$1={draggable:{measure:q9},droppable:{measure:q9,strategy:Cb.WhileDragging,frequency:rR.Optimized},dragOverlay:{measure:Dg}};class D0 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 xGe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new D0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:rM},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$1,measureDroppableContainers:rM,windowRect:null,measuringScheduled:!1},bGe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:rM,draggableNodes:new Map,over:null,measureDroppableContainers:rM},B2=S.createContext(bGe),tne=S.createContext(xGe);function yGe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new D0}}}function vGe(t,e){switch(e.type){case wi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case wi.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case wi.DragEnd:case wi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case wi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new D0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case wi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new D0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case wi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new D0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function _Ge(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=S.useContext(B2),a=JP(r),o=JP(n?.id);return S.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!X4(a)||document.activeElement===a.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=p9e(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function wGe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function SGe(t){return S.useMemo(()=>({draggable:{...$1.draggable,...t?.draggable},droppable:{...$1.droppable,...t?.droppable},dragOverlay:{...$1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function MGe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=S.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Rl(()=>{if(!o&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=Gte(d,r);if(o||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const g=Wte(u);g&&g.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const nne=S.createContext({...Xo,scaleX:1,scaleY:1});var ed;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(ed||(ed={}));const rne=S.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=pGe,collisionDetection:f=T9e,measuring:g,modifiers:p,...x}=e;const y=S.useReducer(vGe,void 0,yGe),[b,v]=y,[E,w]=_9e(),[A,N]=S.useState(ed.Uninitialized),C=A===ed.Initialized,{draggable:{active:T,nodes:O,translate:k},droppable:{containers:R}}=b,z=T!=null?O.get(T):null,D=S.useRef({initial:null,translated:null}),K=S.useMemo(()=>{var Ue;return T!=null?{id:T,data:(Ue=z?.data)!=null?Ue:gGe,rect:D}:null},[T,z]),P=S.useRef(null),[W,Z]=S.useState(null),[G,Y]=S.useState(null),X=Ab(x,Object.values(x)),q=wy("DndDescribedBy",o),F=S.useMemo(()=>R.getEnabled(),[R]),V=SGe(g),{droppableRects:te,measureDroppableContainers:re,measuringScheduled:ae}=rGe(F,{dragging:C,dependencies:[k.x,k.y],config:V.droppable}),he=tGe(O,T),ue=S.useMemo(()=>G?eR(G):null,[G]),ce=xe(),fe=iGe(he,V.draggable.measure);MGe({activeNode:T!=null?O.get(T):null,config:ce.layoutShiftCompensation,initialRect:fe,measure:V.draggable.measure});const pe=Q9(he,V.draggable.measure,fe),_e=Q9(he?he.parentElement:null),ne=S.useRef({activatorEvent:null,active:null,activeNode:he,collisionRect:null,collisions:null,droppableRects:te,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),He=R.getNodeFor((n=ne.current.over)==null?void 0:n.id),B=mGe({measure:V.dragOverlay.measure}),H=(r=B.nodeRef.current)!=null?r:he,le=C?(i=B.rect)!=null?i:pe:null,$=!!(B.nodeRef.current&&B.rect),ee=oGe($?null:pe),de=ene(H?ps(H):null),ke=lGe(C?He??he:null),we=hGe(ke),Ee=wGe(p,{transform:{x:k.x-ee.x,y:k.y-ee.y,scaleX:1,scaleY:1},activatorEvent:G,active:K,activeNodeRect:pe,containerNodeRect:_e,draggingNodeRect:le,over:ne.current.over,overlayNodeRect:B.rect,scrollableAncestors:ke,scrollableAncestorRects:we,windowRect:de}),U=ue?Cp(ue,k):null,I=cGe(ke),se=eG(I),ye=eG(I,[pe]),Se=Cp(Ee,se),ve=le?j9e(le,Ee):null,Be=K&&ve?f({active:K,collisionRect:ve,droppableRects:te,droppableContainers:F,pointerCoordinates:U}):null,Ge=$te(Be,"id"),[Ke,ct]=S.useState(null),$e=$?Ee:Cp(Ee,ye),ge=C9e($e,(a=Ke?.rect)!=null?a:null,pe),Je=S.useRef(null),qe=S.useCallback((Ue,Pe)=>{let{sensor:Me,options:Xe}=Pe;if(P.current==null)return;const ut=O.get(P.current);if(!ut)return;const At=Ue.nativeEvent,St=new Me({active:P.current,activeNode:ut,event:At,options:Xe,context:ne,onAbort(Pt){if(!O.get(Pt))return;const{onDragAbort:Fn}=X.current,Sn={id:Pt};Fn?.(Sn),E({type:"onDragAbort",event:Sn})},onPending(Pt,Jt,Fn,Sn){if(!O.get(Pt))return;const{onDragPending:ft}=X.current,Ht={id:Pt,constraint:Jt,initialCoordinates:Fn,offset:Sn};ft?.(Ht),E({type:"onDragPending",event:Ht})},onStart(Pt){const Jt=P.current;if(Jt==null)return;const Fn=O.get(Jt);if(!Fn)return;const{onDragStart:Sn}=X.current,vr={activatorEvent:At,active:{id:Jt,data:Fn.data,rect:D}};Tc.unstable_batchedUpdates(()=>{Sn?.(vr),N(ed.Initializing),v({type:wi.DragStart,initialCoordinates:Pt,active:Jt}),E({type:"onDragStart",event:vr}),Z(Je.current),Y(At)})},onMove(Pt){v({type:wi.DragMove,coordinates:Pt})},onEnd:Yt(wi.DragEnd),onCancel:Yt(wi.DragCancel)});Je.current=St;function Yt(Pt){return async function(){const{active:Fn,collisions:Sn,over:vr,scrollAdjustedTranslate:ft}=ne.current;let Ht=null;if(Fn&&ft){const{cancelDrop:Qt}=X.current;Ht={activatorEvent:At,active:Fn,collisions:Sn,delta:ft,over:vr},Pt===wi.DragEnd&&typeof Qt=="function"&&await Promise.resolve(Qt(Ht))&&(Pt=wi.DragCancel)}P.current=null,Tc.unstable_batchedUpdates(()=>{v({type:Pt}),N(ed.Uninitialized),ct(null),Z(null),Y(null),Je.current=null;const Qt=Pt===wi.DragEnd?"onDragEnd":"onDragCancel";if(Ht){const mt=X.current[Qt];mt?.(Ht),E({type:Qt,event:Ht})}})}}},[O]),Ze=S.useCallback((Ue,Pe)=>(Me,Xe)=>{const ut=Me.nativeEvent,At=O.get(Xe);if(P.current!==null||!At||ut.dndKit||ut.defaultPrevented)return;const St={active:At};Ue(Me,Pe.options,St)===!0&&(ut.dndKit={capturedBy:Pe.sensor},P.current=Xe,qe(Me,Pe))},[O,qe]),lt=nGe(d,Ze);uGe(d),Rl(()=>{pe&&A===ed.Initializing&&N(ed.Initialized)},[pe,A]),S.useEffect(()=>{const{onDragMove:Ue}=X.current,{active:Pe,activatorEvent:Me,collisions:Xe,over:ut}=ne.current;if(!Pe||!Me)return;const At={active:Pe,activatorEvent:Me,collisions:Xe,delta:{x:Se.x,y:Se.y},over:ut};Tc.unstable_batchedUpdates(()=>{Ue?.(At),E({type:"onDragMove",event:At})})},[Se.x,Se.y]),S.useEffect(()=>{const{active:Ue,activatorEvent:Pe,collisions:Me,droppableContainers:Xe,scrollAdjustedTranslate:ut}=ne.current;if(!Ue||P.current==null||!Pe||!ut)return;const{onDragOver:At}=X.current,St=Xe.get(Ge),Yt=St&&St.rect.current?{id:St.id,rect:St.rect.current,data:St.data,disabled:St.disabled}:null,Pt={active:Ue,activatorEvent:Pe,collisions:Me,delta:{x:ut.x,y:ut.y},over:Yt};Tc.unstable_batchedUpdates(()=>{ct(Yt),At?.(Pt),E({type:"onDragOver",event:Pt})})},[Ge]),Rl(()=>{ne.current={activatorEvent:G,active:K,activeNode:he,collisionRect:ve,collisions:Be,droppableRects:te,draggableNodes:O,draggingNode:H,draggingNodeRect:le,droppableContainers:R,over:Ke,scrollableAncestors:ke,scrollAdjustedTranslate:Se},D.current={initial:le,translated:ve}},[K,he,Be,ve,O,H,le,te,R,Ke,ke,Se]),Q9e({...ce,delta:k,draggingRect:ve,pointerCoordinates:U,scrollableAncestors:ke,scrollableAncestorRects:we});const ie=S.useMemo(()=>({active:K,activeNode:he,activeNodeRect:pe,activatorEvent:G,collisions:Be,containerNodeRect:_e,dragOverlay:B,draggableNodes:O,droppableContainers:R,droppableRects:te,over:Ke,measureDroppableContainers:re,scrollableAncestors:ke,scrollableAncestorRects:we,measuringConfiguration:V,measuringScheduled:ae,windowRect:de}),[K,he,pe,G,Be,_e,B,O,R,te,Ke,re,ke,we,V,ae,de]),Ie=S.useMemo(()=>({activatorEvent:G,activators:lt,active:K,activeNodeRect:pe,ariaDescribedById:{draggable:q},dispatch:v,draggableNodes:O,over:Ke,measureDroppableContainers:re}),[G,lt,K,pe,v,q,O,Ke,re]);return Cr.createElement(Ute.Provider,{value:w},Cr.createElement(B2.Provider,{value:Ie},Cr.createElement(tne.Provider,{value:ie},Cr.createElement(nne.Provider,{value:ge},u)),Cr.createElement(_Ge,{disabled:l?.restoreFocus===!1})),Cr.createElement(M9e,{...l,hiddenTextDescribedById:q}));function xe(){const Ue=W?.autoScrollEnabled===!1,Pe=typeof c=="object"?c.enabled===!1:c===!1,Me=C&&!Ue&&!Pe;return typeof c=="object"?{...c,enabled:Me}:{enabled:Me}}}),EGe=S.createContext(null),nG="button",NGe="Draggable";function AGe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=wy(NGe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:g}=S.useContext(B2),{role:p=nG,roleDescription:x="draggable",tabIndex:y=0}=i??{},b=c?.id===e,v=S.useContext(b?nne:EGe),[E,w]=nM(),[A,N]=nM(),C=dGe(o,e),T=Ab(n);Rl(()=>(f.set(e,{id:e,key:a,node:E,activatorNode:A,data:T}),()=>{const k=f.get(e);k&&k.key===a&&f.delete(e)}),[f,e]);const O=S.useMemo(()=>({role:p,tabIndex:y,"aria-disabled":r,"aria-pressed":b&&p===nG?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,p,y,b,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:O,isDragging:b,listeners:r?void 0:C,node:E,over:g,setNodeRef:w,setActivatorNodeRef:N,transform:v}}function TGe(){return S.useContext(tne)}const CGe="Droppable",kGe={timeout:25};function jGe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=wy(CGe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=S.useContext(B2),d=S.useRef({disabled:n}),f=S.useRef(!1),g=S.useRef(null),p=S.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:b}={...kGe,...i},v=Ab(y??r),E=S.useCallback(()=>{if(!f.current){f.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),p.current=null},b)},[b]),w=z2({callback:E,disabled:x||!o}),A=S.useCallback((O,k)=>{w&&(k&&(w.unobserve(k),f.current=!1),O&&w.observe(O))},[w]),[N,C]=nM(A),T=Ab(e);return S.useEffect(()=>{!w||!N.current||(w.disconnect(),f.current=!1,w.observe(N.current))},[N,w]),S.useEffect(()=>(l({type:wi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:N,rect:g,data:T}}),()=>l({type:wi.UnregisterDroppable,key:a,id:r})),[r]),S.useEffect(()=>{n!==d.current.disabled&&(l({type:wi.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:g,isOver:c?.id===r,node:N,over:c,setNodeRef:C}}function H2(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function PGe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function h1(t){return t!==null&&t>=0}function RGe(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 DGe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const Q4=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=H2(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}},f1={scaleX:1,scaleY:1},OGe=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,...f1}:null}const c=LGe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...f1}:i<n&&i>=o?{x:0,y:l.height+c,...f1}:{x:0,y:0,...f1}};function LGe(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 ine="Sortable",ane=Cr.createContext({activeIndex:-1,containerId:ine,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Q4,disabled:{draggable:!1,droppable:!1}});function sne(t){let{children:e,id:n,items:r,strategy:i=Q4,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=TGe(),f=wy(ine,n),g=l.rect!==null,p=S.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=o!=null,y=o?p.indexOf(o.id):-1,b=u?p.indexOf(u.id):-1,v=S.useRef(p),E=!RGe(p,v.current),w=b!==-1&&y===-1||E,A=DGe(a);Rl(()=>{E&&x&&d(p)},[E,p,x,d]),S.useEffect(()=>{v.current=p},[p]);const N=S.useMemo(()=>({activeIndex:y,containerId:f,disabled:A,disableTransforms:w,items:p,overIndex:b,useDragOverlay:g,sortedRects:PGe(p,c),strategy:i}),[y,f,A.draggable,A.droppable,w,p,b,c,g,i]);return Cr.createElement(ane.Provider,{value:N},e)}const IGe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return H2(n,r,i).indexOf(e)},FGe=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},UGe={duration:200,easing:"ease"},one="transform",zGe=og.Transition.toString({property:one,duration:0,easing:"linear"}),BGe={roleDescription:"sortable"};function HGe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=S.useState(null),l=S.useRef(n);return Rl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Dg(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),S.useEffect(()=>{a&&o(null)},[a]),a}function lne(t){let{animateLayoutChanges:e=FGe,attributes:n,disabled:r,data:i,getNewIndex:a=IGe,id:o,strategy:l,resizeObserverConfig:c,transition:u=UGe}=t;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:x,sortedRects:y,overIndex:b,useDragOverlay:v,strategy:E}=S.useContext(ane),w=$Ge(r,p),A=d.indexOf(o),N=S.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),C=S.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:T,node:O,isOver:k,setNodeRef:R}=jGe({id:o,data:N,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:z,activatorEvent:D,activeNodeRect:K,attributes:P,setNodeRef:W,listeners:Z,isDragging:G,over:Y,setActivatorNodeRef:X,transform:q}=AGe({id:o,data:N,attributes:{...BGe,...n},disabled:w.draggable}),F=d9e(R,W),V=!!z,te=V&&!x&&h1(g)&&h1(b),re=!v&&G,ae=re&&te?q:null,ue=te?ae??(l??E)({rects:y,activeNodeRect:K,activeIndex:g,overIndex:b,index:A}):null,ce=h1(g)&&h1(b)?a({id:o,items:d,activeIndex:g,overIndex:b}):A,fe=z?.id,pe=S.useRef({activeId:fe,items:d,newIndex:ce,containerId:f}),_e=d!==pe.current.items,ne=e({active:z,containerId:f,isDragging:G,isSorting:V,id:o,index:A,items:d,newIndex:pe.current.newIndex,previousItems:pe.current.items,previousContainerId:pe.current.containerId,transition:u,wasDragging:pe.current.activeId!=null}),He=HGe({disabled:!ne,index:A,node:O,rect:T});return S.useEffect(()=>{V&&pe.current.newIndex!==ce&&(pe.current.newIndex=ce),f!==pe.current.containerId&&(pe.current.containerId=f),d!==pe.current.items&&(pe.current.items=d)},[V,ce,f,d]),S.useEffect(()=>{if(fe===pe.current.activeId)return;if(fe!=null&&pe.current.activeId==null){pe.current.activeId=fe;return}const H=setTimeout(()=>{pe.current.activeId=fe},50);return()=>clearTimeout(H)},[fe]),{active:z,activeIndex:g,attributes:P,data:N,rect:T,index:A,newIndex:ce,items:d,isOver:k,isSorting:V,isDragging:G,listeners:Z,node:O,overIndex:b,over:Y,setNodeRef:F,setActivatorNodeRef:X,setDroppableNodeRef:R,setDraggableNodeRef:W,transform:He??ue,transition:B()};function B(){if(He||_e&&pe.current.newIndex===A)return zGe;if(!(re&&!X4(D)||!u)&&(V||ne))return og.Transition.toString({...u,property:one})}}function $Ge(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 sM(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 VGe=[On.Down,On.Right,On.Up,On.Left],cne=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(VGe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=i.get(f.id);if(g)switch(t.code){case On.Down:r.top<g.top&&c.push(f);break;case On.Up:r.top>g.top&&c.push(f);break;case On.Left:r.left>g.left&&c.push(f);break;case On.Right:r.left<g.left&&c.push(f);break}});const u=N9e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=$te(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),g=a.get(d),p=g?i.get(g.id):null,x=g?.node.current;if(x&&p&&f&&g){const b=I2(x).some((C,T)=>l[T]!==C),v=une(f,g),E=GGe(f,g),w=b||!v?{x:0,y:0}:{x:E?r.width-p.width:0,y:E?r.height-p.height:0},A={x:p.left,y:p.top};return w.x&&w.y?A:Tb(A,w)}}}};function une(t,e){return!sM(t)||!sM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function GGe(t,e){return!sM(t)||!sM(e)||!une(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function WGe({item:t,onClose:e}){const n=ln(),{showToast:r}=dr(),[i,a]=S.useState(t.printer_id),o=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[l,c]=S.useState(()=>t.manual_start?"manual":t.scheduled_time&&!o?"scheduled":"asap"),[u,d]=S.useState(()=>t.scheduled_time&&!o?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,g]=S.useState(t.require_previous_success),[p,x]=S.useState(t.auto_off_after),[y,b]=S.useState(!1),[v,E]=S.useState(!1),[w,A]=S.useState(()=>{if(t.ams_mapping&&Array.isArray(t.ams_mapping)){const X={};return t.ams_mapping.forEach((q,F)=>{q!==-1&&(X[F+1]=q)}),X}return{}}),{data:N}=ht({queryKey:["printers"],queryFn:()=>be.getPrinters()}),{data:C}=ht({queryKey:["archive-filaments",t.archive_id],queryFn:()=>be.getArchiveFilamentRequirements(t.archive_id)}),{data:T}=ht({queryKey:["printer-status",i],queryFn:()=>be.getPrinterStatus(i),enabled:!!i}),[O]=S.useState(t.printer_id);S.useEffect(()=>{i!==O&&A({})},[i,O]),S.useEffect(()=>{const X=q=>{q.key==="Escape"&&e()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e]);const k=X=>X?`#${X.replace("#","").substring(0,6)}`:"#808080",R=(X,q,F,V)=>{const te=String.fromCharCode(65+(X>=128?X-128:X));return F?`HT-${te}`:`AMS-${te} Slot ${q+1}`},z=(X,q,F)=>X*4+q,D=S.useMemo(()=>{const X=[];if(T?.ams?.forEach(q=>{const F=q.tray.length===1;q.tray.forEach(V=>{if(V.tray_type){const te=k(V.tray_color);X.push({type:V.tray_type,color:te,colorName:Bc(te),amsId:q.id,trayId:V.id,isHt:F,isExternal:!1,label:R(q.id,V.id,F),globalTrayId:z(q.id,V.id)})}})}),T?.vt_tray?.tray_type){const q=k(T.vt_tray.tray_color);X.push({type:T.vt_tray.tray_type,color:q,colorName:Bc(q),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return X},[T]),K=S.useMemo(()=>{if(!C?.filaments||C.filaments.length===0)return[];const X=V=>V?V.replace("#","").toLowerCase().substring(0,6):"",q=(V,te,re=40)=>{const ae=X(V),he=X(te);if(!ae||!he||ae.length<6||he.length<6)return!1;const ue=parseInt(ae.substring(0,2),16),ce=parseInt(ae.substring(2,4),16),fe=parseInt(ae.substring(4,6),16),pe=parseInt(he.substring(0,2),16),_e=parseInt(he.substring(2,4),16),ne=parseInt(he.substring(4,6),16);return Math.abs(ue-pe)<=re&&Math.abs(ce-_e)<=re&&Math.abs(fe-ne)<=re},F=new Set(Object.values(w));return C.filaments.map(V=>{const te=V.slot_id||0;if(te>0&&w[te]!==void 0){const ne=w[te],He=D.find(B=>B.globalTrayId===ne);if(He){const B=He.type?.toUpperCase()===V.type?.toUpperCase(),H=X(He.color)===X(V.color)||q(He.color,V.color);let le;return B&&H?le="match":B?le="type_only":le="mismatch",{...V,loaded:He,hasFilament:!0,typeMatch:B,colorMatch:H,status:le,isManual:!0}}}const re=D.find(ne=>!F.has(ne.globalTrayId)&&ne.type?.toUpperCase()===V.type?.toUpperCase()&&X(ne.color)===X(V.color)),ae=!re&&D.find(ne=>!F.has(ne.globalTrayId)&&ne.type?.toUpperCase()===V.type?.toUpperCase()&&q(ne.color,V.color)),he=!re&&!ae&&D.find(ne=>!F.has(ne.globalTrayId)&&ne.type?.toUpperCase()===V.type?.toUpperCase()),ue=re||ae||he||void 0;ue&&F.add(ue.globalTrayId);const ce=!!ue,fe=ce,pe=!!re||!!ae;let _e;return re||ae?_e="match":he?_e="type_only":_e="mismatch",{...V,loaded:ue,hasFilament:ce,typeMatch:fe,colorMatch:pe,status:_e,isManual:!1}})},[C,D,w]),P=S.useMemo(()=>{if(K.length===0)return;const X=Math.max(...K.map(F=>F.slot_id||0));if(X<=0)return;const q=new Array(X).fill(-1);return K.forEach(F=>{F.slot_id&&F.slot_id>0&&(q[F.slot_id-1]=F.loaded?.globalTrayId??-1)}),q},[K]),W=C?.filaments&&C.filaments.length>0,Z=xt({mutationFn:X=>be.updateQueueItem(t.id,X),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:X=>{r(X.message||"Failed to update queue item","error")}}),G=X=>{X.preventDefault();const q={printer_id:i,require_previous_success:f,auto_off_after:p,manual_start:l==="manual",ams_mapping:P};l==="scheduled"&&u?q.scheduled_time=new Date(u).toISOString():q.scheduled_time=null,Z.mutate(q)},Y=()=>{const X=new Date;return X.setMinutes(X.getMinutes()+1),X.toISOString().slice(0,16)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsx(vt,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:X=>X.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(qo,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:G,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),N?.length===0?s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(Na,{className:"w-4 h-4"}),"No printers configured"]}):s.jsx("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:X=>a(Number(X.target.value)),required:!0,children:N?.map(X=>s.jsx("option",{value:X.id,children:X.name},X.id))})]}),i&&W&&s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>b(!y),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(z0,{className:"w-4 h-4",fill:K.some(X=>X.status==="mismatch")?"#f97316":K.some(X=>X.status==="type_only")?"#facc15":"#00ae42",stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),K.some(X=>X.status==="mismatch")?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):K.some(X=>X.status==="type_only")?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),y?s.jsx(zd,{className:"w-4 h-4 ml-auto"}):s.jsx(Aa,{className:"w-4 h-4 ml-auto"})]}),y&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.jsxs("button",{type:"button",onClick:async()=>{if(i){E(!0);try{await be.refreshPrinterStatus(i),await new Promise(X=>setTimeout(X,500)),await n.refetchQueries({queryKey:["printer-status",i]})}finally{E(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:v,children:[s.jsx(Dr,{className:`w-3 h-3 ${v?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),K.map((X,q)=>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: ${X.type} - ${Bc(X.color)}`,children:s.jsx(z0,{className:"w-3 h-3",fill:X.color,stroke:X.color})}),s.jsxs("span",{className:"text-white truncate",children:[X.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",X.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:X.loaded?.globalTrayId??"",onChange:F=>{const V=X.slot_id||0;if(V>0){const te=F.target.value;A(te===""?re=>{const ae={...re};return delete ae[V],ae}:re=>({...re,[V]:parseInt(te,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${X.status==="match"?"border-bambu-green/50 text-bambu-green":X.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${X.isManual?"ring-1 ring-blue-400/50":""}`,title:X.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),D.map(F=>s.jsxs("option",{value:F.globalTrayId,className:"bg-bambu-dark text-white",children:[F.label,": ",F.type," (",F.colorName,")"]},F.globalTrayId))]}),X.status==="match"?s.jsx(ds,{className:"w-3 h-3 text-bambu-green"}):X.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Cn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Cn,{className:"w-3 h-3 text-orange-400"})})]},q))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[s.jsx(ur,{className:"w-4 h-4"}),"ASAP"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[s.jsx(Wr,{className:"w-4 h-4"}),"Scheduled"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("manual"),children:[s.jsx(_R,{className:"w-4 h-4"}),"Queue Only"]})]})]}),l==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:u,onChange:X=>d(X.target.value),min:Y(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:X=>g(X.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:p,onChange:X=>x(X.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(Ol,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:l==="asap"?"Print will start as soon as the printer is idle.":l==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Te,{type:"submit",className:"flex-1",disabled:Z.isPending||N?.length===0,children:Z.isPending?"Saving...":"Save Changes"})]})]})]})})})}function dne(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 qGe(t,e="system"){if(!t)return"ASAP";const n=di(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`:Lp(t,e)}function KGe({status:t}){const e={pending:{icon:ur,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:Wc,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:kr,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:Sa,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:tw,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:zt,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 Hk({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system"}){const{attributes:u,listeners:d,setNodeRef:f,transform:g,transition:p,isDragging:x}=lne({id:t.id,disabled:t.status!=="pending"}),y={transform:og.Transform.toString(g),transition:p},b=t.status==="printing",v=t.status==="pending",E=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:f,style:y,className:`
- 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":""}
- ${b?"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:[v?s.jsx("div",{...u,...d,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:s.jsx(B0,{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:be.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(Md,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),s.jsx(Ac,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:s.jsx(qr,{className:"w-3.5 h-3.5"})})]}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(Ei,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(ad,{className:"w-3.5 h-3.5"}),dne(t.print_time_seconds)]}),v&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(ur,{className:"w-3.5 h-3.5"}),qGe(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(_R,{className:"w-3 h-3"}),"Staged"]}),t.require_previous_success&&s.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&s.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[s.jsx(Ol,{className:"w-3 h-3"}),"Auto power off"]})]}),b&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx(Na,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(KGe,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[b&&s.jsx(Te,{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(jle,{className:"w-4 h-4"})}),v&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Te,{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(Wc,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(zt,{className:"w-4 h-4"})})]}),E&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{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(Dr,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(vn,{className:"w-4 h-4"})})]})]})]})})}function XGe(){const t=ln(),{showToast:e}=dr(),[n,r]=S.useState(null),[i,a]=S.useState(""),[o,l]=S.useState(!1),[c,u]=S.useState(null),[d,f]=S.useState(null),[g,p]=S.useState(null),[x,y]=S.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[b,v]=S.useState(()=>{const te=localStorage.getItem("queue.historySortAsc");return te!==null?te==="true":!1}),[E,w]=S.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[A,N]=S.useState(()=>{const te=localStorage.getItem("queue.pendingSortAsc");return te!==null?te==="true":!0});S.useEffect(()=>{localStorage.setItem("queue.historySortBy",x)},[x]),S.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(b))},[b]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",E)},[E]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(A))},[A]);const C=zte(iM(U2,{activationConstraint:{distance:8}}),iM(F2,{coordinateGetter:cne})),{data:T}=ht({queryKey:["settings"],queryFn:be.getSettings}),O=T?.time_format||"system",{data:k,isLoading:R}=ht({queryKey:["queue",n,i],queryFn:()=>be.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:z}=ht({queryKey:["printers"],queryFn:()=>be.getPrinters()}),D=xt({mutationFn:te=>be.cancelQueueItem(te),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),K=xt({mutationFn:te=>be.removeFromQueue(te),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),P=xt({mutationFn:te=>be.stopQueueItem(te),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),W=xt({mutationFn:te=>be.startQueueItem(te),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),Z=xt({mutationFn:te=>be.reorderQueue(te),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),G=xt({mutationFn:async()=>{const te=k?.filter(re=>["completed","failed","skipped","cancelled"].includes(re.status))||[];for(const re of te)await be.removeFromQueue(re.id);return te.length},onSuccess:te=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${te} history item${te!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),Y=S.useMemo(()=>{const te=k?.filter(ae=>ae.status==="pending")||[],re=ae=>{if(!ae.scheduled_time)return 0;const he=new Date(ae.scheduled_time).getTime(),ue=Date.now()+4320*60*60*1e3;return he>ue?0:he};return[...te].sort((ae,he)=>{let ue;return E==="name"?ue=(ae.archive_name||"").localeCompare(he.archive_name||""):E==="printer"?ue=(ae.printer_name||"").localeCompare(he.printer_name||""):E==="time"?ue=re(ae)-re(he):ue=ae.position-he.position,A?ue:-ue})},[k,E,A]),X=k?.filter(te=>te.status==="printing")||[],q=S.useMemo(()=>[...k?.filter(re=>["completed","failed","skipped","cancelled"].includes(re.status))||[]].sort((re,ae)=>{let he;return x==="name"?he=(re.archive_name||"").localeCompare(ae.archive_name||""):x==="printer"?he=(re.printer_name||"").localeCompare(ae.printer_name||""):he=new Date(ae.completed_at||ae.created_at).getTime()-new Date(re.completed_at||re.created_at).getTime(),b?-he:he}),[k,x,b]),F=S.useMemo(()=>Y.reduce((te,re)=>te+(re.print_time_seconds||0),0),[Y]),V=te=>{const{active:re,over:ae}=te;if(!ae||re.id===ae.id)return;const he=Y.findIndex(ce=>ce.id===re.id),ue=Y.findIndex(ce=>ce.id===ae.id);if(he!==-1&&ue!==-1){const fe=H2(Y,he,ue).map((pe,_e)=>({id:pe.id,position:_e+1}));Z.mutate(fe)}};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(QG,{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(vt,{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(Wc,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:X.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(vt,{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(ur,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Y.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(vt,{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(ad,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:dne(F)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(vt,{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(kr,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:q.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:te=>r(te.target.value?Number(te.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),z?.map(te=>s.jsx("option",{value:te.id,children:te.name},te.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:te=>a(te.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"}),q.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(vn,{className:"w-4 h-4"}),"Clear History"]})]}),R?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):k?.length===0?s.jsxs(vt,{className:"p-12 text-center border-dashed",children:[s.jsx(Wr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),s.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),s.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):s.jsxs("div",{className:"space-y-8",children:[X.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:X.map(te=>s.jsx(Hk,{item:te,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>p({type:"stop",item:te}),onRequeue:()=>{},onStart:()=>{},timeFormat:O},te.id))})]}),Y.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(ur,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Y.length," item",Y.length!==1?"s":"",")"]}),s.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:E,onChange:te=>w(te.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(Te,{variant:"ghost",size:"sm",onClick:()=>N(!A),title:A?"Ascending":"Descending",className:"px-2",children:A?s.jsx(kp,{className:"w-4 h-4"}):s.jsx(U0,{className:"w-4 h-4"})})]})]}),s.jsx(rne,{sensors:C,collisionDetection:Vte,onDragEnd:V,children:s.jsx(sne,{items:Y.map(te=>te.id),strategy:OGe,children:s.jsx("div",{className:"space-y-3",children:Y.map((te,re)=>s.jsx(Hk,{item:te,position:re+1,onEdit:()=>u(te),onCancel:()=>p({type:"cancel",item:te}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>W.mutate(te.id),timeFormat:O},te.id))})})})]}),q.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(kr,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",q.length," item",q.length!==1?"s":"",")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:x,onChange:te=>y(te.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(Te,{variant:"ghost",size:"sm",onClick:()=>v(!b),title:b?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:b?s.jsx(kp,{className:"w-4 h-4"}):s.jsx(U0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:q.slice(0,20).map((te,re)=>s.jsx(Hk,{item:te,position:re+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>p({type:"remove",item:te}),onStop:()=>{},onRequeue:()=>f(te),onStart:()=>{},timeFormat:O},te.id))})]})]}),c&&s.jsx(WGe,{item:c,onClose:()=>u(null)}),d&&s.jsx(G4,{archiveId:d.archive_id,archiveName:d.archive_name||`Archive #${d.archive_id}`,onClose:()=>f(null)}),g&&s.jsx(Qn,{title:g.type==="cancel"?"Cancel Scheduled Print":g.type==="stop"?"Stop Print":"Remove from History",message:g.type==="cancel"?`Are you sure you want to cancel "${g.item.archive_name||"this print"}"?`:g.type==="stop"?`Are you sure you want to stop the current print "${g.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${g.item.archive_name||"this item"}" from the queue history?`,confirmText:g.type==="cancel"?"Cancel Print":g.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{g.type==="cancel"?D.mutate(g.item.id):g.type==="stop"?P.mutate(g.item.id):K.mutate(g.item.id),p(null)},onCancel:()=>p(null)}),o&&s.jsx(Qn,{title:"Clear History",message:`Are you sure you want to remove all ${q.length} item${q.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{G.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function YGe({printDates:t,months:e=3}){const n=S.useRef(null),[r,i]=S.useState(0);S.useEffect(()=>{const E=n.current;if(!E)return;const w=new ResizeObserver(A=>{const N=A[0]?.contentRect.width||0;i(N)});return w.observe(E),()=>w.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=S.useMemo(()=>{const E={};t.forEach(z=>{const D=z.split("T")[0];E[D]=(E[D]||0)+1});const w=new Date,A=new Date(w);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const N=[],C=[];let T=[],O=-1;const k=new Date(A);let R=0;for(;k<=w;)k.getDay()===0&&T.length>0&&(N.push(T),T=[],R++),k.getMonth()!==O&&(C.push({month:k.toLocaleDateString("en-US",{month:"short"}),weekIndex:R}),O=k.getMonth()),T.push(new Date(k)),k.setDate(k.getDate()+1);return T.length>0&&N.push(T),{weeks:N,monthLabels:C,printCounts:E}},[t,e]),c=Math.max(1,...Object.values(l)),u=E=>{if(E===0)return"bg-bambu-dark";const w=E/c;return w<=.25?"bg-bambu-green/30":w<=.5?"bg-bambu-green/50":w<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,g=32,p=2,x=r-g-16,y=f>0?Math.floor((x-(f-1)*p)/f):12,b=Math.max(8,Math.min(20,y)),v=b<=10?10:12;return s.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&s.jsxs("div",{children:[s.jsx("div",{className:"flex mb-1",style:{marginLeft:g+4},children:o.map(({month:E,weekIndex:w},A)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:v,marginLeft:A===0?0:`${(w-(o[A-1]?.weekIndex||0))*(b+p)-24}px`},children:E},A))}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"flex flex-col",style:{gap:p,marginRight:4,width:g},children:d.map((E,w)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:g,height:b,fontSize:v,visibility:w%2===1?"visible":"hidden"},children:E},E))}),a.map((E,w)=>s.jsx("div",{className:"flex flex-col",style:{gap:p},children:[0,1,2,3,4,5,6].map(A=>{const N=E.find(k=>k.getDay()===A);if(!N)return s.jsx("div",{style:{width:b,height:b}},A);const C=N.toISOString().split("T")[0],T=l[C]||0,O=C===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(T)} ${O?"ring-1 ring-white":""}`,style:{width:b,height:b},title:`${N.toLocaleDateString()}: ${T} print${T!==1?"s":""}`},A)})},w))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:v},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:p},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:b,height:b}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:b,height:b}})]}),s.jsx("span",{children:"More"})]})]})})}const m1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function ZGe(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 QGe({archives:t,currency:e="$"}){const[n,r]=S.useState("30d"),i=S.useMemo(()=>{const g=ZGe(n);return t.filter(p=>(di(p.completed_at||p.created_at)||new Date(0))>=g)},[t,n]),a=S.useMemo(()=>{const g=new Map;return i.forEach(p=>{const x=di(p.completed_at||p.created_at)||new Date,y=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,b=g.get(y)||{date:y,filament:0,cost:0,prints:0};b.filament+=p.filament_used_grams||0,b.cost+=p.cost||0,b.prints+=1,g.set(y,b)}),Array.from(g.values()).sort((p,x)=>p.date.localeCompare(x.date)).map(p=>({...p,dateLabel:new Date(p.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=S.useMemo(()=>{if(n==="7d"||n==="30d")return a;const g=new Map;return i.forEach(p=>{const x=di(p.completed_at||p.created_at)||new Date,y=new Date(x);y.setDate(x.getDate()-x.getDay());const b=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,v=g.get(b)||{week:b,filament:0,cost:0,prints:0};v.filament+=p.filament_used_grams||0,v.cost+=p.cost||0,v.prints+=1,g.set(b,v)}),Array.from(g.values()).sort((p,x)=>p.week.localeCompare(x.week)).map(p=>({date:p.week,dateLabel:`Week of ${new Date(p.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...p}))},[i,a,n]),l=S.useMemo(()=>{const g=new Map;return i.forEach(p=>{const y=(p.filament_type||"Unknown").split(", ");y.forEach(b=>{const v=(p.filament_used_grams||0)/y.length;g.set(b,(g.get(b)||0)+v)})}),Array.from(g.entries()).map(([p,x])=>({name:p,value:Math.round(x)})).sort((p,x)=>x.value-p.value)},[i]),c=S.useMemo(()=>{const g=new Date,p=[];for(let x=5;x>=0;x--){const y=new Date(g.getFullYear(),g.getMonth()-x,1),b=new Date(g.getFullYear(),g.getMonth()-x+1,0),v=y.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(w=>{const A=di(w.completed_at||w.created_at)||new Date(0);return A>=y&&A<=b});p.push({month:v,filament:Math.round(E.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:E.reduce((w,A)=>w+(A.cost||0),0),prints:E.length})}return p},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((g,p)=>g+(p.filament_used_grams||0),0),f=i.reduce((g,p)=>g+(p.cost||0),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(g=>s.jsx("button",{onClick:()=>r(g),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===g?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:g==="all"?"All":g.replace("d","D")},g))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(E1,{width:"100%",height:250,children:s.jsxs(mCe,{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(Kw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(Yw,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(Zw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),s.jsx(A1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:g=>[`${g.toFixed(0)}g`,"Filament"]}),s.jsx(dZ,{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(E1,{width:160,height:160,children:s.jsxs(hCe,{children:[s.jsx(OY,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((g,p)=>s.jsx(cy,{fill:m1[p%m1.length]},`cell-${p}`))}),s.jsx(A1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:g=>[`${g}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((g,p)=>{const x=l.reduce((b,v)=>b+v.value,0),y=x>0?(g.value/x*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:m1[p%m1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:g.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[y,"%"]})]},g.name)})})]}):s.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),s.jsx(E1,{width:"100%",height:200,children:s.jsxs(eCe,{data:c,children:[s.jsx(Kw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(Yw,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(Zw,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:g=>`${g}g`}),s.jsx(A1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(g,p)=>[p==="filament"?`${g}g`:p==="cost"?`${e}${g.toFixed(2)}`:g,p==="filament"?"Filament":p==="cost"?"Cost":"Prints"]}),s.jsx(tD,{}),s.jsx(BY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function JGe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:g}=lne({id:t}),p={transform:og.Transform.toString(d),transition:f,opacity:g?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...p,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${g?"ring-2 ring-bambu-green shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:s.jsx(B0,{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(yue,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(due,{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(dM,{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 eWe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const A={};return t.forEach(N=>{A[N.id]=N.defaultSize||4}),A},[l,c]=S.useState(()=>{const A=localStorage.getItem(e);if(A)try{const N=JSON.parse(A);return N.sizes||(N.sizes=o()),N}catch{}return{order:t.map(N=>N.id),hidden:t.filter(N=>N.defaultVisible===!1).map(N=>N.id),sizes:o()}}),[u,d]=S.useState(!1);S.useEffect(()=>{const A=()=>d(N=>!N);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),S.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),S.useEffect(()=>{const N=t.map(C=>C.id).filter(C=>!l.order.includes(C));N.length>0&&c(C=>({...C,order:[...C.order,...N]}))},[t,l.order]);const f=zte(iM(U2,{activationConstraint:{distance:8}}),iM(F2,{coordinateGetter:cne})),g=A=>{const{active:N,over:C}=A;C&&N.id!==C.id&&c(T=>{const O=T.order.indexOf(N.id),k=T.order.indexOf(C.id);return{...T,order:H2(T.order,O,k)}})},p=A=>{c(N=>({...N,hidden:N.hidden.includes(A)?N.hidden.filter(C=>C!==A):[...N.hidden,A]}))},x=A=>{c(N=>{const C=N.sizes[A]||4,T=C===1?2:C===2?4:1;return{...N,sizes:{...N.sizes,[A]:T}}})},y=()=>{const A={order:t.map(N=>N.id),hidden:t.filter(N=>N.defaultVisible===!1).map(N=>N.id),sizes:o()};c(A),i?.()},b=l.order.map(A=>t.find(N=>N.id===A)).filter(Boolean),v=b.filter(A=>!l.hidden.includes(A.id)),E=b.filter(A=>l.hidden.includes(A.id)),w=a?.({hiddenCount:E.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return s.jsxs("div",{className:"space-y-4",children:[w,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:y,children:[s.jsx(fg,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(lf,{className:"w-4 h-4"}),E.length," Hidden"]})]}),u&&E.length>0&&s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(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(lf,{className:"w-3 h-3"}),A.title]},A.id))})]}),s.jsx(rne,{sensors:f,collisionDetection:Vte,onDragEnd:g,children:s.jsx(sne,{items:v.map(A=>A.id),strategy:Q4,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:v.map(A=>s.jsx(JGe,{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:()=>x(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(Te,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function tWe({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(Gc,{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(ur,{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(Gc,{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(l3,{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(hf,{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(l3,{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 nWe({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(kr,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:"Prints by Printer"}),s.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([l,c])=>s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(l)||`Printer ${l}`}),s.jsx("span",{className:"text-white font-medium",children:c})]},l))})]})]})]})}function rWe({stats:t,printerMap:e,size:n=1}){const r=t?.average_time_accuracy;if(r==null)return s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const a=(Math.min(150,Math.max(50,r))-50)/100*100,l=(x=>x>=95&&x<=105?"#00ae42":x>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,g=n===1?3:n===2?6:999,p=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,g):[];return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:u,height:u},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:l,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${a/100*f} ${f}`})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${c>=0?"text-blue-400":"text-orange-400"}`,children:[c>=0?"+":"",c.toFixed(0),"%"]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx(rW,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:"100% = perfect estimate"})]}),p.length>0&&s.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:p.map(([x,y])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(x)||`Printer ${x}`}),s.jsxs("span",{className:`font-medium ${y>=95&&y<=105?"text-bambu-green":y>105?"text-blue-400":"text-orange-400"}`,children:[y.toFixed(0),"%"]})]},x))})]})]})}function iWe({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 aWe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(YGe,{printDates:t,months:n})}function sWe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:s.jsx(Ei,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function oWe({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(QGe,{archives:t,currency:e})}function lWe({size:t=1}){const{data:e,isLoading:n}=ht({queryKey:["failureAnalysis"],queryFn:()=>be.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(gt,{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(Cn,{className:`w-5 h-5 ${e.failure_rate>20?"text-red-400":e.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[e.failure_rate.toFixed(1),"%"]})]})}),s.jsxs("div",{className:"text-sm text-bambu-gray mt-1",children:[e.failed_prints," / ",e.total_prints," prints failed"]}),e.trend&&e.trend.length>=2&&s.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(aW,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),s.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",e.trend[e.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]}),a.length>0&&s.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?"Failure Reasons":"Top Failure Reasons"}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:a.map(([l,c])=>s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:l||"Unknown"}),s.jsx("span",{className:"text-bambu-gray ml-2",children:c})]},l))}),o&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["+",i.length-r," more reasons"]})]})]})}function cWe(){const{showToast:t}=dr(),[e,n]=S.useState(!1),[r,i]=S.useState(!1),[a,o]=S.useState(0),[l,c]=S.useState(0);S.useEffect(()=>{const w=()=>{try{const N=localStorage.getItem("bambusy-dashboard-layout");if(N){const C=JSON.parse(N);c(C.hidden?.length||0)}}catch{c(0)}};w(),window.addEventListener("storage",w);const A=setInterval(w,500);return()=>{window.removeEventListener("storage",w),clearInterval(A)}},[a]);const{data:u,isLoading:d}=ht({queryKey:["archiveStats"],queryFn:be.getArchiveStats}),{data:f}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:g}=ht({queryKey:["archives"],queryFn:()=>be.getArchives(void 0,void 0,1e3,0)}),{data:p}=ht({queryKey:["settings"],queryFn:be.getSettings}),x=async w=>{i(!1),n(!0);try{const{blob:A,filename:N}=await be.exportStats({format:w,days:90}),C=URL.createObjectURL(A),T=document.createElement("a");T.href=C,T.download=N,T.click(),URL.revokeObjectURL(C),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},y=p?.currency||"$",b=new Map(f?.map(w=>[String(w.id),w.name])||[]),v=g?.map(w=>w.created_at)||[];if(d)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(tWe,{stats:u,currency:y}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:w=>s.jsx(nWe,{stats:u,printerMap:b,size:w}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:w=>s.jsx(rWe,{stats:u,printerMap:b,size:w}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:w=>s.jsx(iWe,{stats:u,size:w}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:w=>s.jsx(lWe,{size:w}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:w=>s.jsx(aWe,{printDates:v,size:w}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(sWe,{stats:u,printerMap:b}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(oWe,{archives:g||[],currency:y}),defaultSize:4}];return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),s.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&s.jsxs(Te,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(lf,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Te,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(w=>w+1),t("Layout reset")},children:[s.jsx(fg,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Q1,{className:"w-4 h-4"}),"Export Stats"]}),r&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>x("csv"),children:[s.jsx(is,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>x("xlsx"),children:[s.jsx(Q1,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(eWe,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function uWe({plug:t,onEdit:e}){const n=ln(),[r,i]=S.useState(!1),[a,o]=S.useState(!1),[l,c]=S.useState(!1),[u,d]=S.useState(!1),{data:f,isLoading:g,refetch:p}=ht({queryKey:["smart-plug-status",t.id],queryFn:()=>be.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=ht({queryKey:["printers"],queryFn:be.getPrinters}),y=x?.find(T=>T.id===t.printer_id),b=xt({mutationFn:T=>be.controlSmartPlug(t.id,T),onSuccess:()=>{p()}}),v=xt({mutationFn:T=>be.updateSmartPlug(t.id,T),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=xt({mutationFn:()=>be.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",A=f?.reachable??!1,N=b.isPending,C=()=>{const T=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${T}/`:`http://${T}/`};return s.jsxs(s.Fragment,{children:[s.jsx(vt,{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?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:s.jsx(fo,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[g?s.jsx(gt,{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($0,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[s.jsx(Ib,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),s.jsxs("a",{href:C(),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[s.jsx(qr,{className:"w-3 h-3"}),"Admin"]})]})]}),y&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:y.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[s.jsx($h,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[s.jsx(Wr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Te,{size:"sm",variant:w?"primary":"secondary",disabled:!A||N,onClick:()=>o(!0),className:"flex-1",children:[N?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ol,{className:"w-4 h-4"}),"On"]}),s.jsxs(Te,{size:"sm",variant:w?"secondary":"primary",disabled:!A||N,onClick:()=>c(!0),className:"flex-1",children:[N?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(fM,{className:"w-4 h-4"}),"Off"]})]}),s.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(mM,{className:"w-4 h-4"}),"Automation Settings"]}),s.jsx("span",{children:u?"-":"+"})]}),u&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(SR,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:T=>v.mutate({show_in_switchbar:T.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:T=>v.mutate({enabled:T.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:T=>v.mutate({auto_on:T.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:T=>v.mutate({auto_off:T.target.checked}),className:"sr-only peer"}),s.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>v.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[s.jsx(ur,{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(gM,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:T=>v.mutate({off_delay_minutes:parseInt(T.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:T=>v.mutate({off_temp_threshold:parseInt(T.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(AR,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(vn,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Qn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(),i(!1)},onCancel:()=>i(!1)}),a&&s.jsx(Qn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{b.mutate("on"),o(!1)},onCancel:()=>o(!1)}),l&&s.jsx(Qn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{b.mutate("off"),c(!1)},onCancel:()=>c(!1)})]})}function dWe({plug:t,onClose:e}){const n=ln(),r=!!t,[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.ip_address||""),[c,u]=S.useState(t?.username||""),[d,f]=S.useState(t?.password||""),[g,p]=S.useState(t?.printer_id||null),[x,y]=S.useState(null),[b,v]=S.useState(null),[E,w]=S.useState(t?.power_alert_enabled||!1),[A,N]=S.useState(t?.power_alert_high?.toString()||""),[C,T]=S.useState(t?.power_alert_low?.toString()||""),[O,k]=S.useState(t?.schedule_enabled||!1),[R,z]=S.useState(t?.schedule_on_time||""),[D,K]=S.useState(t?.schedule_off_time||""),[P,W]=S.useState(t?.show_in_switchbar||!1),[Z,G]=S.useState(!1),[Y,X]=S.useState({scanned:0,total:0}),[q,F]=S.useState([]),V=S.useRef(null),{data:te}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:re}=ht({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs});S.useEffect(()=>{const B=H=>{H.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),V.current&&clearInterval(V.current)}},[e]);const ae=async()=>{G(!0),F([]),X({scanned:0,total:0}),v(null);try{await be.startTasmotaScan();const B=async()=>{try{const H=await be.getTasmotaScanStatus();X({scanned:H.scanned,total:H.total});const le=await be.getDiscoveredTasmotaDevices();F(le),H.running||(G(!1),V.current&&(clearInterval(V.current),V.current=null))}catch(H){console.error("Polling error:",H)}};await B(),V.current=setInterval(B,500)}catch(B){G(!1);const H=B instanceof Error?B.message:typeof B=="string"?B:JSON.stringify(B);v(H||"Failed to start scan")}},he=async()=>{try{await be.stopTasmotaScan()}catch{}G(!1),V.current&&(clearInterval(V.current),V.current=null)},ue=B=>{l(B.ip_address),a(B.name),y(null)},ce=xt({mutationFn:()=>be.testSmartPlugConnection(o,c||null,d||null),onSuccess:B=>{y(B),v(null),!i&&B.device_name&&a(B.device_name)},onError:B=>{y(null),v(B.message)}}),fe=xt({mutationFn:B=>be.createSmartPlug(B),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:B=>{v(B.message)}}),pe=xt({mutationFn:B=>be.updateSmartPlug(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:B=>{v(B.message)}}),_e=te?.filter(B=>!re?.some(le=>le.printer_id===B.id&&le.id!==t?.id)),ne=B=>{if(B.preventDefault(),v(null),!i.trim()){v("Name is required");return}if(!o.trim()){v("IP address is required");return}const H={name:i.trim(),ip_address:o.trim(),username:c.trim()||null,password:d.trim()||null,printer_id:g,power_alert_enabled:E,power_alert_high:A?parseFloat(A):null,power_alert_low:C?parseFloat(C):null,schedule_enabled:O,schedule_on_time:R||null,schedule_off_time:D||null,show_in_switchbar:P};r?pe.mutate(H):fe.mutate(H)},He=fe.isPending||pe.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:B=>B.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(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ne,className:"p-6 space-y-4 overflow-y-auto",children:[b&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:b}),!r&&s.jsxs("div",{className:"space-y-3",children:[Z?s.jsxs(Te,{type:"button",variant:"secondary",onClick:he,className:"w-full",children:[s.jsx(zt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Te,{type:"button",variant:"primary",onClick:ae,className:"w-full",children:[s.jsx(Ml,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),Z&&Y.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:[Y.scanned," / ",Y.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:`${Y.scanned/Y.total*100}%`}})})]}),q.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",q.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:q.map(B=>s.jsxs("button",{type:"button",onClick:()=>ue(B),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(fo,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:B.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:B.ip_address})]})]}),B.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${B.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(Ol,{className:"w-3 h-3"}),B.state]})]},B.ip_address))})]}),!Z&&q.length===0&&Y.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:o,onChange:B=>{l(B.target.value),y(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>ce.mutate(),disabled:!o.trim()||ce.isPending,children:[ce.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx($0,{className:"w-4 h-4"}),"Test"]})]})]}),x&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${x.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:x.success?s.jsxs(s.Fragment,{children:[s.jsx(kr,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Connected!"}),s.jsxs("p",{className:"text-sm opacity-80",children:[x.device_name&&`Device: ${x.device_name} - `,"State: ",x.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ib,{className:"w-5 h-5"}),s.jsx("span",{children:"Connection failed"})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:B=>a(B.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),s.jsx("input",{type:"text",value:c,onChange:B=>u(B.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:d,onChange:B=>f(B.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:g??"",onChange:B=>p(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:"No printer (manual control only)"}),_e?.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:"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($h,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E,onChange:B=>w(B.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),E&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),s.jsx("input",{type:"number",value:A,onChange:B=>N(B.target.value),placeholder:"e.g. 200",min:"0",max:"5000",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),s.jsx("input",{type:"number",value:C,onChange:B=>T(B.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(ur,{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:O,onChange:B=>k(B.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"})]})]}),O&&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:R,onChange:B=>z(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-sm text-bambu-gray mb-1",children:"Turn Off at"}),s.jsx("input",{type:"time",value:D,onChange:B=>K(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white 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(SR,{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:P,onChange:B=>W(B.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(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:He,className:"flex-1",children:[He?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(js,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Vn({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 hWe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function fWe({provider:t,onEdit:e}){const n=ln(),[r,i]=S.useState(!1),[a,o]=S.useState(!1),[l,c]=S.useState(null),{data:u}=ht({queryKey:["printers"],queryFn:be.getPrinters}),d=u?.find(y=>y.id===t.printer_id),f=xt({mutationFn:y=>be.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=xt({mutationFn:()=>be.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=xt({mutationFn:()=>be.testNotificationProvider(t.id),onSuccess:y=>{c(y),n.invalidateQueries({queryKey:["notification-providers"]})},onError:y=>{c({success:!1,message:y.message})}}),x=y=>y||"";return s.jsxs(s.Fragment,{children:[s.jsx(vt,{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($h,{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:hWe[t.provider_type]||t.provider_type})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&s.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",Op(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(di(t.last_error_at)?.getTime()||0)>(di(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),s.jsx(Vn,{checked:t.enabled,onChange:y=>f.mutate({enabled:y})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&s.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&s.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&s.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&s.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[s.jsx(ew,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[s.jsx(Wr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Te,{size:"sm",variant:"secondary",disabled:p.isPending,onClick:()=>{c(null),p.mutate()},className:"w-full",children:[p.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(TR,{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(kr,{className:"w-4 h-4"}):s.jsx(Sa,{className:"w-4 h-4"}),s.jsx("span",{children:l.message})]}),s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(mM,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(zd,{className:"w-4 h-4"}):s.jsx(Aa,{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(Vn,{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(Vn,{checked:t.on_print_start,onChange:y=>f.mutate({on_print_start:y})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(Vn,{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(ew,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(Vn,{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(ur,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wr,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(Vn,{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(ur,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(AR,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(vn,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Qn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{g.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const rG=[{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 mWe({provider:t,onClose:e}){const n=ln(),r=!!t,[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.provider_type||"email"),[c,u]=S.useState(t?.printer_id||null),[d,f]=S.useState(t?.quiet_hours_enabled||!1),[g,p]=S.useState(t?.quiet_hours_start||"22:00"),[x,y]=S.useState(t?.quiet_hours_end||"07:00"),[b,v]=S.useState(t?.daily_digest_enabled||!1),[E,w]=S.useState(t?.daily_digest_time||"08:00"),[A,N]=S.useState(t?.on_print_start??!1),[C,T]=S.useState(t?.on_print_complete??!0),[O,k]=S.useState(t?.on_print_failed??!0),[R,z]=S.useState(t?.on_print_stopped??!0),[D,K]=S.useState(t?.on_print_progress??!1),[P,W]=S.useState(t?.on_printer_offline??!1),[Z,G]=S.useState(t?.on_printer_error??!1),[Y,X]=S.useState(t?.on_filament_low??!1),[q,F]=S.useState(t?.on_maintenance_due??!1),[V,te]=S.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([$,ee])=>[$,String(ee)])):{}),[re,ae]=S.useState(null),[he,ue]=S.useState(null),{data:ce}=ht({queryKey:["printers"],queryFn:be.getPrinters});S.useEffect(()=>{const $=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[e]);const fe=xt({mutationFn:()=>be.testNotificationConfig({provider_type:o,config:V}),onSuccess:$=>{ae($),ue(null)},onError:$=>{ae({success:!1,message:$.message})}}),pe=xt({mutationFn:$=>be.createNotificationProvider($),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:$=>{ue($.message)}}),_e=xt({mutationFn:$=>be.updateNotificationProvider(t.id,$),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:$=>{ue($.message)}}),ne=$=>{if($.preventDefault(),ue(null),!i.trim()){ue("Name is required");return}const ee=H(o);for(const ke of ee)if(!V[ke.key]?.trim()){ue(`${ke.label} is required`);return}const de={name:i.trim(),provider_type:o,config:V,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?g:null,quiet_hours_end:d?x:null,daily_digest_enabled:b,daily_digest_time:b?E:null,on_print_start:A,on_print_complete:C,on_print_failed:O,on_print_stopped:R,on_print_progress:D,on_printer_offline:P,on_printer_error:Z,on_filament_low:Y,on_maintenance_due:q};r?_e.mutate(de):pe.mutate(de)},He=pe.isPending||_e.isPending,B=$=>{switch($){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambuddy",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},H=$=>B($).filter(ee=>ee.required),le=B(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:$=>$.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ne,className:"p-6 space-y-4",children:[he&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:he}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:$=>a($.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:$=>{l($.target.value),te({}),ae(null)},disabled:r,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:rG.map($=>s.jsx("option",{value:$.value,children:$.label},$.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:rG.find($=>$.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),le.map($=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[$.label," ",$.required&&"*"]}),$.type==="select"&&$.options?s.jsx("select",{value:V[$.key]||$.options[0]?.value||"",onChange:ee=>{te({...V,[$.key]:ee.target.value}),ae(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:$.options.map(ee=>s.jsx("option",{value:ee.value,children:ee.label},ee.value))}):s.jsx("input",{type:$.type,value:V[$.key]||"",onChange:ee=>{te({...V,[$.key]:ee.target.value}),ae(null)},placeholder:$.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},$.key))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>{ae(null),fe.mutate()},disabled:fe.isPending||!V[H(o)[0]?.key],className:"flex-1",children:[fe.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(TR,{className:"w-4 h-4"}),"Test Configuration"]})}),re&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${re.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:re.success?s.jsxs(s.Fragment,{children:[s.jsx(kr,{className:"w-5 h-5"}),s.jsx("span",{children:re.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(Sa,{className:"w-5 h-5"}),s.jsx("span",{children:re.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.jsxs("select",{value:c??"",onChange:$=>u($.target.value?Number($.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"All printers"}),ce?.map($=>s.jsx("option",{value:$.id,children:$.name},$.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx(Vn,{checked:d,onChange:f})]}),d&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),s.jsx("input",{type:"time",value:g,onChange:$=>p($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.jsx("input",{type:"time",value:x,onChange:$=>y($.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(Vn,{checked:b,onChange:v})]}),b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),s.jsx("input",{type:"time",value:E,onChange:$=>w($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),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(Vn,{checked:A,onChange:N})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(Vn,{checked:C,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(Vn,{checked:O,onChange:k})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(Vn,{checked:R,onChange:z})]}),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(Vn,{checked:D,onChange:K})]})]})]}),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(Vn,{checked:P,onChange:W})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(Vn,{checked:Z,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(Vn,{checked:Y,onChange:X})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(Vn,{checked:q,onChange:F})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:He,className:"flex-1",children:[He?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(js,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function pWe({template:t,onClose:e}){const n=ln(),r=S.useRef(null),[i,a]=S.useState(t.title_template),[o,l]=S.useState(t.body_template),[c,u]=S.useState(null),[d,f]=S.useState(!0),{data:g}=ht({queryKey:["template-variables"],queryFn:be.getTemplateVariables}),p=g?.find(N=>N.event_type===t.event_type),{data:x,isLoading:y}=ht({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>be.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});S.useEffect(()=>{const N=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const b=xt({mutationFn:N=>be.updateNotificationTemplate(t.id,N),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:N=>{u(N.message)}}),v=xt({mutationFn:()=>be.resetNotificationTemplate(t.id),onSuccess:N=>{a(N.title_template),l(N.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:N=>{u(N.message)}}),E=N=>{if(N.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}b.mutate({title_template:i,body_template:o})},w=N=>{const C=r.current;if(!C)return;const T=C.selectionStart,O=C.selectionEnd,k=o,R=k.substring(0,T),z=k.substring(O),D=R+`{${N}}`+z;l(D),setTimeout(()=>{C.focus();const K=T+N.length+2;C.setSelectionRange(K,K)},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(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:N=>a(N.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:N=>l(N.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(N=>s.jsxs("button",{type:"button",onClick:()=>w(N),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(mr,{className:"w-3 h-3"}),N]},N))}),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(lf,{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(gt,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),s.jsx("div",{className:"text-white font-medium",children:x.title})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),s.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):s.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[s.jsxs(Te,{type:"button",variant:"ghost",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-orange-400 hover:text-orange-300",children:[v.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(fg,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Te,{onClick:E,disabled:b.isPending||!A,children:[b.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(js,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const gWe={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"},xWe={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 bWe({onClose:t}){const e=ln(),{showToast:n}=dr(),[r,i]=S.useState(7),[a,o]=S.useState(null),[l,c]=S.useState(!1),{data:u}=ht({queryKey:["settings"],queryFn:be.getSettings}),d=u?.time_format||"system",{data:f,isLoading:g,refetch:p,isRefetching:x}=ht({queryKey:["notification-logs",r,l],queryFn:()=>be.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ht({queryKey:["notification-log-stats",r],queryFn:()=>be.getNotificationLogStats(r)}),b=xt({mutationFn:()=>be.clearNotificationLogs(30),onSuccess:E=>{n(E.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:E=>{n(`Failed to clear logs: ${E.message}`,"error")}}),v=E=>{const w=di(E);if(!w)return"";const N=new Date().getTime()-w.getTime();return N<6e4?"Just now":N<36e5?`${Math.floor(N/6e4)}m ago`:N<864e5?`${Math.floor(N/36e5)}h ago`:w.toLocaleDateString()+" "+uhe(w,d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(J1,{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(kr,{className:"w-4 h-4"}),y.success_count," sent"]}),y.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Sa,{className:"w-4 h-4"}),y.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.jsxs("select",{value:r,onChange:E=>i(Number(E.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:E=>c(E.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>p(),disabled:x,children:[x?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-red-400 hover:text-red-300",children:[b.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(vn,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:g?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(gt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(E=>s.jsx(yWe,{log:E,isExpanded:a===E.id,onToggle:()=>o(a===E.id?null:E.id),formatDate:v,formatFullDate:w=>Lp(w,d)},E.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(J1,{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 yWe({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(kr,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(Sa,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${xWe[t.event_type]||"text-bambu-gray"}`,children:gWe[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(zd,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Aa,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&s.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),s.jsx("p",{className:"text-sm text-white",children:t.title})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),s.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),s.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[s.jsxs("span",{children:["Provider: ",t.provider_type]}),s.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}const p1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx(pM,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx($h,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(is,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(fo,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(Lb,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Ei,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:s.jsx(ER,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Ad,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Ho,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:s.jsx(ha,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:s.jsx(qi,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"},{id:"api_keys",labelKey:"backup.categories.apiKeys",defaultLabel:"API Keys",icon:s.jsx(Dh,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function vWe({onClose:t,onExport:e}){const{t:n}=cg(),[r,i]=S.useState(()=>{const x={};return p1.forEach(y=>{x[y.id]=y.default}),x}),[a,o]=S.useState(!1),[l,c]=S.useState(!1);S.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]);const u=x=>{i(y=>({...y,[x]:!y[x]}))},d=()=>{const x={};p1.forEach(y=>{x[y.id]=!0}),i(x)},f=()=>{const x={};p1.forEach(y=>{x[y.id]=!1}),i(x)},g=Object.values(r).filter(Boolean).length,p=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:s.jsx(vt,{className:"w-full max-w-lg",onClick:x=>x.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(Mi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),s.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{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:p1.map(x=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[x.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[s.jsx("input",{type:"checkbox",checked:r[x.id],onChange:()=>u(x.id),disabled:l,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("div",{className:`${r[x.id]?"text-bambu-green":"text-bambu-gray"}`,children:x.icon}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white text-sm font-medium",children:n(x.labelKey,{defaultValue:x.defaultLabel})}),s.jsx("div",{className:"text-xs text-bambu-gray",children:x.description})]})]},x.id))}),r.archives&&s.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Ho,{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(Dh,{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(Vn,{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(Cn,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:g,defaultValue:`${g} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Te,{onClick:p,disabled:g===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?s.jsxs(s.Fragment,{children:[s.jsx(gt,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Mi,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const iG={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 _We({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=S.useState("options"),[a,o]=S.useState(!1),[l,c]=S.useState(null),[u,d]=S.useState(null),[f,g]=S.useState(new Set),p=S.useRef(null);S.useEffect(()=>{const A=N=>{N.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,n,r,u]);const x=A=>{const N=A.target.files?.[0];N&&c(N)},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")}}},b=()=>{u?.success&&n(),t()},v=A=>{g(N=>{const C=new Set(N);return C.has(A)?C.delete(A):C.add(A),C})},E=u?.restored?Object.values(u.restored).reduce((A,N)=>A+N,0)+(u.files_restored||0):0,w=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(vt,{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(kr,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(Cn,{className:"w-5 h-5"}):s.jsx(qi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),r==="options"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("input",{ref:p,type:"file",accept:".json,.zip",className:"hidden",onChange:x}),s.jsx("button",{type:"button",onClick:()=>p.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?s.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[s.jsx(kr,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:l.name})]}):s.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[s.jsx(qi,{className:"w-8 h-8"}),s.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Cn,{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(Dr,{className:"w-4 h-4 text-orange-400"}):s.jsx(tw,{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(Vn,{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(Cn,{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(Te,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Te,{type:"button",onClick:y,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(qi,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&s.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[s.jsx(gt,{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:E}),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:w}),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(kr,{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,N])=>s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:iG[A]||A}),s.jsx("span",{className:"text-bambu-green font-medium",children:N})]},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(tw,{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,N])=>{const C=u.skipped_details?.[A]||[],T=f.has(A);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>C.length>0&&v(A),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${C.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[iG[A]||A,C.length>0&&(T?s.jsx(zd,{className:"w-3 h-3"}):s.jsx(Aa,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:N})]}),T&&C.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:[C.slice(0,10).map((O,k)=>s.jsx("div",{children:O},k)),C.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",C.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(Cn,{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,N)=>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"})]})]},N))})]})]}),E===0&&w===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(Te,{onClick:b,children:"Close"})})]})]})})})}async function wWe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function SWe(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 MWe(){const t=ln(),[e,n]=S.useState(!1),[r,i]=S.useState(""),[a,o]=S.useState("auto"),[l,c]=S.useState(!1),[u,d]=S.useState("all"),[f,g]=S.useState(!1),[p,x]=S.useState(!1),{data:y,isLoading:b}=ht({queryKey:["spoolman-settings"],queryFn:wWe}),{data:v,isLoading:E,refetch:w}=ht({queryKey:["spoolman-status"],queryFn:be.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=ht({queryKey:["printers"],queryFn:be.getPrinters});S.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),g(!0))},[y]),S.useEffect(()=>{if(!f||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==a){const W=setTimeout(()=>{N.mutate()},500);return()=>clearTimeout(W)}},[e,r,a,f]);const N=xt({mutationFn:()=>SWe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),C=xt({mutationFn:be.connectSpoolman,onSuccess:()=>{w()}}),T=xt({mutationFn:be.disconnectSpoolman,onSuccess:()=>{w()}}),O=xt({mutationFn:be.syncAllPrintersAms,onSuccess:P=>{P.success}}),k=xt({mutationFn:P=>be.syncPrinterAms(P),onSuccess:P=>{P.success}}),R=()=>{u==="all"?O.mutate():k.mutate(u)},z=O.isPending||k.isPending,D=u==="all"?O.data:k.data,K=u==="all"?O.isSuccess:k.isSuccess;return b?s.jsxs(vt,{children:[s.jsx(ci,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Mt,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(gt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(vt,{children:[s.jsx(ci,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),N.isPending&&s.jsx(gt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(ds,{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(Sd,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:P=>n(P.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:P=>i(P.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,onChange:P=>o(P.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),E?s.jsx(gt,{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(ds,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(zt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:v?.connected?s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Yce,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Te,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Rp,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&s.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:C.error.message}),v?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("select",{value:u,onChange:P=>d(P.target.value==="all"?"all":Number(P.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[s.jsx("option",{value:"all",children:"All Printers"}),A?.map(P=>s.jsx("option",{value:P.id,children:P.name},P.id))]}),s.jsx(Aa,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:R,disabled:z,children:[z?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Sync"]})]})]}),K&&D&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${D.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:D.success?`Synced ${D.synced_count} spool${D.synced_count!==1?"s":""} successfully`:`Synced ${D.synced_count} spool${D.synced_count!==1?"s":""} with ${D.errors.length} error${D.errors.length!==1?"s":""}`}),D.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(Cn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[D.skipped_count," spool",D.skipped_count!==1?"s":""," skipped"]})]}),D.skipped_count>5&&s.jsx("button",{onClick:()=>x(!p),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:p?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(p?D.skipped:D.skipped.slice(0,5)).map((P,W)=>s.jsxs("li",{className:"flex items-center gap-2",children:[P.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${P.color}`}}),s.jsx("span",{children:P.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",P.reason]})]},W)),!p&&D.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",D.skipped_count-5," more"]})]})]}),D.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:D.errors.map((P,W)=>s.jsx("li",{children:P},W))})]})]})]})]})]})}function EWe({link:t,onClose:e}){const n=ln(),{mode:r}=mg(),i=!!t,a=S.useRef(null),[o,l]=S.useState(t?.name||""),[c,u]=S.useState(t?.url||""),[d,f]=S.useState(t?.icon||"link"),[g,p]=S.useState(!!t?.custom_icon),[x,y]=S.useState(t?.custom_icon?be.getExternalLinkIconUrl(t.id):null),[b,v]=S.useState(null),[E,w]=S.useState(null);S.useEffect(()=>{const z=D=>{D.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const A=xt({mutationFn:async z=>{const D=await be.createExternalLink(z);return b?await be.uploadExternalLinkIcon(D.id,b):D},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:z=>{w(z.message)}}),N=xt({mutationFn:async z=>{let D=await be.updateExternalLink(t.id,z);return b?D=await be.uploadExternalLinkIcon(t.id,b):!g&&t?.custom_icon&&(D=await be.deleteExternalLinkIcon(t.id)),D},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:z=>{w(z.message)}}),C=z=>{const D=z.target.files?.[0];if(D){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(D.type)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(D.size>1024*1024){w("Image file must be less than 1MB");return}v(D),p(!0);const P=new FileReader;P.onload=W=>{y(W.target?.result)},P.readAsDataURL(D)}},T=()=>{v(null),y(null),p(!1),a.current&&(a.current.value="")},O=z=>{if(z.preventDefault(),w(null),!o.trim()){w("Name is required");return}if(!c.trim()){w("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){w("URL must start with http:// or https://");return}const D={name:o.trim(),url:c.trim(),icon:d};i?N.mutate(D):A.mutate(D)},k=A.isPending||N.isPending,R=xM(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:z=>z.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:g&&x?s.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(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(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:O,className:"p-6 space-y-4",children:[E&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:z=>l(z.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:z=>u(z.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),g&&x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:x,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),s.jsx("button",{type:"button",onClick:T,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(vn,{className:"w-4 h-4"})})]}):s.jsxs(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(qi,{className:"w-4 h-4"}),"Upload"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!g&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(ahe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:k,className:"flex-1",children:[k?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(js,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function NWe(){const t=ln(),[e,n]=S.useState(!1),[r,i]=S.useState(null),[a,o]=S.useState(null),[l,c]=S.useState(null),{data:u,isLoading:d}=ht({queryKey:["external-links"],queryFn:be.getExternalLinks}),f=xt({mutationFn:E=>be.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=xt({mutationFn:E=>be.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},x=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},y=(E,w)=>{if(E.preventDefault(),l===null||l===w||!u)return;const A=u.map(O=>O.id),N=A.indexOf(l),C=A.indexOf(w);if(N===-1||C===-1)return;const T=[...A];T.splice(N,1),T.splice(C,0,l),g.mutate(T),c(null)},b=E=>{o(E)},v=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(vt,{children:[s.jsx(ci,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Rp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Te,{size:"sm",onClick:()=>n(!0),children:[s.jsx(mr,{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(gt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(E=>{const w=xM(E.icon);return s.jsxs("div",{draggable:!0,onDragStart:A=>p(A,E.id),onDragOver:x,onDrop:A=>y(A,E.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===E.id?"opacity-50":""}`,children:[s.jsx(B0,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(w,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:E.name}),s.jsx(qr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>b(E),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:s.jsx(vn,{className:"w-4 h-4"})})]})]},E.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Rp,{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(EWe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Qn,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:v,onCancel:()=>o(null)})]})}function AWe(){const t=ln(),{showToast:e}=dr(),[n,r]=S.useState(!1),[i,a]=S.useState(""),[o,l]=S.useState("immediate"),[c,u]=S.useState("3DPrinter-X1-Carbon"),[d,f]=S.useState(!1),[g,p]=S.useState(null),{data:x,isLoading:y}=ht({queryKey:["virtual-printer-settings"],queryFn:y1.getSettings,refetchInterval:1e4}),{data:b}=ht({queryKey:["virtual-printer-models"],queryFn:y1.getModels});S.useEffect(()=>{x&&(r(x.enabled),l(x.mode),u(x.model))},[x]);const v=xt({mutationFn:O=>y1.updateSettings(O),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),p(null)},onError:O=>{e(O.message||"Failed to update settings","error"),x&&(r(x.enabled),l(x.mode),u(x.model)),p(null)}}),E=()=>{const O=!n;if(O&&!i&&!x?.access_code_set){e("Please set an access code first","error");return}r(O),p("toggle"),v.mutate({enabled:O,access_code:i||void 0,mode:o})},w=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}p("accessCode"),v.mutate({access_code:i}),a("")},A=O=>{l(O),p("mode"),v.mutate({mode:O})},N=O=>{u(O),p("model"),v.mutate({model:O})};if(y)return s.jsx(vt,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(gt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const C=x?.status,T=C?.running||!1;return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:s.jsxs(vt,{children:[s.jsx(ci,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ei,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),C&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${T?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${T?"bg-green-400 animate-pulse":"bg-gray-500"}`}),T?"Running":"Stopped"]})]})}),s.jsxs(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:T?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:E,disabled:g==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${g==="toggle"?"opacity-50":""}`,children:s.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:c,onChange:O=>N(O.target.value),disabled:g==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:b?.models&&Object.entries(b.models).sort(([,O],[,k])=>O.localeCompare(k)).map(([O,k])=>s.jsx("option",{value:O,children:k},O))}),s.jsx(Aa,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&T&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Sd,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:x?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(ds,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Cn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:O=>a(O.target.value),placeholder:x?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),s.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?s.jsx(dM,{className:"w-4 h-4"}):s.jsx(lf,{className:"w-4 h-4"})})]}),s.jsx(Te,{onClick:w,disabled:!i||g==="accessCode",variant:"primary",children:g==="accessCode"?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):"Save"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&s.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Archive Mode"}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>A("immediate"),disabled:g==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Immediate"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files as soon as they are uploaded"})]}),s.jsxs("button",{onClick:()=>A("queue"),disabled:g==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Queue for Review"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag files before archiving"})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(vt,{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(Cn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),s.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),s.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[s.jsx(qr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(vt,{children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Sd,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsx("strong",{className:"text-white",children:"How it works:"})}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:"Complete the setup guide for your platform"}),s.jsx("li",{children:"Enable the virtual printer and set an access code"}),s.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),s.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),s.jsx("li",{children:"Connect using the access code you set"}),s.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),C&&T&&s.jsxs(vt,{children:[s.jsx(ci,{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:C.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:C.model_name||C.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:C.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:C.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:C.pending_files})]})]})})]})]})]})}const TWe={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 CWe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function u0(t,e,n=0){if(n>5)return"...";if(e.$ref)return u0(t,CWe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=u0(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?[u0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=u0(t,a,n+1);return r}return{};default:return null}}function kWe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=S.useState(!1),[l,c]=S.useState({}),[u,d]=S.useState(""),[f,g]=S.useState(null),[p,x]=S.useState(!1),[y,b]=S.useState(!1);S.useEffect(()=>{if(a&&n.parameters){const O={};for(const k of n.parameters)k.schema?.default!==void 0&&(O[k.name]=String(k.schema.default));c(k=>({...O,...k}))}},[a,n.parameters]),S.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const O=n.requestBody.content["application/json"].schema,k=u0(r,O);d(JSON.stringify(k,null,2))}},[a,n.requestBody,r,u]);const E=(()=>{const O=[];for(const k of n.parameters||[])if(k.in==="path"||k.required){const R=l[k.name];(R===void 0||R==="")&&O.push(k.name)}return O})(),w=async()=>{if(E.length>0){g({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${E.join(", ")}`,duration:0});return}x(!0),g(null);try{let O=t;const k=new URLSearchParams;for(const q of n.parameters||[]){const F=l[q.name];F!==void 0&&F!==""&&(q.in==="path"?O=O.replace(`{${q.name}}`,encodeURIComponent(F)):q.in==="query"&&k.append(q.name,F))}const R=k.toString(),z=`${O}${R?`?${R}`:""}`,D={"Content-Type":"application/json"};i&&(D["X-API-Key"]=i);const K={method:e.toUpperCase(),headers:D};["post","put","patch"].includes(e)&&u&&(K.body=u);const P=performance.now(),W=await fetch(z,K),Z=Math.round(performance.now()-P),G={};W.headers.forEach((q,F)=>{G[F]=q});let Y;W.headers.get("content-type")?.includes("application/json")?Y=await W.json():Y=await W.text(),g({status:W.status,statusText:W.statusText,headers:G,body:Y,duration:Z})}catch(O){g({status:0,statusText:"Network Error",headers:{},body:O instanceof Error?O.message:"Unknown error",duration:0})}finally{x(!1)}},A=async()=>{if(f){const O=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(O),b(!0),setTimeout(()=>b(!1),2e3)}catch{const k=document.createElement("textarea");k.value=O,k.style.position="fixed",k.style.left="-999999px",document.body.appendChild(k),k.select(),document.execCommand("copy"),document.body.removeChild(k),b(!0),setTimeout(()=>b(!1),2e3)}}},N=(n.parameters||[]).filter(O=>O.in==="path"),C=(n.parameters||[]).filter(O=>O.in==="query"),T=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(Aa,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${TWe[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}),N.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:N.map(O=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[O.name,O.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[O.name]||"",onChange:k=>c(R=>({...R,[O.name]:k.target.value})),placeholder:O.description||O.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},O.name))})]}),C.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:C.map(O=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[O.name,O.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),O.schema?.enum?s.jsxs("select",{value:l[O.name]||"",onChange:k=>c(R=>({...R,[O.name]:k.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"-- Select --"}),O.schema.enum.map(k=>s.jsx("option",{value:k,children:k},k))]}):s.jsx("input",{type:"text",value:l[O.name]||"",onChange:k=>c(R=>({...R,[O.name]:k.target.value})),placeholder:O.description||O.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},O.name))})]}),T&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange:O=>d(O.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{onClick:w,disabled:p,children:[p?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Wc,{className:"w-4 h-4"}),"Execute"]}),E.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(Na,{className:"w-3 h-3"}),"Fill in: ",E.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:A,children:y?s.jsx(kr,{className:"w-3 h-3 text-green-400"}):s.jsx(Wo,{className:"w-3 h-3"})})]}),s.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function jWe({apiKey:t=""}){const[e,n]=S.useState(null),[r,i]=S.useState(!0),[a,o]=S.useState(null),[l,c]=S.useState(new Set),[u,d]=S.useState("");if(S.useEffect(()=>{async function b(){try{const v=await fetch("/openapi.json");if(!v.ok)throw new Error("Failed to fetch OpenAPI schema");const E=await v.json();n(E)}catch(v){o(v instanceof Error?v.message:"Unknown error")}finally{i(!1)}}b()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(vt,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(Na,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[b,v]of Object.entries(e.paths))for(const[E,w]of Object.entries(v)){if(E==="parameters")continue;const A=w.tags||["Other"];for(const N of A)f[N]||(f[N]=[]),f[N].push({path:b,method:E,spec:w})}const g=Object.entries(f).map(([b,v])=>{if(!u)return{tag:b,endpoints:v};const E=v.filter(({path:w,method:A,spec:N})=>{const C=u.toLowerCase();return w.toLowerCase().includes(C)||A.toLowerCase().includes(C)||(N.summary?.toLowerCase()||"").includes(C)||(N.description?.toLowerCase()||"").includes(C)});return{tag:b,endpoints:E}}).filter(({endpoints:b})=>b.length>0).sort((b,v)=>b.tag.localeCompare(v.tag)),p=b=>{c(v=>{const E=new Set(v);return E.has(b)?E.delete(b):E.add(b),E})},x=()=>{c(new Set(g.map(b=>b.tag)))},y=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx("input",{type:"text",value:u,onChange:b=>d(b.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:y,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(qr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[g.reduce((b,v)=>b+v.endpoints.length,0)," endpoints in ",g.length," categories"]}),s.jsx("div",{className:"space-y-3",children:g.map(({tag:b,endpoints:v})=>s.jsxs(vt,{children:[s.jsx("button",{onClick:()=>p(b),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(b)?s.jsx(Aa,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Zo,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:b.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:v.length})]})}),l.has(b)&&s.jsx(Mt,{className:"pt-0 space-y-2",children:v.map(({path:E,method:w,spec:A})=>s.jsx(kWe,{path:E,method:w,spec:A,schema:e,apiKey:t},`${w}-${E}`))})]},b))})]})}function PWe(){const t=ln(),{t:e,i18n:n}=cg(),{showToast:r,showPersistentToast:i,dismissToast:a}=dr(),{mode:o,darkStyle:l,darkBackground:c,darkAccent:u,lightStyle:d,lightBackground:f,lightAccent:g,setDarkStyle:p,setDarkBackground:x,setDarkAccent:y,setLightStyle:b,setLightBackground:v,setLightAccent:E}=mg(),[w,A]=S.useState(null),[N,C]=S.useState(!1),[T,O]=S.useState(null),[k,R]=S.useState(!1),[z,D]=S.useState(null),[K,P]=S.useState(null),[W,Z]=S.useState(!1),[G,Y]=S.useState(fW()),[X,q]=S.useState("general"),[F,V]=S.useState(!1),[te,re]=S.useState(""),[ae,he]=S.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[ue,ce]=S.useState(null),[fe,pe]=S.useState(null),[_e,ne]=S.useState(""),[He,B]=S.useState(!1),[H,le]=S.useState(!1),[$,ee]=S.useState(null),[de,ke]=S.useState(!1),[we,Ee]=S.useState(!1),[U,I]=S.useState(!1),[se,ye]=S.useState(!1),Se=J=>{Y(J),lhe(J)},ve=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Be,isLoading:Ge}=ht({queryKey:["settings"],queryFn:be.getSettings}),{data:Ke,isLoading:ct}=ht({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs}),{data:$e,isLoading:ge}=ht({queryKey:["smart-plugs-energy",Ke?.map(J=>J.id)],queryFn:async()=>{if(!Ke||Ke.length===0)return null;const J=await Promise.all(Ke.filter(oe=>oe.enabled).map(async oe=>{try{const Ae=await be.getSmartPlugStatus(oe.id);return{plug:oe,status:Ae}}catch{return{plug:oe,status:null}}}));let Ne=0,ze=0,Ye=0,nt=0,Et=0;for(const{status:oe}of J)oe?.reachable&&oe.energy&&(Et++,oe.energy.power!=null&&(Ne+=oe.energy.power),oe.energy.today!=null&&(ze+=oe.energy.today),oe.energy.yesterday!=null&&(Ye+=oe.energy.yesterday),oe.energy.total!=null&&(nt+=oe.energy.total));return{totalPower:Ne,totalToday:ze,totalYesterday:Ye,totalLifetime:nt,reachableCount:Et,totalPlugs:Ke.filter(oe=>oe.enabled).length}},enabled:X==="plugs"&&!!Ke&&Ke.length>0,refetchInterval:X==="plugs"?1e4:!1}),{data:Je,isLoading:qe}=ht({queryKey:["notification-providers"],queryFn:be.getNotificationProviders}),{data:Ze,isLoading:lt}=ht({queryKey:["api-keys"],queryFn:be.getAPIKeys}),ie=xt({mutationFn:J=>be.createAPIKey(J),onSuccess:J=>{ce(J.key||null),V(!1),re(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:J=>{r(`Failed to create API key: ${J.message}`,"error")}}),Ie=xt({mutationFn:J=>be.deleteAPIKey(J),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:J=>{r(`Failed to delete API key: ${J.message}`,"error")}}),{data:xe}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:Ue,isLoading:Pe}=ht({queryKey:["notification-templates"],queryFn:be.getNotificationTemplates}),{data:Me}=ht({queryKey:["virtual-printer-settings"],queryFn:y1.getSettings,refetchInterval:1e4}),Xe=Me?.status?.running??!1,{data:ut}=ht({queryKey:["ffmpeg-status"],queryFn:be.checkFfmpeg}),{data:At}=ht({queryKey:["version"],queryFn:be.getVersion}),{data:St,refetch:Yt,isRefetching:Pt}=ht({queryKey:["updateCheck"],queryFn:be.checkForUpdates,staleTime:300*1e3}),{data:Jt,refetch:Fn}=ht({queryKey:["updateStatus"],queryFn:be.getUpdateStatus,refetchInterval:J=>{const Ne=J.state.data;return Ne?.status==="downloading"||Ne?.status==="installing"?1e3:!1}}),{data:Sn}=ht({queryKey:["mqtt-status"],queryFn:be.getMQTTStatus,refetchInterval:X==="network"?5e3:!1}),vr=xt({mutationFn:be.applyUpdate,onSuccess:J=>{J.is_docker?r(J.message,"error"):Fn()}}),[ft,Ht]=S.useState(null),Qt=xt({mutationFn:be.testAllNotificationProviders,onSuccess:J=>{Ht(J),t.invalidateQueries({queryKey:["notification-providers"]}),J.failed===0?r(`All ${J.tested} providers tested successfully!`,"success"):r(`${J.success}/${J.tested} providers succeeded`,J.failed>0?"error":"success")},onError:J=>{r(`Failed to test providers: ${J.message}`,"error")}}),mt=xt({mutationFn:async J=>{if(!Ke)return{success:0,failed:0};const Ne=Ke.filter(Ye=>Ye.enabled),ze=await Promise.all(Ne.map(async Ye=>{try{return await be.controlSmartPlug(Ye.id,J),{success:!0}}catch{return{success:!1}}}));return{success:ze.filter(Ye=>Ye.success).length,failed:ze.filter(Ye=>!Ye.success).length}},onSuccess:(J,Ne)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),J.failed===0?r(`All ${J.success} plugs turned ${Ne}`,"success"):r(`${J.success} plugs turned ${Ne}, ${J.failed} failed`,"error")},onError:J=>{r(`Failed: ${J.message}`,"error")}}),$t=S.useRef(null),cn=S.useRef(!0);S.useEffect(()=>{Be&&!w&&(A(Be),setTimeout(()=>{cn.current=!1},100))},[Be,w]);const Mn=xt({mutationFn:be.updateSettings,onSuccess:J=>{t.setQueryData(["settings"],J),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:J=>{r(`Failed to save: ${J.message}`,"error")}});S.useEffect(()=>{if(!(cn.current||!w||!Be||!(Be.auto_archive!==w.auto_archive||Be.save_thumbnails!==w.save_thumbnails||Be.capture_finish_photo!==w.capture_finish_photo||Be.default_filament_cost!==w.default_filament_cost||Be.currency!==w.currency||Be.energy_cost_per_kwh!==w.energy_cost_per_kwh||Be.energy_tracking_mode!==w.energy_tracking_mode||Be.check_updates!==w.check_updates||Be.notification_language!==w.notification_language||Be.telemetry_enabled!==w.telemetry_enabled||Be.ams_humidity_good!==w.ams_humidity_good||Be.ams_humidity_fair!==w.ams_humidity_fair||Be.ams_temp_good!==w.ams_temp_good||Be.ams_temp_fair!==w.ams_temp_fair||Be.ams_history_retention_days!==w.ams_history_retention_days||Be.date_format!==w.date_format||Be.time_format!==w.time_format||Be.default_printer_id!==w.default_printer_id||Be.ftp_retry_enabled!==w.ftp_retry_enabled||Be.ftp_retry_count!==w.ftp_retry_count||Be.ftp_retry_delay!==w.ftp_retry_delay||Be.ftp_timeout!==w.ftp_timeout||Be.mqtt_enabled!==w.mqtt_enabled||Be.mqtt_broker!==w.mqtt_broker||Be.mqtt_port!==w.mqtt_port||Be.mqtt_username!==w.mqtt_username||Be.mqtt_password!==w.mqtt_password||Be.mqtt_topic_prefix!==w.mqtt_topic_prefix||Be.mqtt_use_tls!==w.mqtt_use_tls)))return $t.current&&clearTimeout($t.current),$t.current=setTimeout(()=>{const Ne={auto_archive:w.auto_archive,save_thumbnails:w.save_thumbnails,capture_finish_photo:w.capture_finish_photo,default_filament_cost:w.default_filament_cost,currency:w.currency,energy_cost_per_kwh:w.energy_cost_per_kwh,energy_tracking_mode:w.energy_tracking_mode,check_updates:w.check_updates,notification_language:w.notification_language,telemetry_enabled:w.telemetry_enabled,ams_humidity_good:w.ams_humidity_good,ams_humidity_fair:w.ams_humidity_fair,ams_temp_good:w.ams_temp_good,ams_temp_fair:w.ams_temp_fair,ams_history_retention_days:w.ams_history_retention_days,date_format:w.date_format,time_format:w.time_format,default_printer_id:w.default_printer_id,ftp_retry_enabled:w.ftp_retry_enabled,ftp_retry_count:w.ftp_retry_count,ftp_retry_delay:w.ftp_retry_delay,ftp_timeout:w.ftp_timeout,mqtt_enabled:w.mqtt_enabled,mqtt_broker:w.mqtt_broker,mqtt_port:w.mqtt_port,mqtt_username:w.mqtt_username,mqtt_password:w.mqtt_password,mqtt_topic_prefix:w.mqtt_topic_prefix,mqtt_use_tls:w.mqtt_use_tls};Mn.mutate(Ne)},500),()=>{$t.current&&clearTimeout($t.current)}},[w,Be,Mn]);const qt=S.useCallback((J,Ne)=>{A(ze=>ze?{...ze,[J]:Ne}:null)},[]);return Ge||!w?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),s.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>q("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${X==="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:()=>q("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${X==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(fo,{className:"w-4 h-4"}),"Smart Plugs",Ke&&Ke.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ke.length})]}),s.jsxs("button",{onClick:()=>q("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${X==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx($h,{className:"w-4 h-4"}),"Notifications",Je&&Je.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Je.length})]}),s.jsxs("button",{onClick:()=>q("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${X==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Kle,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>q("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${X==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx($0,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${Sn?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>q("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${X==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Dh,{className:"w-4 h-4"}),"API Keys",Ze&&Ze.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ze.length})]}),s.jsxs("button",{onClick:()=>q("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${X==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ei,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${Xe?"bg-green-400":"bg-gray-500"}`})]})]}),X==="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(vt,{children:[s.jsx(ci,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("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(cf,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),s.jsx("select",{value:n.language,onChange:J=>n.changeLanguage(J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:dU.map(J=>s.jsxs("option",{value:J.code,children:[J.nativeName," (",J.name,")"]},J.code))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),s.jsx("select",{value:G,onChange:J=>Se(J.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:V0.map(J=>s.jsx("option",{value:J.to,children:e(J.labelKey)},J.id))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),s.jsxs("select",{value:w.date_format||"system",onChange:J=>qt("date_format",J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),s.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),s.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("select",{value:w.time_format||"system",onChange:J=>qt("time_format",J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("select",{value:w.default_printer_id??"",onChange:J=>qt("default_printer_id",J.target.value?Number(J.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"No default (ask each time)"}),xe?.map(J=>s.jsx("option",{value:J.id,children:J.name},J.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(Te,{variant:"secondary",size:"sm",onClick:ve,children:[s.jsx(fg,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(vt,{children:[s.jsx(ci,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ER,{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 ${o==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",o==="dark"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:c,onChange:J=>{x(J.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"}),s.jsx("option",{value:"oled",children:"OLED Black"}),s.jsx("option",{value:"slate",children:"Slate Blue"}),s.jsx("option",{value:"forest",children:"Forest Green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:u,onChange:J=>{y(J.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:l,onChange:J=>{p(J.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${o==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",o==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:f,onChange:J=>{v(J.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:g,onChange:J=>{E(J.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:d,onChange:J=>{b(J.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),s.jsxs(vt,{children:[s.jsx(ci,{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:w.auto_archive,onChange:J=>qt("auto_archive",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",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Save thumbnails"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.save_thumbnails,onChange:J=>qt("save_thumbnails",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",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Capture finish photo"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.capture_finish_photo,onChange:J=>qt("capture_finish_photo",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"})]})]}),w.capture_finish_photo&&ut&&!ut.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(Cn,{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(vt,{children:[s.jsx(ci,{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:w.default_filament_cost,onChange:J=>qt("default_filament_cost",parseFloat(J.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),s.jsxs("select",{value:w.currency,onChange:J=>qt("currency",J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"USD",children:"USD ($)"}),s.jsx("option",{value:"EUR",children:"EUR (€)"}),s.jsx("option",{value:"GBP",children:"GBP (£)"}),s.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),s.jsx("option",{value:"JPY",children:"JPY (¥)"}),s.jsx("option",{value:"CNY",children:"CNY (¥)"}),s.jsx("option",{value:"CAD",children:"CAD ($)"}),s.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:w.energy_cost_per_kwh,onChange:J=>qt("energy_cost_per_kwh",parseFloat(J.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),s.jsxs("select",{value:w.energy_tracking_mode||"total",onChange:J=>qt("energy_tracking_mode",J.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"print",children:"Prints Only"}),s.jsx("option",{value:"total",children:"Total Consumption"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:w.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(vt,{children:[s.jsx(ci,{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(bR,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:"Humidity"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_good??40,onChange:J=>qt("ams_humidity_good",parseInt(J.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_fair??60,onChange:J=>qt("ams_humidity_fair",parseInt(J.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(gM,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:"Temperature"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_good??28,onChange:J=>qt("ams_temp_good",parseFloat(J.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_fair??35,onChange:J=>qt("ams_temp_fair",parseFloat(J.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Pp,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:"History Retention"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:w.ams_history_retention_days??30,onChange:J=>qt("ams_history_retention_days",parseInt(J.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-6 flex-1 lg:max-w-sm",children:[s.jsx(NWe,{}),s.jsxs(vt,{children:[s.jsx(ci,{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:w.check_updates,onChange:J=>qt("check_updates",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",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white",children:e("settings.telemetry")}),s.jsxs("button",{onClick:()=>I(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsx(Sd,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.telemetry_enabled,onChange:J=>qt("telemetry_enabled",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",{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",At?.version||"..."]})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Yt(),disabled:Pt,children:[Pt?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Check now"]})]}),St?.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",St.latest_version]}),St.release_name&&St.release_name!==St.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:St.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[St.release_notes&&s.jsx("button",{onClick:()=>ye(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),St.release_url&&s.jsx("a",{href:St.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(qr,{className:"w-4 h-4"})})]})]}),Jt?.status==="downloading"||Jt?.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(gt,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Jt.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:`${Jt.progress}%`}})})]}):Jt?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Jt.message}):Jt?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Jt.error||Jt.message}):St?.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(Te,{className:"mt-3",onClick:()=>vr.mutate(),disabled:vr.isPending,children:[vr.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Mi,{className:"w-4 h-4"}),"Install Update"]})]}):St?.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: ",St.error]}):St&&!St.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(vt,{children:[s.jsx(ci,{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:"Backup Data"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>ke(!0),children:[s.jsx(Mi,{className:"w-4 h-4"}),"Export"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Restore Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Ee(!0),children:[s.jsx(qi,{className:"w-4 h-4"}),"Restore"]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>B(!0),children:[s.jsx(vn,{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(Te,{variant:"secondary",size:"sm",onClick:()=>le(!0),children:[s.jsx(vn,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),X==="network"&&w&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsx("div",{className:"flex-1 lg:max-w-xl space-y-4",children:s.jsxs(vt,{children:[s.jsx(ci,{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($0,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),Sn?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Sn.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Sn.connected?"text-green-400":"text-red-400"}`,children:Sn.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:w.mqtt_enabled??!1,onChange:J=>qt("mqtt_enabled",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"})]})]}),w.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:w.mqtt_broker??"",onChange:J=>qt("mqtt_broker",J.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:w.mqtt_port??1883,onChange:J=>qt("mqtt_port",Math.min(65535,Math.max(1,parseInt(J.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:w.mqtt_use_tls??!1,onChange:J=>{const Ne=J.target.checked;qt("mqtt_use_tls",Ne);const ze=w.mqtt_port??1883;Ne&&ze===1883?qt("mqtt_port",8883):!Ne&&ze===8883&&qt("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:w.mqtt_username??"",onChange:J=>qt("mqtt_username",J.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:w.mqtt_password??"",onChange:J=>qt("mqtt_password",J.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:w.mqtt_topic_prefix??"bambuddy",onChange:J=>qt("mqtt_topic_prefix",J.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: ",w.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),Sn&&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 ${Sn.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:Sn.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[Sn.broker,":",Sn.port]})]}):"Not connected"})]})})]})]})]})}),s.jsx("div",{className:"flex-1 lg:max-w-xl space-y-4",children:s.jsxs(vt,{children:[s.jsx(ci,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Dr,{className:"w-5 h-5 text-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:w.ftp_retry_enabled??!0,onChange:J=>qt("ftp_retry_enabled",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"})]})]}),w.ftp_retry_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"10",value:w.ftp_retry_count??3,onChange:J=>qt("ftp_retry_count",Math.min(10,Math.max(1,parseInt(J.target.value)||3))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"times"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"30",value:w.ftp_retry_delay??2,onChange:J=>qt("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(J.target.value)||2))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"10",max:"120",value:w.ftp_timeout??30,onChange:J=>qt("ftp_timeout",Math.min(120,Math.max(10,parseInt(J.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)"})]})]})]})})]}),X==="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(fo,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect Tasmota-based smart plugs to automate power control and track energy usage for your printers."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Ke&&Ke.filter(J=>J.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("on"),disabled:mt.isPending,title:"Turn all plugs on",children:[mt.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(Ol,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("off"),disabled:mt.isPending,title:"Turn all plugs off",children:[mt.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(fM,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Te,{className:"whitespace-nowrap",onClick:()=>{O(null),C(!0)},children:[s.jsx(mr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Ke&&Ke.length>0&&s.jsxs(vt,{className:"mb-6",children:[s.jsx(ci,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(hf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",ge&&s.jsx(gt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Mt,{children:$e?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(hf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[$e.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:[$e.reachableCount,"/",$e.totalPlugs," plugs online"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(Wr,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[$e.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",($e.totalToday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(sW,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[$e.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",($e.totalYesterday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(l3,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[$e.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",($e.totalLifetime*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]})]}):ge?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),ct?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ke&&Ke.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Ke.map(J=>s.jsx(uWe,{plug:J,onEdit:Ne=>{O(Ne),C(!0)}},J.id))}):s.jsx(vt,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(fo,{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(Te,{onClick:()=>{O(null),C(!0)},children:[s.jsx(mr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),X==="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($h,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>Z(!0),children:[s.jsx(J1,{className:"w-4 h-4"}),"Log"]}),Je&&Je.length>0&&s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>{Ht(null),Qt.mutate()},disabled:Qt.isPending,children:[Qt.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(TR,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Te,{size:"sm",onClick:()=>{D(null),R(!0)},children:[s.jsx(mr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(vt,{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:e("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:w.notification_language||"en",onChange:J=>qt("notification_language",J.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:dU.map(J=>s.jsx("option",{value:J.code,children:J.nativeName},J.code))})]})})}),ft&&s.jsx(vt,{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:()=>Ht(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(kr,{className:"w-4 h-4"}),ft.success," passed"]}),ft.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Sa,{className:"w-4 h-4"}),ft.failed," failed"]})]}),ft.results.filter(J=>!J.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:ft.results.filter(J=>!J.success).map(J=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[J.provider_name,":"]})," ",J.message]},J.provider_id))})]})}),qe?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(gt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Je&&Je.length>0?s.jsx("div",{className:"space-y-3",children:Je.map(J=>s.jsx(fWe,{provider:J,onEdit:Ne=>{D(Ne),R(!0)}},J.id))}):s.jsx(vt,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx($h,{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(Te,{size:"sm",onClick:()=>{D(null),R(!0)},children:[s.jsx(mr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(is,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),Pe?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(gt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Ue&&Ue.length>0?s.jsx("div",{className:"space-y-2",children:Ue.map(J=>s.jsx(vt,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>P(J),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:J.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:J.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:Ne=>{Ne.stopPropagation(),P(J)},children:s.jsx(AR,{className:"w-4 h-4 text-bambu-gray"})})]})})},J.id))}):s.jsx(vt,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(is,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),X==="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(Dh,{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(Te,{size:"sm",onClick:()=>V(!0),className:"flex-shrink-0",children:[s.jsx(mr,{className:"w-4 h-4"}),"Create Key"]})]}),ue&&s.jsx(vt,{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(kr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),s.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[s.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:ue}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(ue);else{const J=document.createElement("textarea");J.value=ue,J.style.position="fixed",J.style.left="-999999px",document.body.appendChild(J),J.select(),document.execCommand("copy"),document.body.removeChild(J)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:s.jsx(Wo,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{ne(ue),r("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>ce(null),children:"Dismiss"})]})]})]})})}),F&&s.jsxs(vt,{className:"mb-6",children:[s.jsx(ci,{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:te,onChange:J=>re(J.target.value),placeholder:"e.g., Home Assistant, OctoPrint",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ae.can_read_status,onChange:J=>he(Ne=>({...Ne,can_read_status:J.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Read Status"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ae.can_queue,onChange:J=>he(Ne=>({...Ne,can_queue:J.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Manage Queue"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:ae.can_control_printer,onChange:J=>he(Ne=>({...Ne,can_control_printer:J.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(Te,{onClick:()=>ie.mutate({name:te||"Unnamed Key",...ae}),disabled:ie.isPending,children:[ie.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(mr,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Te,{variant:"secondary",onClick:()=>V(!1),children:"Cancel"})]})]})]}),lt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ze&&Ze.length>0?s.jsx("div",{className:"space-y-3",children:Ze.map(J=>s.jsx(vt,{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(Dh,{className:`w-5 h-5 ${J.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:J.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[J.key_prefix,"••••••••",J.last_used&&` · Last used: ${Op(J.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[J.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),J.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),J.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(Te,{variant:"secondary",size:"sm",onClick:()=>pe(J.id),children:s.jsx(vn,{className:"w-4 h-4 text-red-400"})})]})]})})},J.id))}):s.jsx(vt,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Dh,{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(Te,{onClick:()=>V(!0),children:[s.jsx(mr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(vt,{className:"mt-6",children:[s.jsx(ci,{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(cf,{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(vt,{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:_e,onChange:J=>ne(J.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(jWe,{apiKey:_e})]})]}),X==="virtual-printer"&&s.jsx(AWe,{}),X==="filament"&&s.jsx("div",{className:"max-w-2xl",children:s.jsx(MWe,{})}),fe!==null&&s.jsx(Qn,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{Ie.mutate(fe),pe(null)},onCancel:()=>pe(null)}),N&&s.jsx(dWe,{plug:T,onClose:()=>{C(!1),O(null)}}),k&&s.jsx(mWe,{provider:z,onClose:()=>{R(!1),D(null)}}),K&&s.jsx(pWe,{template:K,onClose:()=>P(null)}),W&&s.jsx(bWe,{onClose:()=>Z(!1)}),He&&s.jsx(Qn,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{B(!1);try{const J=await be.clearNotificationLogs(30);r(J.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>B(!1)}),H&&s.jsx(Qn,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{le(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>le(!1)}),$&&s.jsx(Qn,{title:`Turn All Plugs ${$==="on"?"On":"Off"}`,message:`This will turn ${$==="on"?"ON":"OFF"} all ${Ke?.filter(J=>J.enabled).length||0} enabled smart plugs. ${$==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${$==="on"?"On":"Off"}`,variant:$==="off"?"danger":"warning",onConfirm:()=>{const J=$;ee(null),mt.mutate(J)},onCancel:()=>ee(null)}),de&&s.jsx(vWe,{onClose:()=>ke(!1),onExport:async J=>{ke(!1);const Ne="backup-progress",ze=J.archives;ze&&i(Ne,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:Ye,filename:nt}=await be.exportBackup(J);ze&&a(Ne);const Et=URL.createObjectURL(Ye),oe=document.createElement("a");oe.href=Et,oe.download=nt,oe.click(),URL.revokeObjectURL(Et),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{ze&&a(Ne),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),we&&s.jsx(_We,{onClose:()=>Ee(!1),onRestore:async(J,Ne)=>await be.importBackup(J,Ne),onSuccess:()=>{A(null),cn.current=!0,t.resetQueries({queryKey:["settings"]}),t.invalidateQueries({queryKey:["notification-providers"]}),t.invalidateQueries({queryKey:["notification-templates"]}),t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["external-links"]}),t.invalidateQueries({queryKey:["printers"]}),t.invalidateQueries({queryKey:["filaments"]}),t.invalidateQueries({queryKey:["maintenance-types"]}),t.invalidateQueries({queryKey:["api-keys"]})}}),U&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>I(!1),children:s.jsxs(vt,{className:"w-full max-w-lg",onClick:J=>J.stopPropagation(),children:[s.jsxs(ci,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ide,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),s.jsx("button",{onClick:()=>I(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(kr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem4")})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Sa,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),s.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),s.jsx(Te,{onClick:()=>I(!1),className:"w-full",children:e("common.close")})]})]})}),se&&St?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>ye(!1),children:s.jsxs(vt,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:J=>J.stopPropagation(),children:[s.jsxs(ci,{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",St.latest_version]}),St.release_name&&St.release_name!==St.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:St.release_name})]}),s.jsx("button",{onClick:()=>ye(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(zt,{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:St.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[St.release_url&&s.jsx("a",{href:St.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Te,{variant:"secondary",className:"w-full",children:[s.jsx(qr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Te,{onClick:()=>ye(!1),className:"flex-1",children:"Close"})]})]})})]})}const hne=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},RWe=t=>t.startsWith("HH")?"HF":"S",DWe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},iR=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 $k({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=RWe(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(Ed,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Nd,{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:hne(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(nW,{className:"w-3 h-3 text-yellow-500"})}),s.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&s.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:s.jsx(Wo,{className:"w-4 h-4"})})]})}function Vk({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}=dr(),[f,g]=S.useState(t?.name||""),[p,x]=S.useState(t?.k_value?hne(t.k_value):"0.020"),[y,b]=S.useState(t?.filament_id||""),[v,E]=S.useState(t?.nozzle_id?DWe(t.nozzle_id):"HH00"),[w,A]=S.useState(t?.nozzle_diameter||n),[N,C]=S.useState(t?[t.extruder_id]:i?[0,1]:[0]),[T,O]=S.useState(!1),[k,R]=S.useState({current:0,total:0}),[z,D]=S.useState(a),K=Cr.useMemo(()=>{const q=new Map;for(const F of r)if(F.filament_id&&!q.has(F.filament_id)){const V=iR(F.name||"");q.set(F.filament_id,{id:F.filament_id,name:V||F.filament_id})}return Array.from(q.values()).sort((F,V)=>F.name.localeCompare(V.name))},[r]),P=xt({mutationFn:q=>(console.log("[KProfile] Calling API..."),be.setKProfile(e,q)),onSuccess:q=>{if(console.log("[KProfile] Save success:",q),d("K-profile saved"),u&&z!==a){let F;z===""&&o?F=o:t&&t.slot_id>0?F=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:F=`name_${f}_${y}`,u(F,z)}O(!0),setTimeout(()=>{O(!1),c()},2500)},onError:q=>{console.error("[KProfile] Save error:",q),d(q.message,"error"),O(!1)}}),W=xt({mutationFn:q=>(console.log("[KProfile] Deleting profile..."),be.deleteKProfile(e,q)),onSuccess:q=>{console.log("[KProfile] Delete success:",q),d("K-profile deleted"),O(!0),setTimeout(()=>{O(!1),l()},4e3)},onError:q=>{console.error("[KProfile] Delete error:",q),d(q.message,"error"),O(!1)}}),[Z,G]=S.useState(!1),Y=()=>{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})},X=async q=>{if(q.preventDefault(),i&&!t&&N.length===0){d("Please select at least one extruder","error");return}const F=parseFloat(p).toFixed(6),V=`${v}-${w}`;if(t||N.length===1){const re={name:f,k_value:F,filament_id:y,nozzle_id:V,nozzle_diameter:w,extruder_id:t?t.extruder_id:N[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",re),P.mutate(re);return}O(!0),R({current:1,total:N.length});const te=N.map(re=>({name:f,k_value:F,filament_id:y,nozzle_id:V,nozzle_diameter:w,extruder_id:re,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${te.length} profiles in batch:`,te);try{if(await be.setKProfilesBatch(e,te),d(`K-profile saved to ${N.length} extruders`),u&&z){const re=`name_${f}_${y}`;u(re,z)}}catch(re){console.error("[KProfile] Failed to save batch:",re),d("Failed to save K-profiles","error"),O(!1),R({current:0,total:0});return}R({current:N.length,total:N.length}),setTimeout(()=>{O(!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(vt,{className:"w-full max-w-md relative",children:[T&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:k.total>1?`Saving to extruder ${k.current}/${k.total}...`:"Syncing with printer..."}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),s.jsxs(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:T,children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:X,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:q=>g(q.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:q=>{const F=q.target.value;(F===""||/^\d*\.?\d*$/.test(F))&&x(F)},onBlur:q=>{const F=parseFloat(q.target.value);isNaN(F)||x((Math.trunc(F*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),s.jsxs("select",{value:y,onChange:q=>{const F=q.target.value;if(b(F),!t&&F&&!f){const V=K.find(te=>te.id===F);V&&g(`${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:K.find(q=>q.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&K.map(q=>s.jsx("option",{value:q.id,children:q.name},q.id))]}),!t&&K.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:q=>{const F=q.target.value;if(E(F),!t&&y&&!f){const V=K.find(te=>te.id===y);V&&g(`${F==="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:w,onChange:q=>A(q.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:N.includes(1),onChange:q=>{q.target.checked?C([...N,1]):C(N.filter(F=>F!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),s.jsx("span",{className:"text-white",children:"Left"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:N.includes(0),onChange:q=>{q.target.checked?C([...N,0]):C(N.filter(F=>F!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),s.jsx("span",{className:"text-white",children:"Right"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),s.jsx("textarea",{value:z,onChange:q=>D(q.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(Te,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:W.isPending||T,className:"text-red-500 hover:bg-red-500/10",children:W.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(vn,{className:"w-4 h-4"})}),s.jsx(Te,{type:"button",variant:"secondary",onClick:l,disabled:T,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:P.isPending||T,className:"flex-1",children:[P.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(hM,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),Z&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(vt,{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(vn,{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(Te,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Te,{onClick:()=>{G(!1),Y()},disabled:W.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[W.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(vn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const g1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function OWe(){const{showToast:t}=dr(),[e,n]=S.useState(null),[r,i]=S.useState(()=>localStorage.getItem(g1.NOZZLE_DIAMETER)||"0.4"),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),[f,g]=S.useState(""),[p,x]=S.useState("all"),[y,b]=S.useState("all"),[v,E]=S.useState(()=>localStorage.getItem(g1.SORT_OPTION)||"name"),[w,A]=S.useState(!1),[N,C]=S.useState(new Set),[T,O]=S.useState(!1),[k,R]=S.useState(!1),z=$=>`${$.slot_id}_${$.extruder_id}`;S.useEffect(()=>{localStorage.setItem(g1.NOZZLE_DIAMETER,r)},[r]),S.useEffect(()=>{localStorage.setItem(g1.SORT_OPTION,v)},[v]);const{data:D,isLoading:K}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:P,isLoading:W,isFetching:Z,error:G,refetch:Y}=ht({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const $=await be.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",$?.profiles?.length||0,"profiles"),$},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:X}=ht({queryKey:["kprofiles",e,"0.4"],queryFn:()=>be.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:q,refetch:F}=ht({queryKey:["kprofile-notes",e],queryFn:()=>be.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),V=G?.message?.includes("not connected");S.useEffect(()=>{if(!e&&D&&D.length>0){const $=D.find(ee=>ee.is_active);$&&n($.id)}},[e,D]),S.useEffect(()=>{if(e){const $=setTimeout(()=>{Y()},150);return()=>clearTimeout($)}},[e,r]);const te=D?.filter($=>$.is_active)||[],re=Cr.useMemo(()=>P?.profiles?P.profiles.filter(ee=>{const de=f.toLowerCase(),ke=!de||ee.name.toLowerCase().includes(de)||ee.filament_id.toLowerCase().includes(de),we=p==="all"||p==="left"&&ee.extruder_id===1||p==="right"&&ee.extruder_id===0,Ee=y==="all"||y==="hf"&&ee.nozzle_id.startsWith("HH")||y==="s"&&ee.nozzle_id.startsWith("HS");return ke&&we&&Ee}).sort((ee,de)=>{switch(v){case"k_value":return parseFloat(ee.k_value)-parseFloat(de.k_value);case"filament":return iR(ee.name).localeCompare(iR(de.name));case"name":default:return ee.name.localeCompare(de.name)}}):[],[P?.profiles,f,p,y,v]),ae=D?.find($=>$.id===e),he=ae?.nozzle_count===2;S.useEffect(()=>{const $=ee=>{ee.target instanceof HTMLInputElement||ee.target instanceof HTMLTextAreaElement||ee.target instanceof HTMLSelectElement||a||l||u||(ee.key==="r"||ee.key==="R"?(ee.preventDefault(),Y()):ee.key==="n"||ee.key==="N"?(ee.preventDefault(),c(!0)):ee.key==="Escape"&&w&&(ee.preventDefault(),A(!1),C(new Set)))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[a,l,u,w,Y]);const ue=S.useCallback(()=>{if(!P?.profiles||P.profiles.length===0){t("No profiles to export","error");return}const $={version:1,exported_at:new Date().toISOString(),printer:ae?.name||"Unknown",nozzle_diameter:r,profiles:P.profiles.map(we=>({name:we.name,k_value:we.k_value,filament_id:we.filament_id,nozzle_id:we.nozzle_id,nozzle_diameter:we.nozzle_diameter,extruder_id:we.extruder_id}))},ee=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),de=URL.createObjectURL(ee),ke=document.createElement("a");ke.href=de,ke.download=`kprofiles_${ae?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ke),ke.click(),document.body.removeChild(ke),URL.revokeObjectURL(de),t(`Exported ${P.profiles.length} profiles`)},[P?.profiles,ae,r,t]),ce=S.useCallback(()=>{const $=document.createElement("input");$.type="file",$.accept=".json",$.onchange=async ee=>{const de=ee.target.files?.[0];if(de)try{const ke=await de.text(),we=JSON.parse(ke);if(!we.profiles||!Array.isArray(we.profiles)){t("Invalid file format","error");return}let Ee=0;for(const U of we.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await be.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${r}`,nozzle_diameter:U.nozzle_diameter||r,extruder_id:U.extruder_id??0,slot_id:0}),Ee++,await new Promise(I=>setTimeout(I,500))}catch(I){console.error("Failed to import profile:",U.name,I)}t(`Imported ${Ee} of ${we.profiles.length} profiles`),Y()}catch(ke){console.error("Import error:",ke),t("Failed to parse import file","error")}},$.click()},[e,r,t,Y]),fe=S.useCallback($=>{C(ee=>{const de=new Set(ee);return de.has($)?de.delete($):de.add($),de})},[]),pe=S.useCallback(()=>{C(new Set(re.map($=>z($))))},[re,z]),_e=S.useCallback(()=>{N.size!==0&&O(!0)},[N.size]),ne=S.useCallback(async()=>{const $=re.filter(de=>N.has(z(de)));R(!0);let ee=0;for(const de of $)try{await be.deleteKProfile(e,{slot_id:de.slot_id,extruder_id:de.extruder_id,nozzle_id:de.nozzle_id,nozzle_diameter:de.nozzle_diameter,filament_id:de.filament_id,setting_id:de.setting_id}),ee++,await new Promise(ke=>setTimeout(ke,300))}catch(ke){console.error("Failed to delete profile:",de.name,ke)}t(`Deleted ${ee} profiles`),R(!1),O(!1),A(!1),C(new Set),Y()},[e,N,re,t,Y,z]),He=S.useCallback($=>{const ee=[];return $.setting_id&&ee.push($.setting_id),ee.push(`slot_${$.slot_id}_${$.filament_id}_${$.extruder_id}`),ee.push(`name_${$.name}_${$.filament_id}`),ee},[]),B=S.useCallback(async($,ee)=>{if(e)try{await be.setKProfileNote(e,$,ee),F()}catch(de){console.error("Failed to save note:",de),t("Failed to save note","error")}},[e,F,t]),H=S.useCallback($=>{if(!q?.notes)return{note:"",key:null};const ee=He($);for(const de of ee)if(q.notes[de])return{note:q.notes[de],key:de};return{note:"",key:null}},[q,He]),le=S.useCallback($=>H($).note,[H]);return K?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!D||D.length===0?s.jsx(vt,{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 Printers Configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):te.length===0?s.jsx(vt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Ei,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),s.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):s.jsxs(s.Fragment,{children:[Z&&!W&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(gt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1 min-w-48",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsx("select",{value:e||"",onChange:$=>n(parseInt($.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:te.map($=>s.jsx("option",{value:$.id,children:$.name},$.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),s.jsxs("select",{value:r,onChange:$=>i($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>Y(),disabled:Z,children:[s.jsx(Dr,{className:`w-4 h-4 ${Z?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Te,{onClick:()=>c(!0),children:[s.jsx(mr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-48 relative",children:[s.jsx(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:f,onChange:$=>g($.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"})]}),he&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:p,onChange:$=>x($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All 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($.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:$=>E($.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(Te,{variant:"secondary",onClick:ue,disabled:!P?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Mi,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Te,{variant:"secondary",onClick:ce,title:"Import profiles from JSON",children:[s.jsx(qi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),w?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:pe,title:"Select all visible profiles",children:[s.jsx(Ed,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Te,{variant:"secondary",onClick:_e,disabled:N.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${N.size} selected profiles`,children:[s.jsx(vn,{className:"w-4 h-4"}),"Delete (",N.size,")"]}),s.jsxs(Te,{variant:"secondary",onClick:()=>{A(!1),C(new Set)},children:[s.jsx(zt,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Te,{variant:"secondary",onClick:()=>A(!0),disabled:!re.length,title:"Enter selection mode for bulk delete",children:[s.jsx(Ed,{className:"w-4 h-4"}),"Select"]})]}),W?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):V?s.jsx(vt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Ib,{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(Te,{variant:"secondary",onClick:()=>Y(),children:[s.jsx(Dr,{className:"w-4 h-4"}),"Retry"]})]})}):re.length>0?he?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:re.filter($=>$.extruder_id===1).map($=>s.jsx($k,{profile:$,onEdit:()=>o($),onCopy:()=>d($),selectionMode:w,isSelected:N.has(z($)),onToggleSelect:()=>fe(z($)),note:le($)},z($)))})]}),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:re.filter($=>$.extruder_id===0).map($=>s.jsx($k,{profile:$,onEdit:()=>o($),onCopy:()=>d($),selectionMode:w,isSelected:N.has(z($)),onToggleSelect:()=>fe(z($)),note:le($)},z($)))})]})]}):s.jsx("div",{className:"space-y-1",children:re.map($=>s.jsx($k,{profile:$,onEdit:()=>o($),onCopy:()=>d($),selectionMode:w,isSelected:N.has(z($)),onToggleSelect:()=>fe(z($)),note:le($)},z($)))}):f||p!=="all"||y!=="all"?s.jsx(vt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Ml,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):s.jsx(vt,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(hM,{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(Te,{onClick:()=>c(!0),children:[s.jsx(mr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:$,key:ee}=H(a);return s.jsx(Vk,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:X?.profiles||P?.profiles,isDualNozzle:he,initialNote:$,initialNoteKey:ee,onSaveNote:B,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),Y()},onSave:()=>{o(null),Y()}})})(),l&&e&&s.jsx(Vk,{printerId:e,nozzleDiameter:r,existingProfiles:X?.profiles||P?.profiles,isDualNozzle:he,onSaveNote:B,onClose:()=>{c(!1),Y()},onSave:()=>{c(!1),Y()}}),u&&e&&s.jsx(Vk,{printerId:e,nozzleDiameter:r,existingProfiles:X?.profiles||P?.profiles,isDualNozzle:he,onSaveNote:B,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),Y()},onSave:()=>{d(null),Y()}}),T&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(vt,{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(vn,{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:N.size})," selected profiles from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>O(!1),disabled:k,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{onClick:ne,disabled:k,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[k?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(vn,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function J4(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function kb(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function LWe(t){const e=di(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 IWe({onSuccess:t}){const{showToast:e}=dr(),[n,r]=S.useState("email"),[i,a]=S.useState(""),[o,l]=S.useState(""),[c,u]=S.useState(""),[d,f]=S.useState(""),[g,p]=S.useState("global"),x=xt({mutationFn:()=>be.cloudLogin(i,o,g),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),y=xt({mutationFn:()=>be.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),b=xt({mutationFn:()=>be.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),v=w=>{w.preventDefault(),n==="email"?x.mutate():n==="code"?y.mutate():n==="token"&&b.mutate()},E=x.isPending||y.isPending||b.isPending;return s.jsx(vt,{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(uM,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),s.jsxs("form",{onSubmit:v,className:"space-y-4",children:[n==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),s.jsx("input",{type:"email",value:i,onChange:w=>a(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:o,onChange:w=>l(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),s.jsxs("select",{value:g,onChange:w=>p(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"global",children:"Global"}),s.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),s.jsx("input",{type:"text",value:c,onChange:w=>u(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),s.jsx("textarea",{value:d,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),s.jsxs("div",{className:"flex gap-2",children:[n==="code"&&s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Te,{type:"submit",disabled:E,className:"flex-1",children:[E?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(jU,{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(Dh,{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(jU,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function np({label:t,value:e,options:n,onChange:r}){const[i,a]=S.useState(!1),o=n.find(l=>l.value===e);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),s.jsx("span",{children:o?.label||"All"}),s.jsx(Aa,{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 FWe(){const[t,e]=S.useState(!1);S.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?s.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:s.jsx(kp,{className:"w-5 h-5"})}):null}function Gk({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=J4(t.name),c=kb(t.setting_id);return s.jsxs("div",{className:"flex items-center gap-2 group",children:[s.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&s.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&c&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),s.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:s.jsx(Wo,{className:"w-4 h-4"})})]})}function aR(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+" "+aR(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)+": "+aR(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function UWe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=dr(),o=ln(),[l,c]=S.useState(!1),{data:u,isLoading:d}=ht({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>be.getCloudSettingDetail(t.setting_id)}),f=xt({mutationFn:()=>be.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:x=>a(x.message,"error")}),g=kb(t.setting_id),p=J4(t.name,u?.setting?.inherits);return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(vt,{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}),g&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),p.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:p.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{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(gt,{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:aR(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(Cn,{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(Te,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):s.jsx(vn,{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(Te,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Te,{variant:"secondary",onClick:r,children:[s.jsx(Wo,{className:"w-4 h-4"}),"Duplicate"]}),g&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(qo,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{variant:"danger",onClick:()=>c(!0),children:s.jsx(vn,{className:"w-4 h-4"})})]})]})})]})})})}function fne(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function mne(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function zWe({onClose:t,onApply:e}){const{showToast:n}=dr(),[r,i]=S.useState(fne),[a,o]=S.useState("all"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,g]=S.useState(""),[p,x]=S.useState("{}"),[y,b]=S.useState(null),[v,E]=S.useState(null),w=a==="all"?r:r.filter(D=>D.type===a),A=D=>{i(D),mne(D)},N=D=>{const K=r.filter(P=>P.id!==D);A(K),E(null),n("Template deleted")},C=D=>{c(D.id),d(D.name),g(D.description),x(JSON.stringify(D.settings,null,2)),b(null)},T=()=>{if(!(!l||!u.trim()))try{const D=JSON.parse(p),K=r.map(P=>P.id===l?{...P,name:u.trim(),description:f.trim(),settings:D}:P);A(K),c(null),n("Template updated")}catch(D){b(D.message)}},O=()=>{c(null),d(""),g(""),x("{}"),b(null)},k=D=>{const K=r.map(P=>P.id===D?{...P,showInModal:!P.showInModal}:P);A(K)},R={filament:{label:"Filament",icon:xR,color:"text-amber-400"},print:{label:"Process",icon:mM,color:"text-blue-400"},printer:{label:"Printer",icon:Ei,color:"text-purple-400"}},z=v?r.find(D=>D.id===v):null;return S.useEffect(()=>{const D=K=>{K.key==="Escape"&&(v?E(null):l?O():t())};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[v,l,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[z&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(vt,{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(Cn,{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:z.name}),'"?']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),s.jsxs(Te,{onClick:()=>N(v),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(vn,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(vt,{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(H0,{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(zt,{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(D=>s.jsx("button",{onClick:()=>o(D),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===D?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:D==="all"?"All":R[D].label},D))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(H0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:"No templates yet"}),s.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):s.jsx("div",{className:"space-y-2",children:w.map(D=>{const K=R[D.type],P=K.icon;return l===D.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=>g(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=>{x(W.target.value),b(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${y?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),y&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:y})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{size:"sm",onClick:T,disabled:!u.trim(),children:[s.jsx(js,{className:"w-4 h-4"}),"Save"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:O,children:"Cancel"})]})]},D.id):s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[s.jsx(P,{className:`w-5 h-5 ${K.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:D.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:D.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(D.settings).length," fields"]}),s.jsx("button",{onClick:()=>k(D.id),className:`p-1 transition-colors ${D.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:D.showInModal?"Shown in modals":"Hidden in modals",children:D.showInModal?s.jsx(lf,{className:"w-4 h-4"}):s.jsx(dM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(D),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>C(D),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(qo,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E(D.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(vn,{className:"w-4 h-4"})})]},D.id)})})})]})})]})}function pne({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=S.useState("changes"),[l,c]=S.useState(""),u=S.useMemo(()=>{const p=new Set([...Object.keys(e),...Object.keys(n)]),x=[];for(const y of p){if(y==="inherits"||y==="version")continue;const b=e[y],v=n[y],E=y in e,w=y in n;let A;!E&&w?A="added":E&&!w?A="removed":JSON.stringify(b)!==JSON.stringify(v)?A="changed":A="same",x.push({key:y,left:b,right:v,status:A})}return x.sort((y,b)=>{const v={changed:0,added:1,removed:2,same:3};return v[y.status]!==v[b.status]?v[y.status]-v[b.status]:y.key.localeCompare(b.key)})},[e,n]),d=S.useMemo(()=>{let p=[...u];if(a==="changes"&&(p=p.filter(x=>x.status!=="same")),l){const x=l.toLowerCase();p=p.filter(y=>y.key.toLowerCase().includes(x)||String(y.left).toLowerCase().includes(x)||String(y.right).toLowerCase().includes(x))}return p},[u,a,l]),f=S.useMemo(()=>({added:u.filter(p=>p.status==="added").length,removed:u.filter(p=>p.status==="removed").length,changed:u.filter(p=>p.status==="changed").length,same:u.filter(p=>p.status==="same").length}),[u]),g=p=>{if(p===void 0)return"—";if(p===null)return"null";if(Array.isArray(p))return p.length===0?"[]":p.length===1?String(p[0]):p.join(", ");if(typeof p=="object")return JSON.stringify(p);const x=String(p);if(x.includes("\\n")||x.length>100){const y=x.split("\\n").length;if(y>1)return`[${y} lines of G-code/script]`;if(x.length>100)return x.substring(0,100)+"…"}return x};return S.useEffect(()=>{const p=x=>{x.key==="Escape"&&t()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(vt,{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(xp,{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(zt,{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(mr,{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(d3,{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(o3,{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(sA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Ml,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:l,onChange:p=>c(p.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>o("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),s.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(sA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:d.map(p=>{const x={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[p.status],y={added:s.jsx(mr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(d3,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(o3,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(sA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[p.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${x}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[y,s.jsx("span",{className:"text-sm text-white font-mono",children:p.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="removed"?"text-red-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${p.status==="added"?"text-green-300":p.status==="changed"?"text-white":"text-bambu-gray"}`,children:g(p.right)})})]},p.key)})})]})})]})})})}function BWe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=dr(),i=ln(),a=!!e?.setting_id,[o,l]=S.useState("common"),[c,u]=S.useState(e?.type||"filament"),[d,f]=S.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[g,p]=S.useState(e?.base_id||""),[x,y]=S.useState(""),[b,v]=S.useState(e?.setting||{inherits:""}),[E,w]=S.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,N]=S.useState(null),[C,T]=S.useState(""),[O,k]=S.useState(!1),[R,z]=S.useState(""),[D,K]=S.useState(!1),[P,W]=S.useState(fne),[Z,G]=S.useState(!1),[Y,X]=S.useState(""),[q,F]=S.useState(""),[V,te]=S.useState(!0),[re,ae]=S.useState(null),[he,ue]=S.useState(!1),ce=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),fe=S.useMemo(()=>ce.filter(ge=>kb(ge.setting_id)),[ce]),{data:pe}=ht({queryKey:["cloudFields",c],queryFn:()=>be.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:_e}=ht({queryKey:["allPresetDetails",c,fe.map(ge=>ge.setting_id).join(",")],queryFn:async()=>{const ge={};for(let qe=0;qe<fe.length;qe+=5){const Ze=fe.slice(qe,qe+5);(await Promise.all(Ze.map(async ie=>{try{const Ie=await be.getCloudSettingDetail(ie.setting_id);return{id:ie.setting_id,detail:Ie}}catch{return null}}))).forEach(ie=>{ie&&(ge[ie.id]=ie.detail)})}return ge},enabled:fe.length>0,staleTime:1e3*60*10}),{data:ne,isLoading:He}=ht({queryKey:["cloudSettingDetail",g],queryFn:()=>be.getCloudSettingDetail(g),enabled:!!g});S.useEffect(()=>{o!=="json"&&w(JSON.stringify(b,null,2))},[b,o]);const B=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(Je=>!kb(Je.setting_id)).sort((Je,qe)=>Je.name.localeCompare(qe.name)),[n,c]);S.useEffect(()=>{if(!g)return;const ge=B.find(Je=>Je.setting_id===g);ge&&(y(ge.name),a||(v({inherits:ge.name}),w(JSON.stringify({inherits:ge.name},null,2))))},[g,B,a]);const H=S.useMemo(()=>{const ge=pe?.fields||[],Je=new Set(ge.map(ie=>ie.key)),qe=new Set,Ze=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);_e&&Object.values(_e).forEach(ie=>{ie?.setting&&Object.keys(ie.setting).forEach(Ie=>{!Je.has(Ie)&&!Ze.has(Ie)&&qe.add(Ie)})}),Object.keys(b).forEach(ie=>{!Je.has(ie)&&!Ze.has(ie)&&qe.add(ie)});const lt=Array.from(qe).sort().map(ie=>({key:ie,label:ie.replace(/_/g," ").replace(/\b\w/g,Ie=>Ie.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...ge,...lt]},[pe,_e,b]),le=H.filter(ge=>ge.label.toLowerCase().includes(C.toLowerCase())||ge.key.toLowerCase().includes(C.toLowerCase())),$=()=>{if(R.trim()){const ge=R.trim().toLowerCase().replace(/\s+/g,"_");ee(ge,""),z(""),K(!1),r(`Field "${ge}" added`)}},ee=(ge,Je)=>{v(qe=>{const Ze={...qe};return Je===""||Je===void 0?delete Ze[ge]:Ze[ge]=Je,Ze})},de=ge=>{v(Je=>({...Je,...ge.settings})),ae(ge.name),r("Template applied")},ke=()=>{if(!Y.trim())return;const ge={...b};if(delete ge.inherits,Object.keys(ge).length===0){r("No overrides to save","error");return}const Je={id:Date.now().toString(),name:Y.trim(),description:q.trim()||"Custom template",type:c,settings:ge,showInModal:V},qe=[...P,Je];W(qe),mne(qe),G(!1),X(""),F(""),te(!0),r("Template saved")},we=S.useMemo(()=>P.filter(ge=>ge.type===c&&ge.showInModal),[c,P]),Ee=ge=>{w(ge);try{const Je=JSON.parse(ge);v(Je),N(null)}catch(Je){N(Je.message)}},U=ge=>{ge.preventDefault(),k(!1);const Je=ge.dataTransfer.files[0];if(Je&&Je.name.endsWith(".json")){const qe=new FileReader;qe.onload=Ze=>{try{const lt=Ze.target?.result,ie=JSON.parse(lt),Ie=ie.setting||ie;v(xe=>({...xe,...Ie})),w(JSON.stringify({...b,...Ie},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},qe.readAsText(Je)}},I=xt({mutationFn:()=>{const ge={...b},Je=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";ge[Je]=`"${d}"`;const qe={type:c,name:d,base_id:g,setting:ge};return be.createCloudSetting(qe)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ge=>r(ge.message,"error")}),se=xt({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return be.updateCloudSetting(e.setting_id,{name:d,setting:b})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:ge=>r(ge.message,"error")}),ye=a?se:I,Se=ne?.setting?.inherits,ve=Se?B.find(ge=>ge.name===Se):void 0,{data:Be}=ht({queryKey:["cloudSettingDetail",ve?.setting_id],queryFn:()=>be.getCloudSettingDetail(ve.setting_id),enabled:!!ve?.setting_id}),Ge=S.useMemo(()=>{const ge=Be?.setting||{},Je=ne?.setting||{},qe=g&&_e?.[g]?.setting?_e[g].setting:{};return{...ge,...Je,...qe}},[g,ne,Be,_e]),Ke=ge=>{if(ge==null)return"";if(Array.isArray(ge)){const Je=[...new Set(ge.map(qe=>String(qe)))];return Je.length===1?Je[0]:ge.join(", ")}return String(ge)},ct=ge=>{const Je=b[ge.key],qe=Ge[ge.key],Ze=Ke(qe),lt=He?"Loading...":Ze||"",ie="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(ge.type==="boolean"){const Ie=Je==="1"||Je===void 0&&qe==="1";return s.jsx("button",{type:"button",onClick:()=>ee(ge.key,Je==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ie?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ie?"translate-x-3.5":"translate-x-0.5"}`})})}return ge.type==="select"?s.jsxs("select",{value:Je||"",onChange:Ie=>ee(ge.key,Ie.target.value),className:ie,children:[s.jsx("option",{value:"",children:lt}),ge.options?.map(Ie=>s.jsx("option",{value:Ie.value,children:Ie.label},Ie.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:ge.type==="number"?"number":"text",value:Je!==void 0?String(Je):"",onChange:Ie=>ee(ge.key,Ie.target.value),step:ge.step,min:ge.min,max:ge.max,placeholder:lt,className:ie}),ge.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:ge.unit})]})},$e=S.useMemo(()=>ne?.setting?ne.setting:{},[ne]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:ge=>{ge.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:U,children:[he&&g&&s.jsx(pne,{onClose:()=>ue(!1),leftPreset:$e,rightPreset:b,leftLabel:`Base: ${x||g}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(vt,{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:[g&&s.jsxs("button",{onClick:()=>ue(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[s.jsx(xp,{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(zt,{className:"w-5 h-5"})})]})]}),O&&s.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(qi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),s.jsxs("select",{value:c,onChange:ge=>{u(ge.target.value),p("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"filament",children:"Filament"}),s.jsx("option",{value:"print",children:"Process"}),s.jsx("option",{value:"printer",children:"Printer"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),s.jsxs("select",{value:g,onChange:ge=>p(ge.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..."}),B.map(ge=>s.jsx("option",{value:ge.setting_id,children:ge.name},ge.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:ge=>f(ge.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"My Custom Preset"})]})]}),x&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(ds,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:x}),He&&s.jsx(gt,{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(PU,{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(MR,{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(KG,{className:"w-4 h-4"}),"JSON",A&&s.jsx(Na,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const ge={name:d,type:c,base_id:g,setting:b},Je=new Blob([JSON.stringify(ge,null,2)],{type:"application/json"}),qe=URL.createObjectURL(Je),Ze=document.createElement("a");Ze.href=qe,Ze.download=`${d||"preset"}.json`,document.body.appendChild(Ze),Ze.click(),document.body.removeChild(Ze),URL.revokeObjectURL(qe),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[s.jsx(Mi,{className:"w-4 h-4"}),"Export"]}),s.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[s.jsx(qi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:ge=>{const Je=ge.target.files?.[0];if(Je){const qe=new FileReader;qe.onload=Ze=>{try{const lt=JSON.parse(Ze.target?.result),ie=lt.setting||lt;v(Ie=>({...Ie,...ie})),r("File imported")}catch{r("Invalid JSON","error")}},qe.readAsText(Je)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(H0,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(b).filter(ge=>ge!=="inherits").length>0&&s.jsxs("button",{onClick:()=>G(!Z),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(js,{className:"w-3 h-3"}),"Save as template"]})]}),Z&&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:Y,onChange:ge=>X(ge.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:q,onChange:ge=>F(ge.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(Te,{size:"sm",onClick:ke,disabled:!Y.trim(),children:[s.jsx(js,{className:"w-3 h-3"}),"Save"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>te(!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(lf,{className:"w-3.5 h-3.5"}):s.jsx(dM,{className:"w-3.5 h-3.5"}),V?"Show in modals":"Hidden in modals"]})]})]}),re&&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(ds,{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:re})]}),s.jsx("button",{onClick:()=>ae(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(zt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[we.map(ge=>s.jsxs("button",{onClick:()=>de(ge),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:ge.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:ge.description})]},ge.id)),we.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:H.slice(0,10).map(ge=>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:ge.label}),s.jsx("div",{className:"w-48",children:ct(ge)})]},ge.key))})]}),Object.keys(b).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(b).filter(([ge])=>ge!=="inherits").map(([ge,Je])=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[ge,": ",String(Je).slice(0,20),s.jsx("button",{onClick:()=>ee(ge,void 0),className:"hover:text-white",children:s.jsx(zt,{className:"w-3 h-3"})})]},ge))})]})]}),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?`${H.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:C,onChange:ge=>T(ge.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:[le.filter(ge=>!(ge.key in b)).map(ge=>{const Je=Ge[ge.key],qe=Ke(Je);return s.jsxs("div",{onClick:()=>{v(Ze=>({...Ze,[ge.key]:qe||""}))},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:ge.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:ge.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[qe&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:qe,children:[qe.slice(0,20),qe.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(mr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},ge.key)}),le.filter(ge=>!(ge.key in b)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:C?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:D?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:R,onChange:ge=>z(ge.target.value),onKeyDown:ge=>ge.key==="Enter"&&$(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx(Te,{size:"sm",onClick:$,disabled:!R.trim(),children:s.jsx(mr,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>{K(!1),z("")},children:s.jsx(zt,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>K(!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(mr,{className:"w-4 h-4"}),"Add custom field"]})})]}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(b).filter(ge=>ge!=="inherits").length," fields"]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(b).filter(([ge])=>ge!=="inherits").map(([ge,Je])=>{const qe=H.find(Ze=>Ze.key===ge);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:qe?.label||ge}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:ge})]}),s.jsx("button",{onClick:()=>ee(ge,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(zt,{className:"w-4 h-4"})})]}),qe?ct(qe):s.jsx("input",{type:"text",value:String(Je),onChange:Ze=>ee(ge,Ze.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},ge)}),Object.keys(b).filter(ge=>ge!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(PU,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"No overrides yet"}),s.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(b).filter(ge=>ge!=="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(js,{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(Na,{className:"w-4 h-4"}),A]}),s.jsx("textarea",{value:E,onChange:ge=>Ee(ge.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(Te,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{onClick:()=>ye.mutate(),disabled:ye.isPending||!d.trim()||!a&&!g||!!A,className:"flex-1",children:[ye.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):a?s.jsx(js,{className:"w-4 h-4"}):s.jsx(mr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function HWe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,o]=S.useState(""),[l,c]=S.useState("all"),[u,d]=S.useState("all"),[f,g]=S.useState("all"),[p,x]=S.useState("all"),[y,b]=S.useState("all"),[v,E]=S.useState("all"),[w,A]=S.useState(null),[N,C]=S.useState(!1),[T,O]=S.useState(!1),[k,R]=S.useState(null),[z,D]=S.useState(null),[K,P]=S.useState(null),[W,Z]=S.useState(!1),[G,Y]=S.useState([null,null]),[X,q]=S.useState(!1),[F,V]=S.useState(null),te=ln(),re=S.useMemo(()=>[...t.filament.map(le=>({...le,type:"filament"})),...t.printer.map(le=>({...le,type:"printer"})),...t.process.map(le=>({...le,type:"process"}))].map(le=>({...le,meta:J4(le.name)})),[t]),ae=S.useMemo(()=>{const H=new Set,le=new Set,$=new Set;return re.forEach(ee=>{ee.meta.nozzle&&H.add(ee.meta.nozzle),ee.meta.filamentType&&le.add(ee.meta.filamentType),ee.meta.layerHeight&&$.add(ee.meta.layerHeight)}),{printers:i.map(ee=>({id:ee.id.toString(),name:ee.name})),nozzles:Array.from(H).sort((ee,de)=>parseFloat(ee)-parseFloat(de)),filaments:Array.from(le).sort(),layerHeights:Array.from($).sort((ee,de)=>parseFloat(ee)-parseFloat(de))}},[re,i]),he=S.useMemo(()=>f==="all"?null:i.find(le=>le.id.toString()===f)?.model||null,[f,i]),ue=S.useMemo(()=>re.filter(H=>l==="all"||H.type===l).filter(H=>{if(u==="all")return!0;const le=kb(H.setting_id);return u==="custom"?le:!le}).filter(H=>{if(f==="all"||!he)return!0;const le=H.meta.printer?.toLowerCase()||"",$=he.toLowerCase();return le.includes($)||$.includes(le)}).filter(H=>p==="all"||H.meta.nozzle===p).filter(H=>y==="all"||H.meta.filamentType===y).filter(H=>v==="all"||H.meta.layerHeight===v).filter(H=>a===""||H.name.toLowerCase().includes(a.toLowerCase())).sort((H,le)=>H.name.localeCompare(le.name)),[re,l,u,f,he,p,y,v,a]),ce=H=>{if(W){const le=G[0]?.setting_id===H.setting_id,$=G[1]?.setting_id===H.setting_id;if(le)Y([G[1],null]);else if($)Y([G[0],null]);else if(!G[0])Y([H,null]);else if(G[1]){if(G[0].type!==H.type)return;Y([G[0],H])}else{if(G[0].type!==H.type)return;Y([G[0],H])}}else A(H)},fe=H=>{if(G[0]?.setting_id===H.setting_id)return 0;if(G[1]?.setting_id===H.setting_id)return 1},pe=async H=>{try{const le=await be.getCloudSettingDetail(H.setting_id),$=H.type==="process"?"print":H.type;R({type:$,name:H.name,base_id:le.base_id||"GFSA00",setting:le.setting||{}}),A(null)}catch(le){console.error("Failed to fetch preset details for duplication:",le)}},_e=async H=>{try{te.removeQueries({queryKey:["cloudSettingDetail",H.setting_id]});const le=await be.getCloudSettingDetail(H.setting_id),$=H.type==="process"?"print":H.type;D({type:$,name:H.name,base_id:le.base_id||"GFSA00",setting:le.setting||{},setting_id:H.setting_id}),A(null)}catch(le){console.error("Failed to fetch preset details for editing:",le)}},ne=()=>{c("all"),d("all"),g("all"),x("all"),b("all"),E("all"),o("")},He=l!=="all"||u!=="all"||f!=="all"||p!=="all"||y!=="all"||v!=="all"||a!=="",B=t.filament.length+t.printer.length+t.process.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-4 mb-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Ml,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:a,onChange:H=>o(H.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:W?"primary":"secondary",onClick:()=>{W?(Z(!1),Y([null,null])):Z(!0)},children:[s.jsx(xp,{className:"w-4 h-4"}),W?"Cancel":"Compare"]}),s.jsxs(Te,{variant:"secondary",onClick:()=>O(!0),children:[s.jsx(H0,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Te,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(Dr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Te,{onClick:()=>C(!0),children:[s.jsx(mr,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(vR,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(np,{label:"Type",value:l,options:[{value:"all",label:"All",count:B},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:H=>c(H)}),s.jsx(np,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:H=>d(H)}),ae.printers.length>0&&s.jsx(np,{label:"Printer",value:f,options:[{value:"all",label:"All"},...ae.printers.map(H=>({value:H.id,label:H.name}))],onChange:g}),ae.nozzles.length>0&&s.jsx(np,{label:"Nozzle",value:p,options:[{value:"all",label:"All"},...ae.nozzles.map(H=>({value:H,label:H}))],onChange:x}),ae.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(np,{label:"Filament",value:y,options:[{value:"all",label:"All"},...ae.filaments.map(H=>({value:H,label:H}))],onChange:b}),ae.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(np,{label:"Layer",value:v,options:[{value:"all",label:"All"},...ae.layerHeights.map(H=>({value:H,label:H}))],onChange:E}),He&&s.jsx("button",{onClick:ne,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(xp,{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(o3,{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(Te,{size:"sm",onClick:async()=>{try{const[H,le]=await Promise.all([be.getCloudSettingDetail(G[0].setting_id),be.getCloudSettingDetail(G[1].setting_id)]);V([H.setting||{},le.setting||{}]),q(!0)}catch{}},children:[s.jsx(xp,{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(ur,{className:"w-3 h-3"}),"Last synced: ",LWe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",ue.length," of ",B," presets"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),s.jsx("span",{children:"= My preset (editable)"})]})]}),ue.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(Md,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),He&&s.jsx("button",{onClick:ne,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(xR,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ue.filter(H=>H.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ue.filter(H=>H.type==="filament").map(H=>s.jsx(Gk,{setting:H,onClick:()=>ce(H),onDuplicate:()=>pe(H),compareMode:W,isCompareSelected:fe(H)!==void 0,compareIndex:fe(H),compareDisabled:W&&!!G[0]&&G[0].type!==H.type},H.setting_id)),ue.filter(H=>H.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(mM,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ue.filter(H=>H.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ue.filter(H=>H.type==="process").map(H=>s.jsx(Gk,{setting:H,onClick:()=>ce(H),onDuplicate:()=>pe(H),compareMode:W,isCompareSelected:fe(H)!==void 0,compareIndex:fe(H),compareDisabled:W&&!!G[0]&&G[0].type!==H.type},H.setting_id)),ue.filter(H=>H.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Ei,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ue.filter(H=>H.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ue.filter(H=>H.type==="printer").map(H=>s.jsx(Gk,{setting:H,onClick:()=>ce(H),onDuplicate:()=>pe(H),compareMode:W,isCompareSelected:fe(H)!==void 0,compareIndex:fe(H),compareDisabled:W&&!!G[0]&&G[0].type!==H.type},H.setting_id)),ue.filter(H=>H.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&s.jsx(UWe,{setting:w,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>pe(w),onEdit:()=>_e(w)}),(N||k||z||K)&&s.jsx(BWe,{onClose:()=>{C(!1),R(null),D(null),P(null)},initialData:z||k||(K?{type:K.type,name:"",base_id:"",setting:K.setting}:void 0),allPresets:t}),T&&s.jsx(zWe,{onClose:()=>O(!1),onApply:H=>{P({type:H.type,setting:H.settings}),O(!1)}}),X&&F&&G[0]&&G[1]&&s.jsx(pne,{onClose:()=>{q(!1),V(null)},leftPreset:F[0],rightPreset:F[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function $We(){const t=ln(),{showToast:e}=dr(),[n,r]=S.useState("cloud"),[i,a]=S.useState(),{data:o,isLoading:l}=ht({queryKey:["cloudStatus"],queryFn:be.getCloudStatus}),{data:c=[]}=ht({queryKey:["printers"],queryFn:be.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:g}=ht({queryKey:["cloudSettings"],queryFn:()=>be.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});S.useEffect(()=>{g&&a(new Date(g))},[g]);const p=xt({mutationFn:be.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),x=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(gt,{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(uM,{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(hM,{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(Te,{variant:"secondary",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[s.jsx(aue,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(HWe,{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(Te,{onClick:()=>f(),children:"Retry"})]}):s.jsx(IWe,{onSuccess:x})]}),n==="kprofiles"&&s.jsx(OWe,{}),s.jsx(FWe,{})]})}const d0={Droplet:xR,Flame:pce,Ruler:que,Sparkles:H0,Square:Nd,Cable:hle,Wrench:Ad,Calendar:Wr,Timer:ad,Cog:Hle,Fan:XG,Zap:hf,Wind:cW,Thermometer:gM,Layers:Md,Box:vl,Target:rW,RefreshCw:Dr,Settings:pM,Filter:vR,CircleDot:Cle};function O0(t){return t&&d0[t]||Ad}function rp(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 Wk(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 VWe(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 GWe({item:t,onPerform:e,onToggle:n}){const r=O0(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 ${rp(Math.abs(f),"days")}`:t.is_warning?`Due in ${rp(f,"days")}`:`${rp(f,"days")} left`}else return t.is_due?`Overdue by ${rp(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${rp(t.hours_until_due,"hours")}`:`${rp(t.hours_until_due,"hours")} left`};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[s.jsx(r,{className:`w-5 h-5 ${l()}`}),t.enabled&&(t.is_due||t.is_warning)&&s.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&s.jsx("span",{title:"Time-based interval",children:s.jsx(Wr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||VWe(t.maintenance_type_name,t.printer_model);return f?s.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:"View documentation",onClick:g=>g.stopPropagation(),children:s.jsx(qr,{className:"w-3.5 h-3.5"})}):null})()]}),s.jsx("div",{className:"mt-2 mb-1.5",children:s.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${o}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&s.jsx(Cn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(ur,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(ds,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Vn,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Te,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(fg,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function WWe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=S.useState(!0),[o,l]=S.useState(!1),[c,u]=S.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((p,x)=>p.is_due&&!x.is_due?-1:!p.is_due&&x.is_due?1:p.is_warning&&!x.is_warning?-1:!p.is_warning&&x.is_warning?1:p.maintenance_type_id-x.maintenance_type_id),f=d.find(p=>p.enabled&&(p.is_due||p.is_warning)),g=()=>{const p=parseFloat(c);!isNaN(p)&&p>=0&&(r(t.printer_id,p),l(!1))};return s.jsxs(vt,{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(Cn,{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(ur,{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(ds,{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(zd,{className:"w-4 h-4"}):s.jsx(Aa,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),s.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:s.jsx(ad,{className:"w-4 h-4 text-bambu-gray"})}),o?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:c,onChange:p=>u(p.target.value),onKeyDown:p=>{p.key==="Enter"&&g(),p.key==="Escape"&&l(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),s.jsx(Te,{size:"sm",onClick:g,children:"Save"}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):s.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[s.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",s.jsx(uf,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const p=O0(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(GWe,{item:p,onPerform:e,onToggle:n},p.id))})})]})}function qWe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l}){const[c,u]=S.useState(null),[d,f]=S.useState(""),[g,p]=S.useState("hours"),[x,y]=S.useState(!1),[b,v]=S.useState(""),[E,w]=S.useState("100"),[A,N]=S.useState("hours"),[C,T]=S.useState("Wrench"),[O,k]=S.useState(""),[R,z]=S.useState(new Set),[D,K]=S.useState(null),P=S.useMemo(()=>t?t.map($=>({id:$.printer_id,name:$.printer_name})):[],[t]),W=$=>t?t.filter(ee=>ee.maintenance_items.some(de=>de.maintenance_type_id===$)).map(ee=>({printerId:ee.printer_id,printerName:ee.printer_name,itemId:ee.maintenance_items.find(de=>de.maintenance_type_id===$)?.id})):[],Z=$=>{if(!t)return[];const ee=new Set(W($).map(de=>de.printerId));return P.filter(de=>!ee.has(de.id))},[G,Y]=S.useState(null),[X,q]=S.useState(""),[F,V]=S.useState(""),[te,re]=S.useState("hours"),[ae,he]=S.useState("Wrench"),[ue,ce]=S.useState(""),fe=$=>{Y($),q($.name),V($.default_interval_hours.toString()),re($.interval_type||"hours"),he($.icon||"Wrench"),ce($.wiki_url||"")},pe=()=>{G&&X.trim()&&parseFloat(F)>0&&(i(G.id,{name:X.trim(),default_interval_hours:parseFloat(F),interval_type:te,icon:ae,wiki_url:ue.trim()||null}),Y(null))},_e=($,ee,de)=>{const ke=parseFloat(d);if(!isNaN(ke)&&ke>0){const we=Math.abs(ke-ee)<.01?null:ke;n($,{custom_interval_hours:we,custom_interval_type:g!==de?g:null})}u(null)},ne=$=>{$.preventDefault(),b.trim()&&parseFloat(E)>0&&R.size>0&&(r({name:b.trim(),default_interval_hours:parseFloat(E),interval_type:A,icon:C,wiki_url:O.trim()||null},Array.from(R)),v(""),w("100"),N("hours"),k(""),z(new Set),y(!1))},He=$=>{z(ee=>{const de=new Set(ee);return de.has($)?de.delete($):de.add($),de})},B=t?.map($=>({printerId:$.printer_id,printerName:$.printer_name,items:$.maintenance_items.sort((ee,de)=>ee.maintenance_type_id-de.maintenance_type_id)})).sort(($,ee)=>$.printerName.localeCompare(ee.printerName))||[],H=e.filter($=>$.is_system),le=e.filter($=>!$.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),s.jsxs(Te,{onClick:()=>y(!x),children:[s.jsx(mr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),x&&s.jsx(vt,{className:"mb-6",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("form",{onSubmit:ne,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),s.jsx("input",{type:"text",value:b,onChange:$=>v($.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:$=>{N($.target.value),$.target.value==="days"?w("30"):w("100")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",A==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:E,onChange:$=>w($.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(d0).map($=>{const ee=d0[$];return s.jsx("button",{type:"button",onClick:()=>T($),className:`p-2 rounded-lg transition-colors ${C===$?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(ee,{className:"w-4 h-4"})},$)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),s.jsx("input",{type:"url",value:O,onChange:$=>k($.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:P.map($=>s.jsx("button",{type:"button",onClick:()=>He($.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${R.has($.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:$.name},$.id))}),R.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>{y(!1),z(new Set)},children:"Cancel"}),s.jsx(Te,{type:"submit",disabled:!b.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:[H.map($=>{const ee=O0($.icon),de=$.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(ee,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-white truncate",children:$.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[de==="days"?s.jsx(Wr,{className:"w-3 h-3"}):s.jsx(ad,{className:"w-3 h-3"}),Wk($.default_interval_hours,de)]})]})]})},$.id)}),le.map($=>{const ee=O0($.icon),de=$.interval_type||"hours";if(G?.id===$.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:X,onChange:I=>q(I.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:te,onChange:I=>re(I.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:F,onChange:I=>V(I.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(d0).map(I=>{const se=d0[I];return s.jsx("button",{type:"button",onClick:()=>he(I),className:`p-1.5 rounded transition-colors ${ae===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(se,{className:"w-3.5 h-3.5"})},I)})}),s.jsx("input",{type:"url",value:ue,onChange:I=>ce(I.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(Te,{size:"sm",onClick:pe,disabled:!X.trim(),children:"Save"}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Y(null),children:"Cancel"})]})]})},$.id);const we=W($.id),Ee=Z($.id),U=D===$.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(ee,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:$.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[de==="days"?s.jsx(Wr,{className:"w-3 h-3"}):s.jsx(ad,{className:"w-3 h-3"}),Wk($.default_interval_hours,de)]})]}),s.jsxs("button",{onClick:()=>K(U?null:$.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${we.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:`${we.length} printer(s) assigned - click to manage`,children:[s.jsx(Ei,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:we.length}),s.jsx(Aa,{className:`w-3 h-3 transition-transform ${U?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>fe($),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(uf,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${$.name}"?`)&&a($.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(vn,{className:"w-4 h-4"})})]}),U&&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:"}),we.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:we.map(I=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[I.printerName,s.jsx("button",{onClick:()=>I.itemId&&l(I.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},I.printerId))}),Ee.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),Ee.map(I=>s.jsxs("button",{onClick:()=>o(I.id,$.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",I.name]},I.id))]})]})]},$.id)})]})]}),B.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:B.map($=>s.jsx(vt,{children:s.jsxs(Mt,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:$.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:$.items.map(ee=>{const de=O0(ee.maintenance_type_icon),ke=e.find(se=>se.id===ee.maintenance_type_id),we=ke?.default_interval_hours||ee.interval_hours,Ee=ke?.interval_type||"hours",U=ee.interval_type||"hours",I=c===ee.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(de,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:ee.maintenance_type_name}),I?s.jsxs("div",{className:"flex items-center gap-1",children:[g==="days"?s.jsx(Wr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(ad,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:g,onChange:se=>p(se.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:se=>f(se.target.value),onKeyDown:se=>{se.key==="Enter"&&_e(ee.id,we,Ee),se.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(Te,{size:"sm",onClick:()=>_e(ee.id,we,Ee),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(ee.id),f(ee.interval_hours.toString()),p(U)},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:[U==="days"?s.jsx(Wr,{className:"w-3 h-3"}):s.jsx(ad,{className:"w-3 h-3"}),Wk(ee.interval_hours,U),s.jsx(uf,{className:"w-3 h-3 text-bambu-gray"})]})]},ee.id)})})]})},$.printerId))})]}),B.length===0&&s.jsx(vt,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx(ur,{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 KWe(){const t=ln(),{showToast:e}=dr(),[n,r]=S.useState("status"),{data:i,isLoading:a}=ht({queryKey:["maintenanceOverview"],queryFn:be.getMaintenanceOverview}),{data:o}=ht({queryKey:["maintenanceTypes"],queryFn:be.getMaintenanceTypes}),l=xt({mutationFn:({id:w,notes:A})=>be.performMaintenance(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:w=>{e(w.message,"error")}}),c=xt({mutationFn:({id:w,data:A})=>be.updateMaintenanceItem(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:w=>{e(w.message,"error")}}),u=xt({mutationFn:({id:w,data:A})=>be.updateMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:w=>{e(w.message,"error")}}),d=xt({mutationFn:be.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:w=>{e(w.message,"error")}}),f=xt({mutationFn:({printerId:w,hours:A})=>be.setPrinterHours(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:w=>{e(w.message,"error")}}),g=xt({mutationFn:({printerId:w,typeId:A})=>be.assignMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:w=>{e(w.message,"error")}}),p=xt({mutationFn:be.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:w=>{e(w.message,"error")}}),x=w=>{l.mutate({id:w})},y=(w,A)=>{c.mutate({id:w,data:{enabled:A}})},b=(w,A)=>{f.mutate({printerId:w,hours:A})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const v=i?.reduce((w,A)=>w+A.due_count,0)||0,E=i?.reduce((w,A)=>w+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&&E>0&&" · ",E>0&&s.jsxs("span",{className:"text-amber-400",children:[E," due soon"]}),v===0&&E===0&&s.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>r("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),s.jsx("button",{onClick:()=>r("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?s.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((w,A)=>{const N=w.due_count*10+w.warning_count,C=A.due_count*10+A.warning_count;return N!==C?C-N:w.printer_name.localeCompare(A.printer_name)}).map(w=>s.jsx(WWe,{overview:w,onPerform:x,onToggle:y,onSetHours:b},w.printer_id)):s.jsx(vt,{children:s.jsxs(Mt,{className:"text-center py-16",children:[s.jsx(Ad,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):s.jsx(qWe,{overview:i,types:o||[],onUpdateInterval:(w,A)=>c.mutate({id:w,data:A}),onAddType:async(w,A)=>{const N=await be.createMaintenanceType(w);for(const C of A)await be.assignMaintenanceType(C,N.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(w,A)=>u.mutate({id:w,data:A}),onDeleteType:w=>d.mutate(w),onAssignType:(w,A)=>g.mutate({printerId:w,typeId:A}),onRemoveItem:w=>p.mutate(w)})]})}const aG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function gne({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.description||""),[c,u]=S.useState(t?.color||aG[0]),[d,f]=S.useState(t?.target_count?.toString()||""),[g,p]=S.useState(t?.status||"active"),[x,y]=S.useState(t?.tags||""),[b,v]=S.useState(t?.due_date?.split("T")[0]||""),[E,w]=S.useState(t?.priority||"normal"),A=N=>{N.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,tags:x.trim()||void 0,due_date:b||void 0,priority:E,...t&&{status:g}})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),s.jsxs("form",{onSubmit:A,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:N=>a(N.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:N=>l(N.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:aG.map(N=>s.jsx("button",{type:"button",onClick:()=>u(N),className:`w-8 h-8 rounded-full transition-transform ${c===N?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:N}},N))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Print Count (optional)"}),s.jsx("input",{type:"number",value:d,onChange:N=>f(N.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 50 parts to print",min:"1"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),s.jsx("input",{type:"text",value:x,onChange:N=>y(N.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., voron, functional, gift"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),s.jsx("input",{type:"date",value:b,onChange:N=>v(N.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),s.jsxs("select",{value:E,onChange:N=>w(N.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"normal",children:"Normal"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),s.jsxs("select",{value:g,onChange:N=>p(N.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(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Te,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function XWe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.progress_percent??0,a=t.status==="completed",o=t.status==="archived",[l,c]=S.useState(!1),d=a?{icon:Y1,color:"text-bambu-green",bg:"bg-bambu-green/10"}:o?{icon:Ho,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:ur,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:ha,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return s.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[s.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),s.jsxs("div",{className:"p-5 pl-6",children:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg ${d.bg} flex-shrink-0`,children:s.jsx(d.icon,{className:`w-5 h-5 ${d.color}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${i>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_count," completed"]}):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," completed"]}):null,a&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),o&&s.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const f=t.archives.map(y=>y.filament_type).filter(Boolean).flatMap(y=>y.split(",").map(b=>b.trim())).filter(Boolean),g=[...new Set(f)],p=t.archives.map(y=>y.filament_color).filter(Boolean).flatMap(y=>y.split(",").map(b=>b.trim())).filter(y=>y.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(y)),x=[...new Set(p)];return g.length===0&&x.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[g.slice(0,3).map(y=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:y},y)),x.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[x.slice(0,5).map(y=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:y.startsWith("#")?y:`#${y}`},title:y},y)),x.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",x.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:f=>f.stopPropagation(),children:[s.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>c(!l),children:s.jsx(gp,{className:"w-4 h-4"})}),l&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>c(!1)}),s.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),c(!1)},children:[s.jsx(uf,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),c(!1)},children:[s.jsx(vn,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-2",children:[s.jsx("span",{className:"text-bambu-gray",children:"Progress"}),s.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2.5 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=100?"#22c55e":t.color||"#6b7280"}60`}})}),s.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray/60 mt-1",children:[s.jsx("span",{children:t.failed_count>0&&`${t.failed_count} failed`}),s.jsxs("span",{children:[i.toFixed(0),"% complete"]})]})]}):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(Ho,{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(Cn,{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(ur,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(f=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:f.print_name||"Unknown",children:[f.thumbnail_path?s.jsx("img",{src:be.getArchiveThumbnail(f.id),alt:f.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(Gc,{className:"w-6 h-6"})}),f.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(Cn,{className:"w-4 h-4 text-white"})})]},f.id))}),t.archive_count>4&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[s.jsxs("div",{className:"flex items-center gap-1.5",title:"Completed prints",children:[s.jsx(Y1,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsx("span",{children:t.completed_count})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed prints",children:[s.jsx(Cn,{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-blue-400",title:"In queue",children:[s.jsx(u3,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Zo,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function YWe(){const t=Rb(),e=ln(),{showToast:n}=dr(),[r,i]=S.useState(!1),[a,o]=S.useState(),[l,c]=S.useState("active"),[u,d]=S.useState(null),{data:f,isLoading:g}=ht({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>be.getProjects(l==="all"?void 0:l)}),p=xt({mutationFn:C=>be.createProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:C=>{n(C.message,"error")}}),x=xt({mutationFn:({id:C,data:T})=>be.updateProject(C,T),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:C=>{n(C.message,"error")}}),y=xt({mutationFn:C=>be.deleteProject(C),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:C=>{d(null),n(C.message,"error")}}),b=C=>{a?x.mutate({id:a.id,data:C}):p.mutate(C)},v=C=>{o(C),i(!0)},E=C=>{t(`/projects/${C.id}`)},w=C=>{d(C)},A=()=>{u!==null&&y.mutate(u)},N=f?.reduce((C,T)=>(C[T.status]=(C[T.status]||0)+1,C.all=(C.all||0)+1,C),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(ha,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),s.jsxs(Te,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(mr,{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:ur},{key:"completed",label:"Completed",icon:Y1},{key:"archived",label:"Archived",icon:Ho},{key:"all",label:"All",icon:ha}].map(({key:C,label:T,icon:O})=>s.jsxs("button",{onClick:()=>c(C),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===C?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(O,{className:"w-4 h-4"}),s.jsx("span",{children:T}),N[C]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===C?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:N[C]})]},C))}),g?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(gt,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(ha,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&s.jsxs(Te,{onClick:()=>i(!0),children:[s.jsx(mr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(C=>s.jsx(XWe,{project:C,onClick:()=>E(C),onEdit:()=>v(C),onDelete:()=>w(C.id)},C.id))}),u!==null&&s.jsx(Qn,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:A,onCancel:()=>d(null)}),r&&s.jsx(gne,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:b,isLoading:p.isPending||x.isPending})]})}function ZWe(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 QWe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function JWe({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 sG({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(vt,{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 eqe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Gc,{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(Ac,{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:be.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(Gc,{className:"w-8 h-8"})}),e.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(Sa,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(kr,{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 tqe({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(Cn,{className:"w-3 h-3"}),r]})}function nqe(t){return t?Op(t,{year:"numeric",month:"short",day:"numeric"}):""}function qk(t){if(!t)return null;const e=di(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 rqe(){const{id:t}=lR(),e=Rb(),n=ln(),{showToast:r}=dr(),[i,a]=S.useState(!1),[o,l]=S.useState(!1),[c,u]=S.useState(""),[d,f]=S.useState(!1),g=S.useRef(null),p=parseInt(t||"0",10),{data:x,isLoading:y,error:b}=ht({queryKey:["project",p],queryFn:()=>be.getProject(p),enabled:p>0}),{data:v,isLoading:E}=ht({queryKey:["project-archives",p],queryFn:()=>be.getProjectArchives(p),enabled:p>0}),{data:w,isLoading:A}=ht({queryKey:["project-bom",p],queryFn:()=>be.getProjectBOM(p),enabled:p>0}),{data:N,isLoading:C}=ht({queryKey:["project-timeline",p],queryFn:()=>be.getProjectTimeline(p,20),enabled:p>0}),{data:T}=ht({queryKey:["settings"],queryFn:be.getSettings}),O=T?.currency||"$",k=T?.time_format||"system",R=xt({mutationFn:U=>be.updateProject(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project",p]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:U=>{r(U.message,"error")}}),z=()=>{u(x?.notes||""),l(!0)},D=()=>{R.mutate({notes:c})},K=()=>{l(!1),u("")},P=async U=>{const I=U.target.files?.[0];if(I){f(!0);try{const se=await be.uploadProjectAttachment(p,I);n.invalidateQueries({queryKey:["project",p]}),r(`Uploaded: ${se.original_name}`,"success")}catch(se){r(se.message,"error")}finally{f(!1),g.current&&(g.current.value="")}}},W=(U,I)=>{ne({isOpen:!0,title:"Delete Attachment",message:`Are you sure you want to delete "${I}"?`,onConfirm:async()=>{ne(se=>({...se,isOpen:!1}));try{await be.deleteProjectAttachment(p,U),n.invalidateQueries({queryKey:["project",p]}),r("Attachment deleted","success")}catch(se){r(se.message,"error")}}})},Z=U=>U<1024?`${U} B`:U<1024*1024?`${(U/1024).toFixed(1)} KB`:`${(U/(1024*1024)).toFixed(1)} MB`,[G,Y]=S.useState(""),[X,q]=S.useState(1),[F,V]=S.useState(""),[te,re]=S.useState(""),[ae,he]=S.useState(""),[ue,ce]=S.useState(!1),[fe,pe]=S.useState(!1),[_e,ne]=S.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),He=xt({mutationFn:U=>be.createBOMItem(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),Y(""),q(1),V(""),re(""),he(""),ce(!1),r("Part added","success")},onError:U=>r(U.message,"error")}),B=xt({mutationFn:({itemId:U,data:I})=>be.updateBOMItem(p,U,I),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]})},onError:U=>r(U.message,"error")}),H=xt({mutationFn:U=>be.deleteBOMItem(p,U),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",p]}),n.invalidateQueries({queryKey:["project",p]}),r("Part removed","success")},onError:U=>r(U.message,"error")}),le=U=>{U.preventDefault(),G.trim()&&He.mutate({name:G.trim(),quantity_needed:X,unit_price:F?parseFloat(F):void 0,sourcing_url:te.trim()||void 0,remarks:ae.trim()||void 0})},$=U=>{const I=U.is_complete?0:U.quantity_needed;B.mutate({itemId:U.id,data:{quantity_acquired:I}})},ee=(U,I)=>{ne({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${I}"?`,onConfirm:()=>{ne(se=>({...se,isOpen:!1})),H.mutate(U)}})},de=xt({mutationFn:()=>be.createTemplateFromProject(p),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:U=>r(U.message,"error")}),ke=U=>Lp(U,k,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(y)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(gt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(b||!x)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:b?`Error: ${b.message}`:"Project not found"}),s.jsx(Te,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const we=x.stats,Ee=we?.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(Ac,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Zo,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:x.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(Zoe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:x.name}),x.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:x.description})]})]}),s.jsx(JWe,{status:x.status})]}),s.jsxs(Te,{onClick:()=>a(!0),children:[s.jsx(uf,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),x.target_count&&s.jsx(vt,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[we?.completed_prints||0," / ",x.target_count," completed"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Ee,100)}%`,backgroundColor:Ee>=100?"#22c55e":x.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Ee.toFixed(0),"% complete"]}),x.target_count-(we?.completed_prints||0)>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[x.target_count-(we?.completed_prints||0)," remaining"]})]})]})}),we&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(vt,{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(Gc,{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:[we.completed_prints," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"successful"})]}),we.failed_prints>0&&s.jsxs("p",{className:"text-sm text-red-400",children:[we.failed_prints," failed"]})]})]})})}),s.jsx(sG,{icon:ur,label:"Print Time",value:ZWe(we.total_print_time_hours),color:"text-yellow-400"}),s.jsx(sG,{icon:Ei,label:"Filament Used",value:QWe(we.total_filament_grams),color:"text-purple-400"})]}),we&&(we.estimated_cost>0||x.budget)&&s.jsx(vt,{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:[O,we.estimated_cost.toFixed(2)]})]}),we.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:[we.total_energy_kwh.toFixed(2)," kWh",we.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",O,we.total_energy_cost.toFixed(2),")"]})]})]}),x.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[O,x.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),s.jsxs("p",{className:`text-lg font-semibold ${x.budget-we.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[O,(x.budget-we.estimated_cost).toFixed(2)]})]})]})]})]})}),x.children&&x.children.length>0&&s.jsx(vt,{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(vce,{className:"w-5 h-5"}),"Sub-projects (",x.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:x.children.map(U=>s.jsxs(Ac,{to:`/projects/${U.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:U.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:U.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${U.status==="completed"?"bg-bambu-green/20 text-bambu-green":U.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:U.status})]}),U.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[U.progress_percent.toFixed(0),"%"]})]},U.id))})]})}),x.parent_id&&x.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Md,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(Ac,{to:`/projects/${x.parent_id}`,className:"text-bambu-green hover:underline",children:x.parent_name})]}),(x.tags||x.due_date||x.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[x.priority&&x.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),s.jsx(tqe,{priority:x.priority})]}),x.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wr,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:nqe(x.due_date)}),qk(x.due_date)&&s.jsxs("span",{className:`text-xs ${qk(x.due_date).color}`,children:["(",qk(x.due_date).label,")"]})]}),x.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Dp,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:x.tags.split(",").map((U,I)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:U.trim()},I))})]})]}),s.jsx(vt,{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(is,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:K,disabled:R.isPending,children:[s.jsx(zt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Te,{size:"sm",onClick:D,disabled:R.isPending,children:[R.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(js,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Te,{variant:"secondary",size:"sm",onClick:z,children:[s.jsx(uf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(QP,{content:c,onChange:u,placeholder:"Add notes about this project..."}):x.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:x.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),s.jsx(vt,{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(kue,{className:"w-5 h-5"}),"Attachments (",x.attachments?.length||0,")"]}),s.jsxs("div",{children:[s.jsx("input",{ref:g,type:"file",onChange:P,className:"hidden"}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>g.current?.click(),disabled:d,children:[d?s.jsx(gt,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(qi,{className:"w-4 h-4 mr-1"}),"Upload"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Upload any file: images (PNG, JPG), PDFs, STL files, or documents."}),x.attachments&&x.attachments.length>0?s.jsx("div",{className:"space-y-2",children:x.attachments.map(U=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(yR,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:U.original_name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:Z(U.size)})]})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("a",{href:be.getProjectAttachmentUrl(p,U.filename),download:U.original_name,className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Download",children:s.jsx(Mi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>W(U.filename,U.original_name),className:"p-2 rounded hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(vn,{className:"w-4 h-4"})})]})]},U.filename))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No attachments yet. Click Upload to add files."})]})}),s.jsx(vt,{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(tW,{className:"w-5 h-5"}),"Bill of Materials",we&&we.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",we.bom_completed_items,"/",we.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[w&&w.some(U=>U.is_complete)&&s.jsx("button",{onClick:()=>pe(!fe),className:`text-xs px-2 py-1 rounded transition-colors ${fe?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:fe?"Show all":"Hide done"}),!ue&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>ce(!0),children:[s.jsx(mr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),ue&&s.jsxs("form",{onSubmit:le,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:G,onChange:U=>Y(U.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:X,onChange:U=>q(parseInt(U.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),s.jsx("input",{type:"number",step:"0.01",value:F,onChange:U=>V(U.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 (${O})`})]})]}),s.jsx("input",{type:"url",value:te,onChange:U=>re(U.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),s.jsx("input",{type:"text",value:ae,onChange:U=>he(U.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(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>ce(!1),children:"Cancel"}),s.jsx(Te,{type:"submit",size:"sm",disabled:!G.trim()||He.isPending,children:He.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),A?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(gt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):w&&w.length>0?s.jsxs("div",{className:"space-y-2",children:[w.filter(U=>!fe||!U.is_complete).map(U=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${U.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>$(U),disabled:B.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${U.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:U.is_complete&&s.jsx(kr,{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 ${U.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[U.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",U.quantity_needed]})]}),U.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[O,(U.unit_price*U.quantity_needed).toFixed(2)]})]}),s.jsx("button",{onClick:()=>ee(U.id,U.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(vn,{className:"w-4 h-4"})})]}),U.sourcing_url&&s.jsxs("a",{href:U.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:I=>I.stopPropagation(),children:[s.jsx(qr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(U.sourcing_url).hostname.replace("www.","")}catch{return U.sourcing_url}})()})]}),U.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:U.remarks})]})]})},U.id)),w.some(U=>U.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:[O,w.reduce((U,I)=>U+(I.unit_price||0)*I.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(vt,{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(J1,{className:"w-5 h-5"}),"Activity Timeline"]})}),C?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(gt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):N&&N.length>0?s.jsx("div",{className:"space-y-3",children:N.slice(0,10).map((U,I)=>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 ${U.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":U.event_type==="print_failed"?"bg-red-500/20 text-red-400":U.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[U.event_type==="print_completed"&&s.jsx(kr,{className:"w-4 h-4"}),U.event_type==="print_failed"&&s.jsx(Sa,{className:"w-4 h-4"}),U.event_type==="print_started"&&s.jsx(Ei,{className:"w-4 h-4"}),U.event_type==="queued"&&s.jsx(u3,{className:"w-4 h-4"}),U.event_type==="project_created"&&s.jsx(mr,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:U.title}),U.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:U.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:ke(U.timestamp)})]})]},I))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!x.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>de.mutate(),disabled:de.isPending,children:[de.isPending?s.jsx(gt,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Wo,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),we&&(we.queued_prints>0||we.in_progress_prints>0)&&s.jsx(vt,{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(u3,{className:"w-5 h-5"}),"Queue"]}),s.jsx(Ac,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[we.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[we.in_progress_prints," printing"]}),we.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[we.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(Gc,{className:"w-5 h-5"}),"Prints (",v?.length||0,")"]})}),E?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(gt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(eqe,{archives:v||[]})]}),i&&s.jsx(gne,{project:{...x,archive_count:we?.total_archives||0,total_items:we?.total_items||0,completed_count:we?.completed_prints||0,failed_count:we?.failed_prints||0,queue_count:we?.queued_prints||0,progress_percent:we?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:U=>R.mutate(U),isLoading:R.isPending}),_e.isOpen&&s.jsx(Qn,{title:_e.title,message:_e.message,confirmText:"Delete",variant:"danger",onConfirm:_e.onConfirm,onCancel:()=>ne(U=>({...U,isOpen:!1}))})]})}const Kk=5,iqe=2e3,aqe=3e4,sqe=5e3;function oqe(){const{printerId:t}=lR(),e=parseInt(t||"0",10),[n,r]=S.useState("stream"),[i,a]=S.useState(!1),[o,l]=S.useState(!0),[c,u]=S.useState(Date.now()),[d,f]=S.useState(!1),[g,p]=S.useState(!1),[x,y]=S.useState(0),[b,v]=S.useState(!1),[E,w]=S.useState(0),A=S.useRef(null),N=S.useRef(null),C=S.useRef(null),T=S.useRef(null),O=S.useRef(null),{data:k}=ht({queryKey:["printer",e],queryFn:()=>be.getPrinter(e),enabled:e>0});S.useEffect(()=>(k&&(document.title=`${k.name} - Camera`),()=>{document.title="Bambuddy"}),[k]);const R=S.useRef(!1);S.useEffect(()=>{const q=`/api/v1/printers/${e}/camera/stop`;R.current=!1;const F=()=>{e>0&&!R.current&&(R.current=!0,navigator.sendBeacon(q))},V=()=>{F()};return window.addEventListener("beforeunload",V),()=>{window.removeEventListener("beforeunload",V),A.current&&(A.current.src=""),F()}},[e]),S.useEffect(()=>{if(o&&!d){const F=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(F)}},[n,o,c,d]),S.useEffect(()=>{const q=()=>{const F=!!document.fullscreenElement;p(F),n==="stream"&&!d&&(A.current&&(A.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",q),()=>document.removeEventListener("fullscreenchange",q)},[n,d]),S.useEffect(()=>{let q;const F=()=>{clearTimeout(q),q=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",F),()=>{clearTimeout(q),window.removeEventListener("resize",F)}},[]),S.useEffect(()=>()=>{C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),O.current&&clearInterval(O.current)},[]);const z=S.useCallback(()=>{if(x>=Kk){v(!1),a(!0);return}const q=Math.min(iqe*Math.pow(2,x),aqe);v(!0),w(Math.ceil(q/1e3)),T.current=setInterval(()=>{w(F=>F<=1?(T.current&&clearInterval(T.current),0):F-1)},1e3),C.current=setTimeout(()=>{y(F=>F+1),v(!1),l(!0),a(!1),A.current&&(A.current.src=""),u(Date.now())},q)},[x]);S.useEffect(()=>{if(n!=="stream"||o||b||d){O.current&&(clearInterval(O.current),O.current=null);return}return O.current=setInterval(async()=>{try{const q=await fetch(`/api/v1/printers/${e}/camera/status`);if(q.ok){const F=await q.json();(F.stalled||!F.active&&!i)&&(console.log(`Stream issue detected: stalled=${F.stalled}, active=${F.active}, reconnecting...`),O.current&&(clearInterval(O.current),O.current=null),l(!1),z())}}catch{}},sqe),()=>{O.current&&(clearInterval(O.current),O.current=null)}},[n,o,i,b,d,e,z]);const D=()=>{l(!1),n==="stream"&&x<Kk?z():a(!0)},K=()=>{if(l(!1),a(!1),y(0),v(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),A.current&&!localStorage.getItem("cameraWindowState")){const q=A.current,F=q.naturalWidth,V=q.naturalHeight;if(F>0&&V>0){const ae=window.outerWidth-window.innerWidth,he=window.outerHeight-window.innerHeight,ue=F+16+ae,ce=V+45+16+he;try{window.resizeTo(ue,ce)}catch{}}}},P=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},W=q=>{n===q||d||(f(!0),l(!0),a(!1),y(0),v(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),A.current&&(A.current.src=""),n==="stream"&&P(),setTimeout(()=>{r(q),u(Date.now()),f(!1)},100))},Z=()=>{d||(f(!0),l(!0),a(!1),y(0),v(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),A.current&&(A.current.src=""),n==="stream"&&P(),setTimeout(()=>{u(Date.now()),f(!1)},100))},G=()=>{N.current&&(document.fullscreenElement?document.exitFullscreen():N.current.requestFullscreen())},Y=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,X=o||d||b;return e?s.jsxs("div",{ref:N,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(jp,{className:"w-4 h-4"}),k?.name||`Printer ${e}`]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[s.jsx("button",{onClick:()=>W("stream"),disabled:X,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:()=>W("snapshot"),disabled:X,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:Z,disabled:X,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(Dr,{className:`w-4 h-4 text-bambu-gray ${X?"animate-spin":""}`})}),s.jsx("button",{onClick:G,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:g?"Exit fullscreen":"Fullscreen",children:g?s.jsx(_ue,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(fue,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Dr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Ib,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",E,"s... (attempt ",x+1,"/",Kk,")"]}),s.jsx("button",{onClick:Z,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!b&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Cn,{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:Z,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:A,src:Y,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:Y?D:void 0,onLoad:Y?K:void 0},c)]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function lqe(){const{id:t}=lR(),{mode:e}=mg(),{data:n,isLoading:r,error:i}=ht({queryKey:["external-link",t],queryFn:()=>be.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(gt,{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(Cn,{className:"w-12 h-12"}),s.jsx("p",{children:"Link not found"})]}):s.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function Jr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return s.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function oG({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 Gu({title:t,icon:e,children:n}){return s.jsxs(vt,{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 cqe(){const{t}=cg(),e=ln(),[n,r]=S.useState(null),[i,a]=S.useState(!1),[o,l]=S.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ht({queryKey:["systemInfo"],queryFn:be.getSystemInfo,refetchInterval:3e4}),{data:g}=ht({queryKey:["debugLogging"],queryFn:_1.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:p}=ht({queryKey:["settings"],queryFn:be.getSettings}),x=p?.time_format||"system",y=async()=>{l(!0);try{const w=await _1.setDebugLogging(!g?.enabled);e.setQueryData(["debugLogging"],w)}catch(w){console.error("Failed to toggle debug logging:",w)}finally{l(!1)}},b=async()=>{r(null),a(!0);try{await _1.downloadSupportBundle()}catch(w){r(w instanceof Error?w.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(gt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return s.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const v=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",E=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),s.jsxs("button",{onClick:()=>d(),disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[s.jsx(Dr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(Gu,{title:t("system.application","Application"),icon:wh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Jr,{icon:wh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(Jr,{icon:ur,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(Jr,{icon:wh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(Gu,{title:t("support.title","Support & Troubleshooting"),icon:Oce,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${g?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(qG,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[g?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),g?.enabled&&g.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(g.duration_seconds/60),"m ",g.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:y,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${g?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&s.jsx(gt,{className:"w-4 h-4 animate-spin"}),g?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:s.jsx(Mi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),s.jsxs("button",{onClick:b,disabled:i||!g?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:g?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(gt,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!g?.enabled&&s.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-bambu-gray",children:[s.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),s.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),s.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),s.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),s.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),s.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),s.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),s.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),s.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),s.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),s.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),s.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),s.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),s.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),s.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]})]})}),s.jsxs(Gu,{title:t("system.database","Database"),icon:Pp,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(Jr,{icon:Ho,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(Jr,{icon:Y1,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(Jr,{icon:Sa,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(Jr,{icon:gt,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Jr,{icon:Ei,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(Jr,{icon:ER,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(Jr,{icon:ha,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(Jr,{icon:fo,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(Jr,{icon:ur,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(Jr,{icon:Ho,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(Gu,{title:t("system.connectedPrinters","Connected Printers"),icon:Ei,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(w=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),s.jsx("span",{className:"font-medium text-white",children:w.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:w.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${w.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":w.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:w.state})]})]},w.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(Gu,{title:t("system.storage","Storage"),icon:wR,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(oG,{percent:c.storage.disk_percent_used,color:v}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsx(Jr,{icon:Ho,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(Jr,{icon:Pp,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(Gu,{title:t("system.memory","Memory"),icon:pue,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(oG,{percent:c.memory.percent_used,color:E}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(Gu,{title:t("system.cpu","CPU"),icon:Lv,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Jr,{icon:Lv,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(Jr,{icon:Lv,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(Gu,{title:t("system.systemDetails","System Details"),icon:wh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Jr,{icon:wh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(Jr,{icon:Lv,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(Jr,{icon:wh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(Jr,{icon:ur,label:t("system.bootTime","Boot Time"),value:Lp(c.system.boot_time,x)})]})})]})}function uqe(){const t=S.useRef(null),e=S.useRef(null),n=ln(),[r,i]=S.useState(!1),a=S.useRef(new Set),o=S.useRef(null),l=S.useRef(new Map),c=S.useRef(null),u=S.useRef([]),d=S.useRef(!1),f=S.useRef(()=>{}),g=S.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const E=()=>{const w=u.current.shift();w?requestAnimationFrame(()=>{f.current(w),u.current.length>0?setTimeout(E,16):d.current=!1}):d.current=!1};E()},[]),p=S.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(w);let N=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),N=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=C=>{try{const T=JSON.parse(C.data);T.type==="printer_status"&&T.printer_id!==void 0&&T.data?f.current(T):(u.current.push(T),g())}catch{}},A.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),N&&(clearInterval(N),N=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{p()},3e3)},A.onerror=C=>{console.error("[WebSocket] Error",C),A.close()},t.current=A},[]),x=S.useCallback((E,w)=>{const A=l.current.get(E)||{};l.current.set(E,{...A,...w}),c.current||(c.current=window.setTimeout(()=>{const N=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{N.forEach((C,T)=>{n.setQueryData(["printerStatus",T],O=>{const k={...O,...C};return k.wifi_signal==null&&O?.wifi_signal!=null&&(k.wifi_signal=O.wifi_signal),k})})})},100))},[n]),y=S.useCallback(E=>{a.current.add(E),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const w=Array.from(a.current);a.current.clear(),o.current=null;let A=0;w.forEach(N=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[N]})})},A),A+=500})},3e3)},[n]),b=S.useCallback(E=>{switch(E.type){case"printer_status":E.printer_id!==void 0&&E.data&&x(E.printer_id,E.data);break;case"print_start":E.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",E.printer_id]});break;case"print_complete":y("archives"),y("archiveStats");break;case"archive_created":y("archives"),y("archiveStats");break;case"archive_updated":y("archives");break}},[n,y,x]);S.useEffect(()=>{f.current=b},[b]),S.useEffect(()=>(p(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[p]);const v=S.useCallback(E=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(E))},[]);return{isConnected:r,sendMessage:v}}const dqe=new Toe({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function hqe({children:t}){return uqe(),s.jsx(s.Fragment,{children:t})}function fqe(){return s.jsx(the,{children:s.jsx(fhe,{children:s.jsx(Coe,{client:dqe,children:s.jsx(Yse,{children:s.jsxs(Ase,{children:[s.jsx(es,{path:"/camera/:printerId",element:s.jsx(oqe,{})}),s.jsxs(es,{element:s.jsx(hqe,{children:s.jsx(che,{})}),children:[s.jsx(es,{index:!0,element:s.jsx(OCe,{})}),s.jsx(es,{path:"archives",element:s.jsx(u9e,{})}),s.jsx(es,{path:"queue",element:s.jsx(XGe,{})}),s.jsx(es,{path:"stats",element:s.jsx(cWe,{})}),s.jsx(es,{path:"profiles",element:s.jsx($We,{})}),s.jsx(es,{path:"maintenance",element:s.jsx(KWe,{})}),s.jsx(es,{path:"projects",element:s.jsx(YWe,{})}),s.jsx(es,{path:"projects/:id",element:s.jsx(rqe,{})}),s.jsx(es,{path:"settings",element:s.jsx(PWe,{})}),s.jsx(es,{path:"system",element:s.jsx(cqe,{})}),s.jsx(es,{path:"external/:id",element:s.jsx(lqe,{})})]})]})})})})})}jie.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:s.jsx(fqe,{})}));
|